Skip to content

Commit 48e2735

Browse files
authored
Merge pull request #491 from ANUGRAHG/main
Ensure application stops when the stopped flag is set with rolling or blue-green strategy
2 parents de7d5b0 + 7a856a3 commit 48e2735

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

operation/push.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,15 @@ func (p *AppPushOperation) pushBlueGreenApp(ctx context.Context, space *resource
8787
return p.pushApp(ctx, space, manifest, zipFile)
8888
}
8989

90+
if p.stopped {
91+
// If stopped flag is set just stop the original app and return
92+
_, err = p.client.Applications.Stop(ctx, originalApp.GUID)
93+
if err != nil {
94+
return nil, fmt.Errorf("failed to stop the application with: %w", err)
95+
}
96+
return originalApp, err
97+
}
98+
9099
tempAppName := originalApp.Name + "-venerable"
91100

92101
// Check if temporary app name already exists if yes gracefully delete the app and continue
@@ -133,6 +142,16 @@ func (p *AppPushOperation) pushRollingApp(ctx context.Context, space *resource.S
133142
if errors.Is(err, client.ErrExactlyOneResultNotReturned) || originalApp.State != "STARTED" {
134143
return p.pushApp(ctx, space, manifest, zipFile)
135144
}
145+
146+
if p.stopped {
147+
// If stopped flag is set just stop the original app and return
148+
_, err = p.client.Applications.Stop(ctx, originalApp.GUID)
149+
if err != nil {
150+
return nil, fmt.Errorf("failed to stop the application with: %w", err)
151+
}
152+
return originalApp, err
153+
}
154+
136155
// Get the fallback revision in case of rollback
137156
fallbackRevision, _ := p.client.Revisions.SingleForAppDeployed(ctx, originalApp.GUID, nil)
138157

0 commit comments

Comments
 (0)