Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify instance update code #1378

Merged
merged 6 commits into from
Mar 4, 2020
Merged

Simplify instance update code #1378

merged 6 commits into from
Mar 4, 2020

Conversation

zen-dog
Copy link
Contributor

@zen-dog zen-dog commented Mar 2, 2020

Summary:
we save one Update call in the instance_controller.go::updateInstance method by removing the finalizer before updating the instance. To avoid misleading log messages, the subsequent updating of the status is handling the fact that the instance might be removed.

Signed-off-by: Aleksey Dukhovniy alex.dukhovniy@googlemail.com

Summary:
we save one `Update` call in the `instance_controller.go::updateInstance` method by removing the finalizer *before* updating the instance. To avoid misleading log messages, the subsequent updating of the status is handling the fact that the instance might be removed.

Signed-off-by: Aleksey Dukhovniy <alex.dukhovniy@googlemail.com>
Copy link
Member

@kensipe kensipe left a comment

Choose a reason for hiding this comment

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

minor nit / question...

/lgtm

there is an e2e test failing

// update instance spec and metadata. this will not update Instance.Status field
// The order of both updates below is important: *first* the instance Spec and Metadata and *then* the Status.
// If Status is update first, a new reconcile request will be scheduled with *WRONG* instance snapshot (which is
// saved in the annotations). This request will then have wrong "previous state".
Copy link
Member

Choose a reason for hiding this comment

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

👏 thanks for the docs and order procedures below!

instanceStatus := instance.Status.DeepCopy()

if tryRemoveFinalizer(instance) {
log.Printf("InstanceController: Removing finalizer on instance %s/%s", instance.Namespace, instance.Name)
Copy link
Member

Choose a reason for hiding this comment

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

why is this not in the tryRemoveFinalizer? seems if this is valuable and used other places that we would want to know for all cases... what is logged is provided to the function.

Copy link
Member

Choose a reason for hiding this comment

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

Good point, it's now there. That also allows us to distinguish the reasons why the finalizer was removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, #1352 moves this method (and it's adding-counterpart) into the helpers because they are not used by the webhook too. Now, log.Printf("InstanceController:... would be a lie. I think it is important to know who removed the finalizer so I kept it in the calling method. We could provide some logging prefix, of course, but that seems like overkill.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

On the other hand, I like the distinction between cleanup plan is finished and there is no cleanup plan. Ok, let's leave it like this.

Copy link
Member

@ANeumann82 ANeumann82 left a comment

Choose a reason for hiding this comment

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

lgtm

zen-dog and others added 5 commits March 3, 2020 11:39
Signed-off-by: Aleksey Dukhovniy <alex.dukhovniy@googlemail.com>
Signed-off-by: Aleksey Dukhovniy <alex.dukhovniy@googlemail.com>
Signed-off-by: Andreas Neumann <aneumann@mesosphere.com>
Signed-off-by: Andreas Neumann <aneumann@mesosphere.com>
Signed-off-by: Aleksey Dukhovniy <alex.dukhovniy@googlemail.com>
@zen-dog zen-dog merged commit f726968 into master Mar 4, 2020
@zen-dog zen-dog deleted the ad/simplify-instance-update branch March 4, 2020 13:48
runyontr pushed a commit that referenced this pull request Mar 11, 2020
Summary:
we save one `Update` call in the `instance_controller.go::updateInstance` method by removing the finalizer *before* updating the instance. To avoid misleading log messages, the subsequent updating of the status is handling the fact that the instance might be removed.

Signed-off-by: Aleksey Dukhovniy <alex.dukhovniy@googlemail.com>

Co-authored-by: Andreas Neumann <aneumann@mesosphere.com>
Signed-off-by: Thomas Runyon <runyontr@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants