@@ -144,6 +144,13 @@ func (cic *ClusterClient) Merge(localInv Info, objs object.ObjMetadataSet, dryRu
144144		return  pruneIds , err 
145145	}
146146
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+ 
147154	if  dryRun .ClientOrServerDryRun () {
148155		klog .V (4 ).Infof ("dry-run create inventory object: not created" )
149156		return  pruneIds , nil 
@@ -176,13 +183,18 @@ func (cic *ClusterClient) Replace(localInv Info, objs object.ObjMetadataSet, sta
176183		return  err 
177184	}
178185
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+ 	}
182192
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 )
186198	}
187199
188200	return  nil 
0 commit comments