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

make deprovisioning an instance asynchronously not fall-through to synchronous deprovision #1067

Merged
merged 1 commit into from Aug 11, 2017

Conversation

Projects
None yet
6 participants
@kibbles-n-bytes
Contributor

kibbles-n-bytes commented Jul 26, 2017

No description provided.

@pmorie

Can we get a test for this?

@kibbles-n-bytes

This comment has been minimized.

Show comment
Hide comment
@kibbles-n-bytes

kibbles-n-bytes Jul 27, 2017

Contributor

@pmorie Yup, working on that now!

Contributor

kibbles-n-bytes commented Jul 27, 2017

@pmorie Yup, working on that now!

@kibbles-n-bytes

This comment has been minimized.

Show comment
Hide comment
@kibbles-n-bytes

kibbles-n-bytes Aug 1, 2017

Contributor

I made a few design choices, would like feedback as to whether they're valid.

Currently in master, asynchronously deprovisioning sets an async-only condition, and then falls back onto the regular deprovision logic, where the condition is set as successfully deprovisioned, a successful deprovision event is recorded, and the finalizer is cleared.

This seemed strange to me. The instance hasn't actually been completely prepped for K8s-side deletion, so clearing the finalizer seems wrong. And setting the InstanceConditionReady as false already occurs in the async-only step, so doing a second condition seemed odd. And I'm not entirely sure of when it's appropriate to record an event, but recording a successful deprovision event also seemed misleading. So I added a return in the async section that does none of them. Is this alright? Should we be recording a different event type here?

Contributor

kibbles-n-bytes commented Aug 1, 2017

I made a few design choices, would like feedback as to whether they're valid.

Currently in master, asynchronously deprovisioning sets an async-only condition, and then falls back onto the regular deprovision logic, where the condition is set as successfully deprovisioned, a successful deprovision event is recorded, and the finalizer is cleared.

This seemed strange to me. The instance hasn't actually been completely prepped for K8s-side deletion, so clearing the finalizer seems wrong. And setting the InstanceConditionReady as false already occurs in the async-only step, so doing a second condition seemed odd. And I'm not entirely sure of when it's appropriate to record an event, but recording a successful deprovision event also seemed misleading. So I added a return in the async section that does none of them. Is this alright? Should we be recording a different event type here?

@kibbles-n-bytes

This comment has been minimized.

Show comment
Hide comment
@kibbles-n-bytes

kibbles-n-bytes Aug 1, 2017

Contributor

It seems like async provisioning does record an event, so I'll record one for deprovisioning too.

Contributor

kibbles-n-bytes commented Aug 1, 2017

It seems like async provisioning does record an event, so I'll record one for deprovisioning too.

@kibbles-n-bytes kibbles-n-bytes changed the title from make deprovisioning an instance asynchronously add it to the polling queue to make deprovisioning an instance asynchronously not fall-through Aug 1, 2017

@kibbles-n-bytes kibbles-n-bytes changed the title from make deprovisioning an instance asynchronously not fall-through to make deprovisioning an instance asynchronously not fall-through to synchronous deprovision Aug 1, 2017

@kibbles-n-bytes

This comment has been minimized.

Show comment
Hide comment
@kibbles-n-bytes

kibbles-n-bytes Aug 1, 2017

Contributor

Since #1074 is now in, the scope of this PR changes. Now it is only preventing the asynchronous deprovision logic from falling through to the rest of the synchronous deprovision logic, and adds a test (and typo fix).

Contributor

kibbles-n-bytes commented Aug 1, 2017

Since #1074 is now in, the scope of this PR changes. Now it is only preventing the asynchronous deprovision logic from falling through to the rest of the synchronous deprovision logic, and adds a test (and typo fix).

@MHBauer

MHBauer approved these changes Aug 2, 2017

seems okay.

I am not liking this "gotta make sure we check in the right order".

LGTM

@kibbles-n-bytes

This comment has been minimized.

Show comment
Hide comment
@kibbles-n-bytes

kibbles-n-bytes Aug 2, 2017

Contributor

@MHBauer Not sure if there's a clean way around it. There's no single thing you can look at to see what should be done to reconcile the instance. We could specify the different actions to take as:

shouldPoll = instance.Status.AsyncOpInProgress
shouldDelete = !instance.Status.AsyncOpInProgress && instance.ObjectMeta.DeletionTimestamp != nil
shouldAddOrUpdate = !instance.StatusAsyncOpInProgress && instance.ObjectMeta.DeletionTimestamp == nil

But that's pretty ugly IMO. I'm planning to work on refactoring the polling queue logic anyway though, so I'll try to see if there's a better place we can place the poll/not poll logic at least. But that'll have to be in a followup.

Contributor

kibbles-n-bytes commented Aug 2, 2017

@MHBauer Not sure if there's a clean way around it. There's no single thing you can look at to see what should be done to reconcile the instance. We could specify the different actions to take as:

