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

fix - remove force destroy of application offers. #651

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions internal/juju/offers.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,16 +195,17 @@ func (c offersClient) DestroyOffer(input *DestroyOfferInput) error {
return err
}

forceDestroy := false
//This code loops until it detects 0 connections in the offer or 3 minutes elapses
//This code loops until it detects 0 connections in the offer or 5 minutes elapses
if len(offer.Connections) > 0 {
end := time.Now().Add(5 * time.Minute)
for ok := true; ok; ok = len(offer.Connections) > 0 {
//if we have been failing to destroy offer for 5 minutes then force destroy
//TODO: investigate cleaner solution (acceptance tests fail even if timeout set to 20m)
//if we have been failing to destroy offer for 5 minutes then fail on destroy
if time.Now().After(end) {
forceDestroy = true
break
connections := make([]string, len(offer.Connections))
for i, connection := range offer.Connections {
connections[i] = fmt.Sprintf("%s:%s", connection.SourceModelUUID, connection.Endpoint)
}
return fmt.Errorf("offer %q has remaining integrations: %s", input.OfferURL, strings.Join(connections, ", "))
}
time.Sleep(10 * time.Second)
offer, err = client.ApplicationOffer(input.OfferURL)
Expand All @@ -214,7 +215,7 @@ func (c offersClient) DestroyOffer(input *DestroyOfferInput) error {
}
}

err = client.DestroyOffers(forceDestroy, input.OfferURL)
err = client.DestroyOffers(false, input.OfferURL)
if err != nil {
return err
}
Expand Down
6 changes: 6 additions & 0 deletions internal/provider/resource_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ resource "juju_integration" "a" {
application {
offer_url = juju_offer.b.url
}

depends_on = [juju_offer.b]
}
`, srcModelName, aOS, dstModelName, bOS, viaCIDRs)
}
Expand Down Expand Up @@ -315,6 +317,8 @@ resource "juju_integration" "b1" {
application {
offer_url = juju_offer.a.url
}

depends_on = [juju_offer.a]
}

resource "juju_application" "b2" {
Expand All @@ -339,6 +343,8 @@ resource "juju_integration" "b2" {
application {
offer_url = juju_offer.a.url
}

depends_on = [juju_offer.a]
}

variable "enable-b1-consumer" {
Expand Down
2 changes: 2 additions & 0 deletions internal/provider/resource_offer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ resource "juju_integration" "int" {
application {
offer_url = juju_offer.offerone.url
}

depends_on = [juju_offer.offerone]
}
`, srcModelName, destModelName)
}
Expand Down
Loading