Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Canary Deployment Changes #3051

Merged
merged 17 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions actor/v7action/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,9 +298,9 @@ func (actor Actor) PollStart(app resources.Application, noWait bool, handleInsta
}
}

// 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
// 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
// they have failed or been canceled during polling.
func (actor Actor) PollStartForRolling(app resources.Application, deploymentGUID string, noWait bool, handleInstanceDetails func(string)) (Warnings, error) {
func (actor Actor) PollStartForDeployment(app resources.Application, deploymentGUID string, noWait bool, handleInstanceDetails func(string)) (Warnings, error) {
var (
deployment resources.Deployment
processes []resources.Process
Expand All @@ -321,7 +321,7 @@ func (actor Actor) PollStartForRolling(app resources.Application, deploymentGUID
}
return allWarnings, actionerror.StartupTimeoutError{Name: app.Name}
case <-timer.C():
if !isDeployed(deployment) {
if !isDeployProcessed(deployment) {
ccDeployment, warnings, err := actor.getDeployment(deploymentGUID)
allWarnings = append(allWarnings, warnings...)
if err != nil {
Expand All @@ -335,7 +335,7 @@ func (actor Actor) PollStartForRolling(app resources.Application, deploymentGUID
}
}

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

func isDeployed(d resources.Deployment) bool {
func isDeployProcessed(d resources.Deployment) bool {
if d.Strategy == constant.DeploymentStrategyCanary {
return d.StatusValue == constant.DeploymentStatusValueActive && d.StatusReason == constant.DeploymentStatusReasonPaused ||
d.StatusValue == constant.DeploymentStatusValueFinalized && d.StatusReason == constant.DeploymentStatusReasonDeployed
}

return d.StatusValue == constant.DeploymentStatusValueFinalized && d.StatusReason == constant.DeploymentStatusReasonDeployed
}

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

// if the deployment is deployed we know web are all running and PollProcesses will see those as stable
// so just getting all processes is equivalent to just getting non-web ones and polling those
if isDeployed(deployment) {
if isDeployProcessed(deployment) {
processes, warnings, err := actor.CloudControllerClient.GetApplicationProcesses(appGUID)
if err != nil {
return processes, Warnings(warnings), err
Expand Down
27 changes: 27 additions & 0 deletions actor/v7action/application_summary_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,33 @@ var _ = Describe("Application Summary Actions", func() {
})
})
})

When("the deployment strategy is canary", func() {
When("the deployment is paused", func() {
BeforeEach(func() {
fakeCloudControllerClient.GetDeploymentsReturns(
[]resources.Deployment{
{
GUID: "some-deployment-guid",
Strategy: "canary",
StatusValue: "ACTIVE",
StatusReason: "PAUSED",
},
},
nil,
nil,
)
})
It("returns the deployment information", func() {
Expect(summary.Deployment).To(Equal(resources.Deployment{
GUID: "some-deployment-guid",
Strategy: "canary",
StatusValue: "ACTIVE",
StatusReason: "PAUSED",
}))
})
})
})
})

When("the deployment is not active", func() {
Expand Down
Loading
Loading