From 9ac9853543d32fef8d169690d8b2924240a2887b Mon Sep 17 00:00:00 2001 From: Heather Lanigan Date: Wed, 25 Oct 2023 15:56:44 -0400 Subject: [PATCH] Ensure CreateApplication only waits on NotFound and AlreadyExists We were not failing quickly on deployment errors such as trying to deploy a subordinate with a unit. --- internal/juju/applications.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/internal/juju/applications.go b/internal/juju/applications.go index 161482ac..15a0190c 100644 --- a/internal/juju/applications.go +++ b/internal/juju/applications.go @@ -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)