Fix non-operation update block status reflect issue

Signed-off-by: RainbowMango <renhongcai@huawei.com>
This commit is contained in:
RainbowMango 2021-03-25 18:09:16 +08:00 committed by Hongcai Ren
parent 65a4f32e3e
commit 4696f7800d
1 changed files with 11 additions and 1 deletions

View File

@ -175,7 +175,17 @@ func (c *WorkStatusController) syncWorkStatus(key util.QueueKey) error {
} }
if needUpdate { 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) klog.Infof("reflecting %s(%s/%s) status to Work(%s/%s)", obj.GetKind(), obj.GetNamespace(), obj.GetName(), workNamespace, workName)