@@ -144,7 +144,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, req controllerruntime.Reques
144144
145145 workUpdated := false
146146 overrideSucceeded := false
147- // list all the corresponding works
147+ // list all the correspo/nding works
148148 works , syncErr := r .listAllWorksAssociated (ctx , & resourceBinding )
149149 if syncErr == nil {
150150 // generate and apply the workUpdated works if we have all the works
@@ -1530,16 +1530,30 @@ func (r *Reconciler) SetupWithManager(mgr controllerruntime.Manager) error {
15301530 newResourceSnapshot := newWork .Labels [fleetv1beta1 .ParentResourceSnapshotIndexLabel ]
15311531 if oldResourceSnapshot == "" || newResourceSnapshot == "" {
15321532 klog .ErrorS (controller .NewUnexpectedBehaviorError (errors .New ("found an invalid work without parent-resource-snapshot-index" )),
1533- "Could not find the parent resource snapshot index label" , "oldWork" , klog .KObj (oldWork ), "oldResourceSnapshotLabelValue " , oldResourceSnapshot ,
1534- "newWork" , klog .KObj (newWork ), "newResourceSnapshotLabelValue " , newResourceSnapshot )
1533+ "Could not find the parent resource snapshot index label" , "oldWork" , klog .KObj (oldWork ), "oldWorkLabels " , oldWork . Labels ,
1534+ "newWork" , klog .KObj (newWork ), "newWorkLabels " , newWork . Labels )
15351535 return
15361536 }
1537- // There is an edge case that, the work spec is the same but from different resourceSnapshots.
1538- // WorkGenerator will update the work because of the label changes, but the generation is the same.
1537+ oldClusterResourceOverrideSnapshotHash := oldWork .Annotations [fleetv1beta1 .ParentClusterResourceOverrideSnapshotHashAnnotation ]
1538+ newClusterResourceOverrideSnapshotHash := newWork .Annotations [fleetv1beta1 .ParentClusterResourceOverrideSnapshotHashAnnotation ]
1539+ oldResourceOverrideSnapshotHash := oldWork .Annotations [fleetv1beta1 .ParentResourceOverrideSnapshotHashAnnotation ]
1540+ newResourceOverrideSnapshotHash := newWork .Annotations [fleetv1beta1 .ParentResourceOverrideSnapshotHashAnnotation ]
1541+ if oldClusterResourceOverrideSnapshotHash == "" || newClusterResourceOverrideSnapshotHash == "" ||
1542+ oldResourceOverrideSnapshotHash == "" || newResourceOverrideSnapshotHash == "" {
1543+ klog .ErrorS (controller .NewUnexpectedBehaviorError (errors .New ("found an invalid work without override-snapshot-hash" )),
1544+ "Could not find the override-snapshot-hash annotation" , "oldWork" , klog .KObj (oldWork ), "oldWorkAnnotations" , oldWork .Annotations ,
1545+ "newWork" , klog .KObj (newWork ), "newWorkAnnotations" , newWork .Annotations )
1546+ return
1547+ }
1548+
1549+ // There is an edge case that, the work spec is the same but from different resourceSnapshots or resourceOverrideSnapshots.
1550+ // WorkGenerator will update the work because of the label/annotation changes, but the generation is the same.
15391551 // When the normal update happens, the controller will set the applied condition as false and wait
15401552 // until the work condition has been changed.
15411553 // In this edge case, we need to requeue the binding to update the binding status.
1542- if oldResourceSnapshot == newResourceSnapshot {
1554+ if oldResourceSnapshot == newResourceSnapshot &&
1555+ oldClusterResourceOverrideSnapshotHash == newClusterResourceOverrideSnapshotHash &&
1556+ oldResourceOverrideSnapshotHash == newResourceOverrideSnapshotHash {
15431557 klog .V (2 ).InfoS ("The work applied or available condition stayed as true, no need to reconcile" , "oldWork" , klog .KObj (oldWork ), "newWork" , klog .KObj (newWork ))
15441558 return
15451559 }
0 commit comments