Skip to content

Commit

Permalink
Fix non-operation update block status reflect issue
Browse files Browse the repository at this point in the history
Signed-off-by: RainbowMango <[email protected]>
  • Loading branch information
RainbowMango committed Mar 25, 2021
1 parent 65a4f32 commit 4696f78
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion pkg/controllers/status/workstatus_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,17 @@ func (c *WorkStatusController) syncWorkStatus(key util.QueueKey) error {
}

if needUpdate {
return c.ObjectWatcher.Update(cluster, desireObj, obj)
if err := c.ObjectWatcher.Update(cluster, desireObj, obj); err != nil {
klog.Errorf("Update %s failed: %v", keyStr, err)
return err
}
// We can't return even after a success updates, because that might lose the chance to collect status.
// Not all updates are real, they might be no change, in that case there will be no more event for this update,
// this usually happens with those resources not enables 'metadata.generation', like 'Service'.
// When a Service's status changes, it's 'metadata.resourceVersion' will be increased, but 'metadata.generation'
// not increased(defaults to 0), the ObjectWatcher can't easily tell what happened to the object, so ObjectWatcher
// also needs to update again. The update operation will be a non-operation if the event triggered by Service's
// status changes.
}

klog.Infof("reflecting %s(%s/%s) status to Work(%s/%s)", obj.GetKind(), obj.GetNamespace(), obj.GetName(), workNamespace, workName)
Expand Down

0 comments on commit 4696f78

Please sign in to comment.