Skip to content

Commit

Permalink
Cherry-picked Rolling Deployment timeout issue PR
Browse files Browse the repository at this point in the history
Merge pull request #2170 from cloudfoundry/2169-rolling-deploy-timeout-issue

2169 rolling deploy timeout issue
  • Loading branch information
Jenna Goldstrich authored and Jenna Goldstrich committed Jul 2, 2021
1 parent 6738b34 commit 22e69e2
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 28 deletions.
5 changes: 5 additions & 0 deletions actor/v7action/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,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 @@ -1160,9 +1160,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 @@ -1171,12 +1175,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
60 changes: 34 additions & 26 deletions integration/v7/push/rolling_push_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package push

import (
"fmt"

"code.cloudfoundry.org/cli/integration/helpers"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
Expand Down Expand Up @@ -34,21 +36,21 @@ var _ = Describe("push with --strategy rolling", func() {
PushCommandName, appName, "--strategy", "rolling",
)

Eventually(session).Should(Say(`Pushing app %s to org %s / space %s as %s\.\.\.`, appName, organization, space, userName))
Eventually(session).Should(Say(`Packaging files to upload\.\.\.`))
Eventually(session).Should(Say(`Uploading files\.\.\.`))
Eventually(session).Should(Say(`100.00%`))
Eventually(session).Should(Say(`Waiting for API to complete processing files\.\.\.`))
Eventually(session).Should(Say(`Staging app and tracing logs\.\.\.`))
Eventually(session).Should(Say(`Starting deployment for app %s\.\.\.`, appName))
Eventually(session).Should(Say(`Waiting for app to deploy\.\.\.`))
Eventually(session).Should(Say(`name:\s+%s`, appName))
Eventually(session).Should(Say(`requested state:\s+started`))
Eventually(session).Should(Say(`routes:\s+%s.%s`, appName, helpers.DefaultSharedDomain()))
Eventually(session).Should(Say(`type:\s+web`))
Eventually(session).Should(Say(`start command:\s+%s`, helpers.StaticfileBuildpackStartCommand))
Eventually(session).Should(Say(`#0\s+running`))
Eventually(session).Should(Exit(0))
Expect(session).To(Say(`Pushing app %s to org %s / space %s as %s\.\.\.`, appName, organization, space, userName))
Expect(session).To(Say(`Packaging files to upload\.\.\.`))
Expect(session).To(Say(`Uploading files\.\.\.`))
Expect(session).To(Say(`100.00%`))
Expect(session).To(Say(`Waiting for API to complete processing files\.\.\.`))
Expect(session).To(Say(`Staging app and tracing logs\.\.\.`))
Expect(session).To(Say(`Starting deployment for app %s\.\.\.`, appName))
Expect(session).To(Say(`Waiting for app to deploy\.\.\.`))
Expect(session).To(Say(`name:\s+%s`, appName))
Expect(session).To(Say(`requested state:\s+started`))
Expect(session).To(Say(`routes:\s+%s.%s`, appName, helpers.DefaultSharedDomain()))
Expect(session).To(Say(`type:\s+web`))
Expect(session).To(Say(`start command:\s+%s`, helpers.StaticfileBuildpackStartCommand))
Expect(session).To(Say(`#0\s+running`))
})
})
})
Expand Down Expand Up @@ -100,19 +102,25 @@ var _ = Describe("push with --strategy rolling", func() {
WorkingDirectory: appDir,
EnvVars: map[string]string{"CF_STARTUP_TIMEOUT": "0.1"},
}, PushCommandName, appName, "--strategy", "rolling")
Eventually(session).Should(Say(`Pushing app %s to org %s / space %s as %s\.\.\.`, appName, organization, space, userName))
Eventually(session).Should(Say(`Packaging files to upload\.\.\.`))
Eventually(session).Should(Say(`Uploading files\.\.\.`))
Eventually(session).Should(Say(`100.00%`))
Eventually(session).Should(Say(`Waiting for API to complete processing files\.\.\.`))
Eventually(session).Should(Say(`Staging app and tracing logs\.\.\.`))
Eventually(session).Should(Say(`Starting deployment for app %s\.\.\.`, appName))
Eventually(session).Should(Say(`Waiting for app to deploy\.\.\.`))
Eventually(session).Should(Say(`FAILED`))
Eventually(session.Err).Should(Say(`Start app timeout`))
Eventually(session.Err).Should(Say(`TIP: Application must be listening on the right port\. Instead of hard coding the port, use the \$PORT environment variable\.`))
Eventually(session.Err).Should(Say(`Use 'cf logs %s --recent' for more information`, appName))
Eventually(session).Should(Exit(1))
Expect(session).To(Say(`Pushing app %s to org %s / space %s as %s\.\.\.`, appName, organization, space, userName))
Expect(session).To(Say(`Packaging files to upload\.\.\.`))
Expect(session).To(Say(`Uploading files\.\.\.`))
Expect(session).To(Say(`100.00%`))
Expect(session).To(Say(`Waiting for API to complete processing files\.\.\.`))
Expect(session).To(Say(`Staging app and tracing logs\.\.\.`))
Expect(session).To(Say(`Starting deployment for app %s\.\.\.`, appName))
Expect(session).To(Say(`Waiting for app to deploy\.\.\.`))
Expect(session).To(Say(`FAILED`))
Expect(session.Err).To(Say(`Start app timeout`))
Expect(session.Err).To(Say(`TIP: Application must be listening on the right port\. Instead of hard coding the port, use the \$PORT environment variable\.`))
Expect(session.Err).To(Say(`Use 'cf logs %s --recent' for more information`, appName))
appGUID := helpers.AppGUID(appName)
Eventually(func() *Buffer {
session_deployment := helpers.CF("curl", fmt.Sprintf("/v3/deployments?app_guids=%s", appGUID))
Eventually(session_deployment).Should(Exit(0))
return session_deployment.Out
}).Should(Say(`"reason":\s*"CANCELED"`))
})
})
})
Expand Down

0 comments on commit 22e69e2

Please sign in to comment.