shouldPoll = instance.Status.AsyncOpInProgress
shouldDelete = !instance.Status.AsyncOpInProgress && instance.ObjectMeta.DeletionTimestamp != nil
shouldAddOrUpdate = !instance.StatusAsyncOpInProgress && instance.ObjectMeta.DeletionTimestamp == nil

But that's pretty ugly IMO. I'm planning to work on refactoring the polling queue logic anyway though, so I'll try to see if there's a better place we can place the poll/not poll logic at least. But that'll have to be in a followup.

@MHBauer

This comment has been minimized.

Show comment
Hide comment
@MHBauer

MHBauer Aug 2, 2017

Member

That's why I keep trying to push this state machine idea. We should know, coming in, which fork we're going down, and go down only that fork, before moving to the next state. I'm not sure if it can be done by sub parts of the condition or what. What makes the controller adjustments painful is we have to make sure to return if we enter one of these blocks, make sure to change something (or not) so we don't enter the same block the next go around, make sure sure that nothing in one block can effect any other block in the same invocation, etc. Maybe extracting will fix it. I don't know.

Member

MHBauer commented Aug 2, 2017

That's why I keep trying to push this state machine idea. We should know, coming in, which fork we're going down, and go down only that fork, before moving to the next state. I'm not sure if it can be done by sub parts of the condition or what. What makes the controller adjustments painful is we have to make sure to return if we enter one of these blocks, make sure to change something (or not) so we don't enter the same block the next go around, make sure sure that nothing in one block can effect any other block in the same invocation, etc. Maybe extracting will fix it. I don't know.

@pmorie

One nit - what do you think?

@@ -354,22 +358,21 @@ func (c *controller) reconcileInstance(instance *v1alpha1.Instance) error {
glog.V(4).Infof("Processing Instance %v/%v", instance.Namespace, instance.Name)
// if the instance is marked for deletion, handle that first.
if instance.Status.AsyncOpInProgress {

This comment has been minimized.

@pmorie

pmorie Aug 3, 2017

Member

if you move this up to L328, we can remove a level of nesting in the checksum check

@pmorie

pmorie Aug 3, 2017

Member

if you move this up to L328, we can remove a level of nesting in the checksum check

This comment has been minimized.

@kibbles-n-bytes

kibbles-n-bytes Aug 3, 2017

Contributor

Ah yeah, good catch!

@kibbles-n-bytes

kibbles-n-bytes Aug 3, 2017

Contributor

Ah yeah, good catch!

@kibbles-n-bytes

This comment has been minimized.

Show comment
Hide comment
@kibbles-n-bytes

kibbles-n-bytes Aug 7, 2017

Contributor

@MHBauer Can you write up an issue describing a bit of what your state machine concept would look like? I'm curious and would like to wrap my head around it, so if you're serious about it I'd like to get the ball rolling so we can discuss pros/cons/implementation/etc.

Contributor

kibbles-n-bytes commented Aug 7, 2017

@MHBauer Can you write up an issue describing a bit of what your state machine concept would look like? I'm curious and would like to wrap my head around it, so if you're serious about it I'd like to get the ball rolling so we can discuss pros/cons/implementation/etc.

@MHBauer MHBauer added the LGTM1 label Aug 9, 2017

@kibbles-n-bytes

This comment has been minimized.

Show comment
Hide comment
@kibbles-n-bytes

kibbles-n-bytes Aug 11, 2017

Contributor

FYI @ALL: @pmorie gave me a verbal LGTM to this PR, but said because he was on a plane about to take off, he wasn't able to add the badge and merge on GitHub. I'm going to go ahead and do so as a proxy.

Contributor

kibbles-n-bytes commented Aug 11, 2017

FYI @ALL: @pmorie gave me a verbal LGTM to this PR, but said because he was on a plane about to take off, he wasn't able to add the badge and merge on GitHub. I'm going to go ahead and do so as a proxy.

@kibbles-n-bytes kibbles-n-bytes merged commit 8411f31 into kubernetes-incubator:master Aug 11, 2017

3 checks passed

cla/linuxfoundation kibbles-n-bytes authorized
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
service-catalog-PR-testing2 Successful presubmits. Details at https://service-catalog-jenkins.appspot.com/job/service-catalog-PR-testing2/1775/.
Details

@kibbles-n-bytes kibbles-n-bytes deleted the kibbles-n-bytes:async-fix branch Aug 11, 2017

@nilebox

This comment has been minimized.

Show comment
Hide comment
@nilebox

nilebox Aug 21, 2017

Member

@kibbles-n-bytes just found this bug myself, and was happy to find that it has already been fixed in the latest release :) 👍

Member

nilebox commented Aug 21, 2017

@kibbles-n-bytes just found this bug myself, and was happy to find that it has already been fixed in the latest release :) 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment