Skip to content

Commit

Permalink
Cancel rolling deployments when the CF_STARTUP_TIMEOUT has been reached
Browse files Browse the repository at this point in the history
issue #2169

Co-authored-by: Teal Stannard <tstannard@pivotal.io>
Co-authored-by: Seth Boyles <sboyles@pivotal.io>
  • Loading branch information
Teal Stannard and sethboyles committed May 26, 2021
1 parent 80dddc7 commit 61677f2
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
5 changes: 5 additions & 0 deletions actor/v7action/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,11 @@ func (actor Actor) PollStartForRolling(app resources.Application, deploymentGUID
for {
select {
case <-timeout:
warnings, err := actor.CancelDeployment(deploymentGUID)
allWarnings = append(allWarnings, warnings...)
if err != nil {
return allWarnings, err
}
return allWarnings, actionerror.StartupTimeoutError{Name: app.Name}
case <-timer.C():
if !isDeployed(deployment) {
Expand Down
39 changes: 37 additions & 2 deletions actor/v7action/application_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1200,9 +1200,13 @@ var _ = Describe("Application Actions", func() {
ccv3.Warnings{"get-deployment-warning"},
nil,
)
fakeCloudControllerClient.CancelDeploymentReturns(
ccv3.Warnings{"cancel-deployment-warning"},
nil,
)
})

It("returns a timeout error and any warnings", func() {
It("returns a timeout error and any warnings and cancels the deployment", func() {
// initial tick
fakeClock.WaitForNWatchersAndIncrement(1*time.Millisecond, 2)

Expand All @@ -1211,12 +1215,43 @@ var _ = Describe("Application Actions", func() {
// timeout tick
fakeClock.Increment(1 * time.Millisecond)

Eventually(fakeCloudControllerClient.CancelDeploymentCallCount).Should(Equal(1))

// wait for func to finish
Eventually(done).Should(Receive(BeTrue()))

Expect(executeErr).To(MatchError(actionerror.StartupTimeoutError{}))
Expect(warnings).To(ConsistOf("get-deployment-warning"))
Expect(warnings).To(ConsistOf("get-deployment-warning", "cancel-deployment-warning"))
})

When("the cancel deployment fails", func() {
BeforeEach(func() {
fakeCloudControllerClient.CancelDeploymentReturns(
ccv3.Warnings{"cancel-deployment-warning"},
errors.New("cancel-deployment-error"),
)
})

It("returns a timeout error and any warnings and cancels the deployment", func() {
// initial tick
fakeClock.WaitForNWatchersAndIncrement(1*time.Millisecond, 2)

Eventually(fakeCloudControllerClient.GetDeploymentCallCount).Should(Equal(1))

// timeout tick
fakeClock.Increment(1 * time.Millisecond)

Eventually(fakeCloudControllerClient.CancelDeploymentCallCount).Should(Equal(1))

// wait for func to finish
Eventually(done).Should(Receive(BeTrue()))

Expect(executeErr).To(MatchError("cancel-deployment-error"))
Expect(warnings).To(ConsistOf("get-deployment-warning", "cancel-deployment-warning"))
})

})

})

When("the processes dont become healthy", func() {
Expand Down

0 comments on commit 61677f2

Please sign in to comment.