Skip to content

Commit 5f5e4d5

Browse files
Wait for app deletion in DoCreate instead of DoDelete
1 parent fe1b364 commit 5f5e4d5

File tree

1 file changed

+7
-8
lines changed
  • bundle/direct/dresources

1 file changed

+7
-8
lines changed

bundle/direct/dresources/app.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ func (r *ResourceApp) DoRead(ctx context.Context, id string) (*apps.App, error)
3131
}
3232

3333
func (r *ResourceApp) DoCreate(ctx context.Context, config *apps.App) (string, *apps.App, error) {
34+
if err := r.waitForDeletion(ctx, config.Name); err != nil {
35+
return "", nil, err
36+
}
37+
3438
request := apps.CreateAppRequest{
3539
App: *config,
3640
NoCompute: true,
@@ -63,10 +67,7 @@ func (r *ResourceApp) DoUpdate(ctx context.Context, id string, config *apps.App,
6367

6468
func (r *ResourceApp) DoDelete(ctx context.Context, id string) error {
6569
_, err := r.client.Apps.DeleteByName(ctx, id)
66-
if err != nil {
67-
return err
68-
}
69-
return r.waitForDeletion(ctx, id)
70+
return err
7071
}
7172

7273
func (*ResourceApp) FieldTriggers(_ bool) map[string]deployplan.ActionType {
@@ -97,11 +98,9 @@ func (r *ResourceApp) waitForDeletion(ctx context.Context, name string) error {
9798
switch app.ComputeStatus.State {
9899
case apps.ComputeStateDeleting:
99100
return nil, retries.Continues("app is deleting")
100-
case apps.ComputeStateActive, apps.ComputeStateStopped, apps.ComputeStateError:
101-
err := fmt.Errorf("app %s was not deleted, current state: %s", name, app.ComputeStatus.State)
102-
return nil, retries.Halt(err)
103101
default:
104-
return nil, retries.Continues(fmt.Sprintf("app is in %s state", app.ComputeStatus.State))
102+
err := fmt.Errorf("app %s already exists", name)
103+
return nil, retries.Halt(err)
105104
}
106105
})
107106
return err

0 commit comments

Comments
 (0)