@@ -151,31 +151,37 @@ func (p *AppPushOperation) pushBlueGreenApp(ctx context.Context, space *resource
151151 }
152152
153153 if newApp .State == "STARTED" {
154- pollOptions := p .getAppDeployedRunningPollingOptions ()
155- healthCheckErr := p .waitForAppHealthy (ctx , newApp , pollOptions )
156- // If health check fails, delete new app and change back original app name
157- if healthCheckErr != nil {
158- originalName := newApp .Name
159- deleteErr := p .gracefulDeletion (ctx , newApp )
160- if deleteErr != nil {
161- return nil , fmt .Errorf ("failed to delete new app after health check failure: %w" , deleteErr )
162- }
163- _ , revertUpdateErr := p .client .Applications .Update (ctx , originalApp .GUID , & resource.AppUpdate {
164- Name : originalName ,
165- })
154+ if p .isWaitForAppDeployedRunningEnabled () {
155+ pollOptions := p .getAppDeployedRunningPollingOptions ()
156+ healthCheckErr := p .waitForAppHealthy (ctx , newApp , pollOptions )
157+ // If health check fails, delete new app and change back original app name
158+ if healthCheckErr != nil {
159+ originalName := newApp .Name
160+ deleteErr := p .gracefulDeletion (ctx , newApp )
161+ if deleteErr != nil {
162+ return nil , fmt .Errorf ("failed to delete new app after health check failure: %w" , deleteErr )
163+ }
164+ _ , revertUpdateErr := p .client .Applications .Update (ctx , originalApp .GUID , & resource.AppUpdate {
165+ Name : originalName ,
166+ })
166167
167- if revertUpdateErr != nil {
168- return nil , fmt .Errorf ("failed to update app name back to original name: failed with: %w" , revertUpdateErr )
169- }
168+ if revertUpdateErr != nil {
169+ return nil , fmt .Errorf ("failed to update app name back to original name: failed with: %w" , revertUpdateErr )
170+ }
170171
171- return nil , fmt .Errorf ("new application failed health check with: %w" , healthCheckErr )
172+ return nil , fmt .Errorf ("new application failed health check with: %w" , healthCheckErr )
173+ }
172174 }
173175 cleanUpOldErr := p .gracefulDeletion (ctx , originalApp )
174176 return newApp , cleanUpOldErr
175177 }
176178 return newApp , fmt .Errorf ("failed to verify application start: %w" , pushError )
177179}
178180
181+ func (p * AppPushOperation ) isWaitForAppDeployedRunningEnabled () bool {
182+ return p .timeout != 0 || p .checkInterval != 0
183+ }
184+
179185func (p * AppPushOperation ) getAppDeployedRunningPollingOptions () * client.PollingOptions {
180186
181187 if p .timeout == 0 {
@@ -554,6 +560,7 @@ func (p *AppPushOperation) findSpace(ctx context.Context, orgGUID string) (*reso
554560}
555561
556562func (p * AppPushOperation ) waitForAppHealthy (ctx context.Context , app * resource.App , pollOptions * client.PollingOptions ) error {
563+
557564 appPollErr := client .PollForStateOrTimeout (func () (string , string , error ) {
558565 for {
559566 procData , err := p .client .Processes .GetStatsForApp (ctx , app .GUID , "web" )
0 commit comments