Skip to content

Commit ec7df41

Browse files
authored
Fixed bundle run for apps when compute is already starting (#3478)
## Changes It can happen that after creating app the compute state returned from API is Starting already. Previously we incorrectly handled this and did not wait for the app to start first ## Why Fixes nightly tests ## Tests <!-- How have you tested the changes? --> <!-- If your PR needs to be included in the release notes for next release, add a separate entry in NEXT_CHANGELOG.md as part of your PR. -->
1 parent 1cda440 commit ec7df41

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

bundle/run/app.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func (a *appRunner) Name() string {
3737
return a.app.Name
3838
}
3939

40-
func isAppStopped(app *apps.App) bool {
40+
func isAppComputeStopped(app *apps.App) bool {
4141
return app.ComputeStatus == nil ||
4242
(app.ComputeStatus.State == apps.ComputeStateStopped || app.ComputeStatus.State == apps.ComputeStateError)
4343
}
@@ -70,13 +70,21 @@ func (a *appRunner) Run(ctx context.Context, opts *Options) (output.RunOutput, e
7070
// 1. The app is new and was never deployed yet.
7171
// 2. The app was stopped (compute not running).
7272
// We need to start the app only if the compute is not running.
73-
if isAppStopped(createdApp) {
73+
if isAppComputeStopped(createdApp) {
7474
err := a.start(ctx)
7575
if err != nil {
7676
return nil, err
7777
}
7878
}
7979

80+
// If the app is starting, we need to wait for it to be active before we can deploy it.
81+
if isAppComputeStarting(createdApp) {
82+
_, err := w.Apps.WaitGetAppActive(ctx, app.Name, 20*time.Minute, nil)
83+
if err != nil {
84+
return nil, err
85+
}
86+
}
87+
8088
// Deploy the app.
8189
err = a.deploy(ctx)
8290
if err != nil {
@@ -87,6 +95,10 @@ func (a *appRunner) Run(ctx context.Context, opts *Options) (output.RunOutput, e
8795
return nil, nil
8896
}
8997

98+
func isAppComputeStarting(app *apps.App) bool {
99+
return app.ComputeStatus != nil && app.ComputeStatus.State == apps.ComputeStateStarting
100+
}
101+
90102
func (a *appRunner) start(ctx context.Context) error {
91103
app := a.app
92104
b := a.bundle

0 commit comments

Comments
 (0)