Skip to content

Commit 081fd8d

Browse files
Canary Deployment Changes (#3051) (#3087)
Introduce canary strategy on all the commands Co-authored-by: João Pereira <[email protected]>
1 parent 7f5d48c commit 081fd8d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+2568
-1484
lines changed

actor/v7action/application.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -298,9 +298,9 @@ func (actor Actor) PollStart(app resources.Application, noWait bool, handleInsta
298298
}
299299
}
300300

301-
// PollStartForRolling polls a deploying application's processes until some are started. It does the same thing as PollStart, except it accounts for rolling deployments and whether
301+
// PollStartForDeployment polls a deploying application's processes until some are started. It does the same thing as PollStart, except it accounts for rolling/canary deployments and whether
302302
// they have failed or been canceled during polling.
303-
func (actor Actor) PollStartForRolling(app resources.Application, deploymentGUID string, noWait bool, handleInstanceDetails func(string)) (Warnings, error) {
303+
func (actor Actor) PollStartForDeployment(app resources.Application, deploymentGUID string, noWait bool, handleInstanceDetails func(string)) (Warnings, error) {
304304
var (
305305
deployment resources.Deployment
306306
processes []resources.Process
@@ -321,7 +321,7 @@ func (actor Actor) PollStartForRolling(app resources.Application, deploymentGUID
321321
}
322322
return allWarnings, actionerror.StartupTimeoutError{Name: app.Name}
323323
case <-timer.C():
324-
if !isDeployed(deployment) {
324+
if !isDeployProcessed(deployment) {
325325
ccDeployment, warnings, err := actor.getDeployment(deploymentGUID)
326326
allWarnings = append(allWarnings, warnings...)
327327
if err != nil {
@@ -335,7 +335,7 @@ func (actor Actor) PollStartForRolling(app resources.Application, deploymentGUID
335335
}
336336
}
337337

338-
if noWait || isDeployed(deployment) {
338+
if noWait || isDeployProcessed(deployment) {
339339
stopPolling, warnings, err := actor.PollProcesses(processes, handleInstanceDetails)
340340
allWarnings = append(allWarnings, warnings...)
341341
if stopPolling || err != nil {
@@ -348,7 +348,12 @@ func (actor Actor) PollStartForRolling(app resources.Application, deploymentGUID
348348
}
349349
}
350350

351-
func isDeployed(d resources.Deployment) bool {
351+
func isDeployProcessed(d resources.Deployment) bool {
352+
if d.Strategy == constant.DeploymentStrategyCanary {
353+
return d.StatusValue == constant.DeploymentStatusValueActive && d.StatusReason == constant.DeploymentStatusReasonPaused ||
354+
d.StatusValue == constant.DeploymentStatusValueFinalized && d.StatusReason == constant.DeploymentStatusReasonDeployed
355+
}
356+
352357
return d.StatusValue == constant.DeploymentStatusValueFinalized && d.StatusReason == constant.DeploymentStatusReasonDeployed
353358
}
354359

@@ -439,7 +444,7 @@ func (actor Actor) getProcesses(deployment resources.Deployment, appGUID string,
439444

440445
// if the deployment is deployed we know web are all running and PollProcesses will see those as stable
441446
// so just getting all processes is equivalent to just getting non-web ones and polling those
442-
if isDeployed(deployment) {
447+
if isDeployProcessed(deployment) {
443448
processes, warnings, err := actor.CloudControllerClient.GetApplicationProcesses(appGUID)
444449
if err != nil {
445450
return processes, Warnings(warnings), err

actor/v7action/application_summary_test.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,33 @@ var _ = Describe("Application Summary Actions", func() {
628628
})
629629
})
630630
})
631+
632+
When("the deployment strategy is canary", func() {
633+
When("the deployment is paused", func() {
634+
BeforeEach(func() {
635+
fakeCloudControllerClient.GetDeploymentsReturns(
636+
[]resources.Deployment{
637+
{
638+
GUID: "some-deployment-guid",
639+
Strategy: "canary",
640+
StatusValue: "ACTIVE",
641+
StatusReason: "PAUSED",
642+
},
643+
},
644+
nil,
645+
nil,
646+
)
647+
})
648+
It("returns the deployment information", func() {
649+
Expect(summary.Deployment).To(Equal(resources.Deployment{
650+
GUID: "some-deployment-guid",
651+
Strategy: "canary",
652+
StatusValue: "ACTIVE",
653+
StatusReason: "PAUSED",
654+
}))
655+
})
656+
})
657+
})
631658
})
632659

633660
When("the deployment is not active", func() {

0 commit comments

Comments
 (0)