Skip to content

Commit 15e2367

Browse files
committed
Fix rollback that was not setting the correct values on the deployment
Signed-off-by: João Pereira <joao.pereira@broadcom.com>
1 parent 42cb1fe commit 15e2367

2 files changed

Lines changed: 22 additions & 3 deletions

File tree

command/v7/shared/app_stager.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,16 +122,17 @@ func (stager *Stager) StartApp(app resources.Application, space configv3.Space,
122122
Strategy: opts.Strategy,
123123
Relationships: resources.Relationships{constant.RelationshipTypeApplication: resources.Relationship{GUID: app.GUID}},
124124
}
125+
126+
if opts.Strategy == constant.DeploymentStrategyCanary && len(opts.CanarySteps) > 0 {
127+
dep.Options = resources.DeploymentOpts{CanaryDeploymentOptions: resources.CanaryDeploymentOptions{Steps: opts.CanarySteps}}
128+
}
125129
switch opts.AppAction {
126130
case constant.ApplicationRollingBack:
127131
dep.RevisionGUID = resourceGuid
128132
dep.Options.MaxInFlight = opts.MaxInFlight
129133
deploymentGUID, warnings, err = stager.Actor.CreateDeployment(dep)
130134
default:
131135
dep.DropletGUID = resourceGuid
132-
if opts.Strategy == constant.DeploymentStrategyCanary && len(opts.CanarySteps) > 0 {
133-
dep.Options = resources.DeploymentOpts{CanaryDeploymentOptions: resources.CanaryDeploymentOptions{Steps: opts.CanarySteps}}
134-
}
135136
dep.Options.MaxInFlight = opts.MaxInFlight
136137
deploymentGUID, warnings, err = stager.Actor.CreateDeployment(dep)
137138
}

command/v7/shared/app_stager_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,24 @@ var _ = Describe("app stager", func() {
539539
})
540540
})
541541

542+
When("the app action is rollback", func() {
543+
BeforeEach(func() {
544+
appAction = constant.ApplicationRollingBack
545+
strategy = constant.DeploymentStrategyCanary
546+
canaryWeightSteps = []resources.CanaryStep{{InstanceWeight: 1}, {InstanceWeight: 2}}
547+
app = resources.Application{GUID: "app-guid", Name: "app-name", State: constant.ApplicationStarted}
548+
})
549+
550+
It("displays output for each step of starting", func() {
551+
Expect(executeErr).To(BeNil())
552+
553+
Expect(fakeActor.CreateDeploymentCallCount()).To(Equal(1))
554+
deployment := fakeActor.CreateDeploymentArgsForCall(0)
555+
Expect(deployment.Strategy).To(Equal(constant.DeploymentStrategyCanary))
556+
Expect(deployment.Options.CanaryDeploymentOptions.Steps).To(Equal(canaryWeightSteps))
557+
})
558+
})
559+
542560
When("the app action is restarting", func() {
543561
It("displays output for each step of restarting", func() {
544562
Expect(executeErr).To(BeNil())

0 commit comments

Comments
 (0)