@@ -144,6 +144,13 @@ func (cic *ClusterClient) Merge(localInv Info, objs object.ObjMetadataSet, dryRu
144
144
return pruneIds , err
145
145
}
146
146
147
+ // Update not required when all objects in inventory are the same and
148
+ // status does not need to be updated. If status is stored, always update the
149
+ // inventory to store the latest status.
150
+ if objs .Equal (clusterObjs ) && cic .statusPolicy == StatusPolicyNone {
151
+ return pruneIds , nil
152
+ }
153
+
147
154
if dryRun .ClientOrServerDryRun () {
148
155
klog .V (4 ).Infof ("dry-run create inventory object: not created" )
149
156
return pruneIds , nil
@@ -176,13 +183,18 @@ func (cic *ClusterClient) Replace(localInv Info, objs object.ObjMetadataSet, sta
176
183
return err
177
184
}
178
185
179
- if ! objs .Equal (clusterObjs ) {
180
- klog .V (4 ).Infof ("replace cluster inventory: %s/%s" , clusterInv .GetNamespace (), clusterInv .GetName ())
181
- klog .V (4 ).Infof ("replace cluster inventory %d objects" , len (objs ))
186
+ // Update not required when all objects in inventory are the same and
187
+ // status does not need to be updated. If status is stored, always update the
188
+ // inventory to store the latest status.
189
+ if objs .Equal (clusterObjs ) && cic .statusPolicy == StatusPolicyNone {
190
+ return nil
191
+ }
182
192
183
- if err := wrappedInv .ApplyWithPrune (cic .dc , cic .mapper , cic .statusPolicy , objs ); err != nil {
184
- return fmt .Errorf ("failed to write updated inventory to cluster: %w" , err )
185
- }
193
+ klog .V (4 ).Infof ("replace cluster inventory: %s/%s" , clusterInv .GetNamespace (), clusterInv .GetName ())
194
+ klog .V (4 ).Infof ("replace cluster inventory %d objects" , len (objs ))
195
+
196
+ if err := wrappedInv .ApplyWithPrune (cic .dc , cic .mapper , cic .statusPolicy , objs ); err != nil {
197
+ return fmt .Errorf ("failed to write updated inventory to cluster: %w" , err )
186
198
}
187
199
188
200
return nil
0 commit comments