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

Handle race where offer is already destroyed #446

Conversation

jack-w-shaw
Copy link
Member

Description

If an offer has already been destroyed, 'DestroyOffer' will fail with a 'not found' error. In this case, there is no offer to destroy, so we should just return successfully.

This race is rare, but has been seen here:
https://github.com/juju/juju/actions/runs/7745564317/job/21121856659?pr=16883

Fixes: #395

Type of change

  • Change existing resource
  • Logic changes in resources (the API interaction with Juju has been changed)
  • Bug fix (non-breaking change which fixes an issue)
  • Maintenance work (repository related, like Github actions, or revving the Go version, etc.)

Environment

  • Juju controller version: I'm using 3.4, since the bug this addresses was seen in 3.4

  • Terraform version: 1.7.5

QA steps

TF_ACC="1" TEST_CLOUD="lxd" go test -count=10 -timeout 60m ./internal/provider/ -run TestAcc_ResourceIntegrationWithMultipleConsumers

If an offer has already been destroyed, 'DestroyOffer' will fail with
a 'not found' error. In this case, there is no offer to destroy, so we
should just return successfully.

This race is rare, but has been seen here:
https://github.com/juju/juju/actions/runs/7745564317/job/21121856659?pr=16883
@hmlanigan hmlanigan self-requested a review April 10, 2024 14:07
@hmlanigan hmlanigan added this to the 0.12.0 milestone Apr 10, 2024
Copy link
Member

@hmlanigan hmlanigan left a comment

Choose a reason for hiding this comment

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

This is an intermittent failure, more concrete QA steps are necessary.

@@ -192,6 +193,10 @@ func (c offersClient) DestroyOffer(input *DestroyOfferInput) error {

client := applicationoffers.NewClient(conn)
offer, err := client.ApplicationOffer(input.OfferURL)
if jujuerrors.Is(err, jujuerrors.NotFound) {
Copy link
Member

Choose a reason for hiding this comment

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

We don't get actual types out of the juju clients usually. Check out some of the other NotFound code.

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.

On delete we should handle not found as already destroyed if we can
3 participants