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

Bug 1533425 - protect against simultaneous updates #898

Merged
merged 3 commits into from Apr 25, 2018
Merged

Conversation

jmrodri
Copy link
Contributor

@jmrodri jmrodri commented Apr 19, 2018

protect against simultaneous updates

Simultaneous calls to SetState or SetBindingInstance would fail with an already exists error instead of graciously updating the existing instances.

Also, the broker.Bind was incorrectly trying to set the state of a binding job using the instance id as the key, vs use bindingid for state in bindings

@jmrodri jmrodri requested a review from eriknelson April 19, 2018 17:57
@openshift-ci-robot openshift-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Apr 19, 2018
Simultaneous calls to SetState or SetBindingInstance would fail with an
already exists error instead of graciously updating the existing
instances.

Also, the broker.Bind was incorrectly trying to set the state of a
binding job using the instance id as the key, vs
use bindingid for state in bindings
@jmrodri jmrodri changed the title Protect against simultaneous updates Bug 1533425 - protect against simultaneous updates Apr 19, 2018
// looks like we already have this state, probably created by
// another goroutine. Let's try to update the existing one instead.
if js, err := d.client.JobStates(d.namespace).Get(state.Token, metav1.GetOptions{}); err == nil {
js.Spec = j
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be in a helper function?

}); err != nil {
log.Errorf("failed to set initial jobstate for %v, %v", token, err.Error())
}
// if _, err := a.dao.SetState(bindInstance.ID.String(), apb.JobState{
Copy link
Contributor

Choose a reason for hiding this comment

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

Just my opinion but if the code is not running can we delete it?

We can also go back in history with git and re-add it back?

@jmrodri
Copy link
Contributor Author

jmrodri commented Apr 25, 2018

@shawn-hurley refactored update code into a method. Let me know.

Copy link
Contributor

@shawn-hurley shawn-hurley left a comment

Choose a reason for hiding this comment

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

LGTM

@jmrodri jmrodri merged commit a6049d6 into master Apr 25, 2018
@jmrodri jmrodri deleted the fix_binding_state branch May 4, 2018 03:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants