Skip to content

Support retries on conflicting image stream mapping create attempts - #5455

Merged
openshift-bot merged 2 commits into
openshift:masterfrom
ironcladlou:istmapping-create-retries
Oct 29, 2015
Merged

openshift-bot merged 2 commits into
openshift:masterfrom
ironcladlou:istmapping-create-retries

Conversation

@ironcladlou

Copy link
Copy Markdown
Contributor

Add retry support to mapping creation to allow repeated update attempts
when the conflicting resource doesn't contain any tag diffs.

Fixes #5421

@ironcladlou
ironcladlou force-pushed the istmapping-create-retries branch 3 times, most recently from 5739cbd to 8e95bec Compare October 28, 2015 18:00
@ironcladlou ironcladlou changed the title WIP: support retries on ISTM create Support retries on conflicting image stream mapping create attempts Oct 28, 2015
@ironcladlou
ironcladlou force-pushed the istmapping-create-retries branch from 8e95bec to d58e64f Compare October 28, 2015 18:03
@ironcladlou

Copy link
Copy Markdown
Contributor Author

@deads2k @smarterclayton @ncdc PTAL.

@ironcladlou

Copy link
Copy Markdown
Contributor Author

[test]

@openshift-bot

Copy link
Copy Markdown
Contributor

@deads2k

deads2k commented Oct 28, 2015

Copy link
Copy Markdown
Contributor

Little bit of plumbing for that test, eh?

lgtm

@ironcladlou

Copy link
Copy Markdown
Contributor Author

Little bit of plumbing for that test, eh?

😩

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If you have this then there is no point to having RetryOnConflic.t... which is supposed t handle conflict errors.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not sure I understand. If the error is not a conflict error, return early and pass that on to the client (i.e. no retry). If it is a conflict, do a deeper inspection to decide whether to allow the helper to deal with the conflict (i.e. retry).

@smarterclayton

Copy link
Copy Markdown
Contributor

Hold on LGTM

@smarterclayton

Copy link
Copy Markdown
Contributor

Not using RetryOnConflict correctly.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All of this code should be at the beginning of the loop - guarded by "don't do this on the first loop".

Before the call to RetryOnConflict, set the last stream tag. At the beginning of the loop, check whether stream == nil. Then check whether old tag == new tag. If they don't, then exit. Do the mutation. If you get any error, clear stream (so the next iteration of the loop reads it again).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If you want to terminate early, return a known error type that you convert to conflict on the outside.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If you get any error, clear stream (so the next iteration of the loop reads it again).

This code relies on not resetting the stream unless it finds there isn't a real conflict. That logic ensures that it never re-attempts this work without an imagestream with a resourceversion that is known to be consistent with the first one we grabbed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Using a custom error type makes sense to clean up that little mess, but I'm still trying to understand what's being proposed for the rest of the refactor. I don't really see how what I have is wrong.

Add retry support to mapping creation to allow repeated update attempts
when the conflicting resource doesn't contain any tag diffs.
@ironcladlou
ironcladlou force-pushed the istmapping-create-retries branch from d58e64f to 74190e7 Compare October 28, 2015 18:27
@deads2k

deads2k commented Oct 28, 2015

Copy link
Copy Markdown
Contributor

Not using RetryOnConflict correctly.

I find the current code easier to inspect that the changes needed for RetryOnConflict. Maybe just not use that construct?

@ironcladlou

Copy link
Copy Markdown
Contributor Author

I don't think the conflict-based aspect of the retry helper is buying us anything in this case since we have to micromanage the conflict error type ourselves (while the helper wants to assume that all conflicts mean "retry").

What would be more appropriate IMO is a generic retry/backoff helper that lets me return a bool indicating whether or not to retry (sort of like wait.Poll).

@smarterclayton

Copy link
Copy Markdown
Contributor

If you don't like RetryOnConflict, this isn't the time to change it, but if
it's not solving the problem then it needs to be changed.

This code, as written, isn't really using RetryOnConflict the way its
intended to be used.

On Wed, Oct 28, 2015 at 2:38 PM, David Eads [email protected]
wrote:

Not using RetryOnConflict correctly.

I find the current code easier to inspect that the changes needed for
RetryOnConflict. Maybe just not use that construct?

—
Reply to this email directly or view it on GitHub
#5455 (comment).

@smarterclayton

Copy link
Copy Markdown
Contributor

You can use wait.ExponentialBackoff and pass the same arguments, but you'll
get your early exit.

On Wed, Oct 28, 2015 at 2:44 PM, Clayton Coleman [email protected]
wrote:

If you don't like RetryOnConflict, this isn't the time to change it, but
if it's not solving the problem then it needs to be changed.

This code, as written, isn't really using RetryOnConflict the way its
intended to be used.

On Wed, Oct 28, 2015 at 2:38 PM, David Eads [email protected]
wrote:

Not using RetryOnConflict correctly.

I find the current code easier to inspect that the changes needed for
RetryOnConflict. Maybe just not use that construct?

—
Reply to this email directly or view it on GitHub
#5455 (comment).

@ironcladlou

Copy link
Copy Markdown
Contributor Author

Refactored to use wait.ExponentialBackoff; looks much cleaner in this case IMO.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

false, err, right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not sure that it matters- ExponentialBackoff will return due to err != nil. Technically we're also "done" at this point...

@ironcladlou
ironcladlou force-pushed the istmapping-create-retries branch from af13dc6 to 0ef34a0 Compare October 28, 2015 20:16
@soltysh

soltysh commented Oct 28, 2015

Copy link
Copy Markdown
Contributor

I was recently faced with similar problem and tried to stay away from modifying the storage layer, but rather was inclined to that in the client code which should support situations as such. My reasoning was the storage should be as simple as possible, without any retry logic. Although code looks good, I'm not too happy with this change. I'm afraid it might hide some bigger problems...

@liggitt

liggitt commented Oct 28, 2015

Copy link
Copy Markdown
Contributor

Retry for conflict on create is weird... we shouldn't make clients do that. Retry for conflict on update is fine for clients to have to handle, I think

@soltysh

soltysh commented Oct 28, 2015

Copy link
Copy Markdown
Contributor

The root cause of this issue is we're trying to create ISM and update IS status at one shot, which ends up with those failures. Maybe in that case we should rather fix in UpdateImageStreamStatus and not here?

@soltysh

soltysh commented Oct 28, 2015

Copy link
Copy Markdown
Contributor

Whereas most, if not all (except for this one and I think I know other one), of our storage are dealing with single object. Wherever more than one come into play, problems occur.

@smarterclayton

Copy link
Copy Markdown
Contributor

This is an idempotent API operation (add mapping). So retry at the server is appropriate.

@soltysh

soltysh commented Oct 28, 2015

Copy link
Copy Markdown
Contributor

@smarterclayton

Copy link
Copy Markdown
Contributor

LGTM [merge]

@openshift-bot

Copy link
Copy Markdown
Contributor

continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pull_requests_origin/6330/) (Image: devenv-rhel7_2587)

@openshift-bot

Copy link
Copy Markdown
Contributor

Evaluated for origin merge up to 0ef34a0

@openshift-bot

Copy link
Copy Markdown
Contributor

Evaluated for origin test up to 0ef34a0

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.

6 participants