Skip to content
This repository has been archived by the owner on Jul 22, 2022. It is now read-only.

Add status as part of DecoratorController hook response #114

Merged
merged 6 commits into from
Oct 31, 2018

Conversation

lionelvillard
Copy link
Contributor

In order to be consistent with CompositeController the status returned by the hook replaces the existing one

Copy link

@enisoc enisoc left a 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.

controller/decorator/controller.go Show resolved Hide resolved
(syncResult.Finalized && dynamicobject.HasFinalizer(parent, c.finalizer.Name)) {
updatedParent.SetLabels(parentLabels)
updatedParent.SetAnnotations(parentAnnotations)
k8s.SetNestedField(updatedParent.Object, syncResult.Status, "status")
Copy link

@enisoc enisoc Oct 30, 2018

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:

Suggested change
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())
}

Copy link
Contributor Author

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.

Copy link

@enisoc enisoc Oct 31, 2018

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.

docs/_api/decoratorcontroller.md Outdated Show resolved Hide resolved
docs/_api/decoratorcontroller.md Outdated Show resolved Hide resolved
docs/_api/decoratorcontroller.md Outdated Show resolved Hide resolved
enisoc and others added 5 commits October 30, 2018 19:53
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>
@lionelvillard
Copy link
Contributor Author

lionelvillard commented Oct 31, 2018

@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)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
result, err = parentClient.Namespace(parent.GetNamespace()).UpdateStatus(updatedParent)
result, err := parentClient.Namespace(parent.GetNamespace()).UpdateStatus(updatedParent)

@enisoc enisoc merged commit 1f30ddf into GoogleCloudPlatform:master Oct 31, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants