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

Add CreateAnew function #185

Merged
merged 1 commit into from
Feb 23, 2021
Merged

Conversation

tpantelis
Copy link
Contributor

For use cases where an existing instance needs to first be deleted.

Also added unit tests for the new function and the existing CreateOrUpdate function.

return err
}

return retry.OnError(backOff, apierrors.IsAlreadyExists, func() error {
Copy link
Member

Choose a reason for hiding this comment

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

Is there any point in retrying if Create() returns an error other than “already exists”?

Copy link
Member

Choose a reason for hiding this comment

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

OK, for anyone else following along, @tpantelis pointed out to me that the function is only retried if the error is accepted by the function given as the second argument to OnError, i.e. IsAlreadyExists.

Copy link
Contributor Author

@tpantelis tpantelis Feb 23, 2021

Choose a reason for hiding this comment

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

I refactored it to use wait.ExponentialBackoff directly as OnError doesn't really add value.

For use cases where an existing instance needs to first be deleted.

Also added unit tests for the new function and the existing CreateOrUpdate
function.

Signed-off-by: Tom Pantelis <tompantelis@gmail.com>
@tpantelis tpantelis merged commit 06e40f4 into submariner-io:devel Feb 23, 2021
@tpantelis tpantelis deleted the create_anew branch May 6, 2022 13:40
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.

2 participants