Skip to content

Commit

Permalink
Ensure CreateApplication only waits on NotFound and AlreadyExists
Browse files Browse the repository at this point in the history
We were not failing quickly on deployment errors such as trying to
deploy a subordinate with a unit.
  • Loading branch information
hmlanigan committed Oct 25, 2023
1 parent fd26ff0 commit 9ac9853
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions internal/juju/applications.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,14 @@ func (c applicationsClient) CreateApplication(ctx context.Context, input *Create
}
return nil
},
IsFatalError: func(err error) bool {
// If we hit AlreadyExists, it is from Deploy only under 2
// scenarios:
// 1. User error, the application has already been created?
// 2. We're replacing the application and tear down hasn't
// finished yet, we should try again.
return !errors.Is(err, jujuerrors.NotFound) && !errors.Is(err, jujuerrors.AlreadyExists)
},
NotifyFunc: func(err error, attempt int) {
c.Errorf(err, fmt.Sprintf("deploy application %q retry", appName))
message := fmt.Sprintf("waiting for application %q deploy, attempt %d", appName, attempt)
Expand Down

0 comments on commit 9ac9853

Please sign in to comment.