-
Notifications
You must be signed in to change notification settings - Fork 103
Add status as part of DecoratorController hook response #114
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks pretty good! Just a few suggested changes.
(syncResult.Finalized && dynamicobject.HasFinalizer(parent, c.finalizer.Name)) { | ||
updatedParent.SetLabels(parentLabels) | ||
updatedParent.SetAnnotations(parentAnnotations) | ||
k8s.SetNestedField(updatedParent.Object, syncResult.Status, "status") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that we support /status subresource, we need to call UpdateStatus separately if /status is enabled on a given resource. The regular Update call will ignore changes to .status on the server-side in that case.
I think we need something like this:
k8s.SetNestedField(updatedParent.Object, syncResult.Status, "status") | |
k8s.SetNestedField(updatedParent.Object, syncResult.Status, "status") | |
if statusChanged && parentClient.HasSubresource("status") { | |
// The regular Update below will ignore changes to .status so we do it separately. | |
result, err := parentClient.Namespace(parent.GetNamespace()).UpdateStatus(updatedParent) | |
if err != nil { | |
return fmt.Errorf("can't update status: %v", err) | |
} | |
// The Update below needs to use the latest ResourceVersion. | |
updatedParent.SetResourceVersion(result.GetResourceVersion()) | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a typo: result, err := ...
. Not sure if I can edit it directly in github.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah good catch. I'll fix that in a new suggested change. I think you just did a code review of my code review... This is a strange new world we live in.
Co-Authored-By: lionelvillard <villard@us.ibm.com>
Co-Authored-By: lionelvillard <villard@us.ibm.com>
Co-Authored-By: lionelvillard <villard@us.ibm.com>
Co-Authored-By: lionelvillard <villard@us.ibm.com>
Co-Authored-By: lionelvillard <villard@us.ibm.com>
@enisoc it should be good now. Thanks for the fixes! |
|
||
if statusChanged && parentClient.HasSubresource("status") { | ||
// The regular Update below will ignore changes to .status so we do it separately. | ||
result, err = parentClient.Namespace(parent.GetNamespace()).UpdateStatus(updatedParent) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
result, err = parentClient.Namespace(parent.GetNamespace()).UpdateStatus(updatedParent) | |
result, err := parentClient.Namespace(parent.GetNamespace()).UpdateStatus(updatedParent) |
In order to be consistent with CompositeController the status returned by the hook replaces the existing one