-
Notifications
You must be signed in to change notification settings - Fork 382
Checking for returned errors when updating conditions & finalizers #929
Conversation
This is a work in progress. More changes and (likely) some tests to come |
); err != nil { | ||
glog.Errorf("updating binding condition (%s)", err) | ||
return err | ||
} | ||
c.recorder.Event(binding, api.EventTypeWarning, errorWithOngoingAsyncOperation, s) |
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.
do we want to put these events above the binding updates? we'll skip them now.
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.
@MHBauer I left them where they were before. I think it's the right behavior to not emit an event if the update failed, because the state didn't change. Thoughts?
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.
What causes updating the condition in status to fail?
What happens after? Do we try to reconcile again? Eventually it succeeds?
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.
What causes updating the condition in status to fail?
Broken pipe, API server goes down, etc
What happens after? Do we try to reconcile again? Eventually it succeeds?
We periodically re-reconcile everything, yeah. Eventually it succeeds.
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.
I don't understand what's going on enough to lgtm or not.
Overall it seems dangerous somehow. Everything has worked, but we're going to bail at the last second in a bunch of cases because we can't update status. We also don't roll back anything we did. We're not going to end up in an error state on the server, just some weird intermediate one.
I think I'm missing some knowledge.
c.recorder.Event(binding, api.EventTypeWarning, errorInjectingBindResultReason, s) | ||
return err | ||
} | ||
c.updateBindingCondition( | ||
if err := c.updateBindingCondition( |
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.
I'm finding this style here to be harder to read than (IMHO) simpler:
err := c.update...
if err != nil {
But, if others are fine with this style, then so be it :)
// Clear the finalizer | ||
finalizers.Delete(v1alpha1.FinalizerServiceCatalog) | ||
c.updateBindingFinalizers(binding, finalizers.List()) | ||
if err := c.updateBindingFinalizers(binding, finalizers.List()); err != nil { |
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.
So for example here, I think this is more readable using this format because things can fit in a single line :)
binding, | ||
v1alpha1.BindingConditionReady, | ||
v1alpha1.ConditionFalse, | ||
errorWithOngoingAsyncOperation, | ||
errorWithOngoingAsyncOperationMessage, | ||
) | ||
); err != nil { | ||
glog.Errorf("updating binding condition (%s)", err) |
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.
Should we be creating an error event in these failure cases?
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.
I mean error about the update condition failing?
); err != nil { | ||
glog.Errorf("updating binding condition (%s)", err) | ||
return err | ||
} | ||
c.recorder.Event(binding, api.EventTypeWarning, errorWithOngoingAsyncOperation, s) |
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.
What causes updating the condition in status to fail?
Broken pipe, API server goes down, etc
What happens after? Do we try to reconcile again? Eventually it succeeds?
We periodically re-reconcile everything, yeah. Eventually it succeeds.
binding, | ||
v1alpha1.BindingConditionReady, | ||
v1alpha1.ConditionFalse, | ||
errorWithParameters, | ||
"Error unmarshaling binding parameters. "+s, | ||
) | ||
); err != nil { | ||
glog.Errorf("updating binding condition (%s)", err) |
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.
I would prefer to include the text "Error" in the message, even though I am fully aware that the log level says it's an error.
) | ||
|
||
// bindingTestCase represents a single row of a table driven test for reconciling bindings | ||
type reconcileBindingTestCase struct { |
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.
strongly prefer for this to be defined where it is used
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.
Why is this a separate file?
binding, | ||
v1alpha1.BindingConditionReady, | ||
v1alpha1.ConditionFalse, | ||
errorBindCallReason, | ||
"Bind call failed. "+s) | ||
"Bind call failed. "+s, | ||
); err != nil { |
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.
note to self, feel free to read and confirm cases : binding creation failed, can't update condition to say binding failed. next time through loop will try to create binding again.
binding, | ||
v1alpha1.BindingConditionReady, | ||
v1alpha1.ConditionTrue, | ||
successInjectedBindResultReason, | ||
successInjectedBindResultMessage, | ||
) | ||
); err != nil { | ||
glog.Errorf("updating binding condition (%s)", err) |
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.
binding successfully injected, next time through the loop we will try to create and inject a fresh binding?
This seems off to me.
binding, | ||
v1alpha1.BindingConditionReady, | ||
v1alpha1.ConditionUnknown, | ||
errorEjectingBindReason, | ||
errorEjectingBindMessage+s, | ||
) | ||
); err != nil { | ||
glog.Errorf("updating binding condition (%s)", err) |
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.
if we fail below, do we come back through here and fail to eject the binding? (as it is already ejected?)
How does ConditionUnknown play into this?
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.
Have any of us drawn up a state diagram to show transitions of the conditions between true and false and unknown?
I think some of my concerns are with return statements everywhere which make it difficult to track.
@arschles build failure:
|
Also a non-lint error:
|
I am going to say this can be closed or needs to be re-written. |
Closing since this is obviously stale. |
This patch adds error checks to all
update{Broker,Binding,Instance}Condition
calls in the controller, along with tests to ensure that the errors are properly handled.Fixes #925