Skip to content

Commit 39b9f3c

Browse files
author
Greg Weresch
authored
Always show max-in-flight value for active deployments (#3121)
- show deployment strategy value on its own line
1 parent c1f3e70 commit 39b9f3c

File tree

9 files changed

+102
-97
lines changed

9 files changed

+102
-97
lines changed

api/cloudcontroller/ccv3/constant/deployment.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,3 @@ const (
3131
DeploymentStatusValueActive DeploymentStatusValue = "ACTIVE"
3232
DeploymentStatusValueFinalized DeploymentStatusValue = "FINALIZED"
3333
)
34-
35-
const DeploymentMaxInFlightDefaultValue int = 1

command/v7/shared/app_summary_displayer.go

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package shared
22

33
import (
44
"fmt"
5+
"strconv"
56
"strings"
67
"time"
78

@@ -12,8 +13,6 @@ import (
1213
"code.cloudfoundry.org/cli/resources"
1314
"code.cloudfoundry.org/cli/util/ui"
1415
log "github.com/sirupsen/logrus"
15-
"golang.org/x/text/cases"
16-
"golang.org/x/text/language"
1716
)
1817

1918
type AppSummaryDisplayer struct {
@@ -57,7 +56,7 @@ func (display AppSummaryDisplayer) AppDisplay(summary v7action.DetailedApplicati
5756
}
5857
}
5958

60-
display.UI.DisplayKeyValueTable("", keyValueTable, 3)
59+
display.UI.DisplayKeyValueTable("", keyValueTable, ui.DefaultTableSpacePadding)
6160

6261
if summary.LifecycleType == constant.AppLifecycleTypeBuildpack {
6362
display.displayBuildpackTable(summary.CurrentDroplet.Buildpacks)
@@ -150,7 +149,7 @@ func (display AppSummaryDisplayer) displayProcessTable(summary v7action.Detailed
150149
startCommandRow,
151150
}
152151

153-
display.UI.DisplayKeyValueTable("", keyValueTable, 3)
152+
display.UI.DisplayKeyValueTable("", keyValueTable, ui.DefaultTableSpacePadding)
154153

155154
if len(process.InstanceDetails) == 0 {
156155
display.UI.DisplayText("There are no running instances of this process.")
@@ -163,11 +162,19 @@ func (display AppSummaryDisplayer) displayProcessTable(summary v7action.Detailed
163162
display.UI.DisplayNewline()
164163
display.UI.DisplayText(display.getDeploymentStatusText(summary))
165164

165+
var maxInFlightRow []string
166166
var maxInFlight = summary.Deployment.Options.MaxInFlight
167-
if maxInFlight > 0 && maxInFlight != constant.DeploymentMaxInFlightDefaultValue {
168-
display.UI.DisplayText(fmt.Sprintf("max-in-flight: %d", maxInFlight))
167+
if maxInFlight > 0 {
168+
maxInFlightRow = append(maxInFlightRow, display.UI.TranslateText("max-in-flight:"), strconv.Itoa(maxInFlight))
169169
}
170170

171+
keyValueTable := [][]string{
172+
{display.UI.TranslateText("strategy:"), strings.ToLower(string(summary.Deployment.Strategy))},
173+
maxInFlightRow,
174+
}
175+
176+
display.UI.DisplayKeyValueTable("", keyValueTable, ui.DefaultTableSpacePadding)
177+
171178
if summary.Deployment.Strategy == constant.DeploymentStrategyCanary && summary.Deployment.StatusReason == constant.DeploymentStatusReasonPaused {
172179
display.UI.DisplayNewline()
173180
display.UI.DisplayText(fmt.Sprintf("Please run `cf continue-deployment %s` to promote the canary deployment, or `cf cancel-deployment %s` to rollback to the previous version.", summary.Application.Name, summary.Application.Name))
@@ -178,13 +185,11 @@ func (display AppSummaryDisplayer) displayProcessTable(summary v7action.Detailed
178185
func (display AppSummaryDisplayer) getDeploymentStatusText(summary v7action.DetailedApplicationSummary) string {
179186
var lastStatusChangeTime = display.getLastStatusChangeTime(summary)
180187
if lastStatusChangeTime != "" {
181-
return fmt.Sprintf("%s deployment currently %s (since %s)",
182-
cases.Title(language.English, cases.NoLower).String(string(summary.Deployment.Strategy)),
188+
return fmt.Sprintf("Active deployment with status %s (since %s)",
183189
summary.Deployment.StatusReason,
184190
lastStatusChangeTime)
185191
} else {
186-
return fmt.Sprintf("%s deployment currently %s.",
187-
cases.Title(language.English, cases.NoLower).String(string(summary.Deployment.Strategy)),
192+
return fmt.Sprintf("Active deployment with status %s.",
188193
summary.Deployment.StatusReason)
189194
}
190195
}

command/v7/shared/app_summary_displayer_test.go

Lines changed: 40 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package shared_test
22

33
import (
4-
"fmt"
54
"time"
65

76
"code.cloudfoundry.org/cli/actor/v7action"
@@ -14,8 +13,6 @@ import (
1413
. "github.com/onsi/ginkgo/v2"
1514
. "github.com/onsi/gomega"
1615
. "github.com/onsi/gomega/gbytes"
17-
"golang.org/x/text/cases"
18-
"golang.org/x/text/language"
1916
)
2017

2118
var _ = Describe("app summary displayer", func() {
@@ -718,11 +715,12 @@ var _ = Describe("app summary displayer", func() {
718715
})
719716

720717
It("displays the message", func() {
721-
Expect(testUI.Out).To(Say(`Rolling deployment currently DEPLOYING \(since %s\)`, dateTimeRegexPattern))
718+
Expect(testUI.Out).To(Say(`Active deployment with status DEPLOYING \(since %s\)`, dateTimeRegexPattern))
719+
Expect(testUI.Out).To(Say(`strategy: rolling`))
722720
})
723721

724722
It("displays max-in-flight value", func() {
725-
Expect(testUI.Out).To(Say(`max-in-flight: 2`))
723+
Expect(testUI.Out).To(Say(`max-in-flight: 2`))
726724
})
727725
})
728726

@@ -742,11 +740,9 @@ var _ = Describe("app summary displayer", func() {
742740
})
743741

744742
It("displays the message", func() {
745-
Expect(testUI.Out).To(Say(`Rolling deployment currently DEPLOYING \(since %s\)`, dateTimeRegexPattern))
746-
})
747-
748-
It("does not display max-in-flight", func() {
749-
Expect(testUI.Out).NotTo(Say(`max-in-flight`))
743+
Expect(testUI.Out).To(Say(`Active deployment with status DEPLOYING \(since %s\)`, dateTimeRegexPattern))
744+
Expect(testUI.Out).To(Say(`strategy: rolling`))
745+
Expect(testUI.Out).To(Say(`max-in-flight: 1`))
750746
})
751747
})
752748

@@ -763,11 +759,9 @@ var _ = Describe("app summary displayer", func() {
763759
})
764760

765761
It("displays the message", func() {
766-
Expect(testUI.Out).To(Say(`Rolling deployment currently DEPLOYING \(since %s\)`, dateTimeRegexPattern))
767-
})
768-
769-
It("does not display max-in-flight", func() {
770-
Expect(testUI.Out).NotTo(Say(`max-in-flight`))
762+
Expect(testUI.Out).To(Say(`Active deployment with status DEPLOYING \(since %s\)`, dateTimeRegexPattern))
763+
Expect(testUI.Out).To(Say(`strategy: rolling`))
764+
Expect(testUI.Out).ToNot(Say(`max-in-flight`))
771765
})
772766
})
773767

@@ -787,12 +781,13 @@ var _ = Describe("app summary displayer", func() {
787781
})
788782

789783
It("displays the message", func() {
790-
Expect(testUI.Out).To(Say(`Rolling deployment currently DEPLOYING`))
784+
Expect(testUI.Out).To(Say(`Active deployment with status DEPLOYING`))
791785
Expect(testUI.Out).NotTo(Say(`\(since`))
786+
Expect(testUI.Out).To(Say(`strategy: rolling`))
792787
})
793788

794789
It("displays max-in-flight value", func() {
795-
Expect(testUI.Out).To(Say(`max-in-flight: 2`))
790+
Expect(testUI.Out).To(Say(`max-in-flight: 2`))
796791
})
797792
})
798793

@@ -812,12 +807,10 @@ var _ = Describe("app summary displayer", func() {
812807
})
813808

814809
It("displays the message", func() {
815-
Expect(testUI.Out).To(Say(`Rolling deployment currently DEPLOYING`))
810+
Expect(testUI.Out).To(Say(`Active deployment with status DEPLOYING`))
816811
Expect(testUI.Out).NotTo(Say(`\(since`))
817-
})
818-
819-
It("does not display max-in-flight", func() {
820-
Expect(testUI.Out).NotTo(Say(`max-in-flight`))
812+
Expect(testUI.Out).To(Say(`strategy: rolling`))
813+
Expect(testUI.Out).To(Say(`max-in-flight: 1`))
821814
})
822815
})
823816
})
@@ -839,11 +832,12 @@ var _ = Describe("app summary displayer", func() {
839832
})
840833

841834
It("displays the message", func() {
842-
Expect(testUI.Out).To(Say(`Rolling deployment currently CANCELING \(since %s\)`, dateTimeRegexPattern))
835+
Expect(testUI.Out).To(Say(`Active deployment with status CANCELING \(since %s\)`, dateTimeRegexPattern))
836+
Expect(testUI.Out).To(Say(`strategy: rolling`))
843837
})
844838

845839
It("displays max-in-flight value", func() {
846-
Expect(testUI.Out).To(Say(`max-in-flight: 2`))
840+
Expect(testUI.Out).To(Say(`max-in-flight: 2`))
847841
})
848842
})
849843

@@ -863,11 +857,9 @@ var _ = Describe("app summary displayer", func() {
863857
})
864858

865859
It("displays the message", func() {
866-
Expect(testUI.Out).To(Say(`Rolling deployment currently CANCELING \(since %s\)`, dateTimeRegexPattern))
867-
})
868-
869-
It("does not display max-in-flight", func() {
870-
Expect(testUI.Out).NotTo(Say(`max-in-flight`))
860+
Expect(testUI.Out).To(Say(`Active deployment with status CANCELING \(since %s\)`, dateTimeRegexPattern))
861+
Expect(testUI.Out).To(Say(`strategy: rolling`))
862+
Expect(testUI.Out).To(Say(`max-in-flight: 1`))
871863
})
872864
})
873865
})
@@ -891,12 +883,13 @@ var _ = Describe("app summary displayer", func() {
891883
})
892884

893885
It("displays the message", func() {
894-
Expect(testUI.Out).To(Say(`Canary deployment currently DEPLOYING \(since %s\)`, dateTimeRegexPattern))
886+
Expect(testUI.Out).To(Say(`Active deployment with status DEPLOYING \(since %s\)`, dateTimeRegexPattern))
887+
Expect(testUI.Out).To(Say(`strategy: canary`))
895888
Expect(testUI.Out).NotTo(Say(`promote the canary deployment`))
896889
})
897890

898891
It("displays max-in-flight value", func() {
899-
Expect(testUI.Out).To(Say(`max-in-flight: 2`))
892+
Expect(testUI.Out).To(Say(`max-in-flight: 2`))
900893
})
901894
})
902895

@@ -916,12 +909,10 @@ var _ = Describe("app summary displayer", func() {
916909
})
917910

918911
It("displays the message", func() {
919-
Expect(testUI.Out).To(Say(`Canary deployment currently DEPLOYING \(since %s\)`, dateTimeRegexPattern))
912+
Expect(testUI.Out).To(Say(`Active deployment with status DEPLOYING \(since %s\)`, dateTimeRegexPattern))
913+
Expect(testUI.Out).To(Say(`strategy: canary`))
920914
Expect(testUI.Out).NotTo(Say(`promote the canary deployment`))
921-
})
922-
923-
It("does not display max-in-flight", func() {
924-
Expect(testUI.Out).NotTo(Say(`max-in-flight`))
915+
Expect(testUI.Out).To(Say(`max-in-flight: 1`))
925916
})
926917
})
927918
})
@@ -948,12 +939,13 @@ var _ = Describe("app summary displayer", func() {
948939
})
949940

950941
It("displays the message", func() {
951-
Expect(testUI.Out).To(Say(`Canary deployment currently PAUSED \(since %s\)`, dateTimeRegexPattern))
942+
Expect(testUI.Out).To(Say(`Active deployment with status PAUSED \(since %s\)`, dateTimeRegexPattern))
943+
Expect(testUI.Out).To(Say(`strategy: canary`))
952944
Expect(testUI.Out).To(Say("Please run `cf continue-deployment foobar` to promote the canary deployment, or `cf cancel-deployment foobar` to rollback to the previous version."))
953945
})
954946

955947
It("displays max-in-flight value", func() {
956-
Expect(testUI.Out).To(Say(`max-in-flight: 2`))
948+
Expect(testUI.Out).To(Say(`max-in-flight: 2`))
957949
})
958950
})
959951

@@ -978,13 +970,11 @@ var _ = Describe("app summary displayer", func() {
978970
})
979971

980972
It("displays the message", func() {
981-
Expect(testUI.Out).To(Say(`Canary deployment currently PAUSED \(since %s\)`, dateTimeRegexPattern))
973+
Expect(testUI.Out).To(Say(`Active deployment with status PAUSED \(since %s\)`, dateTimeRegexPattern))
974+
Expect(testUI.Out).To(Say(`strategy: canary`))
975+
Expect(testUI.Out).To(Say(`max-in-flight: 1`))
982976
Expect(testUI.Out).To(Say("Please run `cf continue-deployment foobar` to promote the canary deployment, or `cf cancel-deployment foobar` to rollback to the previous version."))
983977
})
984-
985-
It("does not display max-in-flight", func() {
986-
Expect(testUI.Out).NotTo(Say(`max-in-flight`))
987-
})
988978
})
989979
})
990980

@@ -1005,12 +995,13 @@ var _ = Describe("app summary displayer", func() {
1005995
})
1006996

1007997
It("displays the message", func() {
1008-
Expect(testUI.Out).To(Say(`Canary deployment currently CANCELING \(since %s\)`, dateTimeRegexPattern))
998+
Expect(testUI.Out).To(Say(`Active deployment with status CANCELING \(since %s\)`, dateTimeRegexPattern))
999+
Expect(testUI.Out).To(Say(`strategy: canary`))
10091000
Expect(testUI.Out).NotTo(Say(`promote the canary deployment`))
10101001
})
10111002

10121003
It("displays max-in-flight value", func() {
1013-
Expect(testUI.Out).To(Say(`max-in-flight: 2`))
1004+
Expect(testUI.Out).To(Say(`max-in-flight: 2`))
10141005
})
10151006
})
10161007

@@ -1030,13 +1021,11 @@ var _ = Describe("app summary displayer", func() {
10301021
})
10311022

10321023
It("displays the message", func() {
1033-
Expect(testUI.Out).To(Say(`Canary deployment currently CANCELING \(since %s\)`, dateTimeRegexPattern))
1024+
Expect(testUI.Out).To(Say(`Active deployment with status CANCELING \(since %s\)`, dateTimeRegexPattern))
1025+
Expect(testUI.Out).To(Say(`strategy: canary`))
1026+
Expect(testUI.Out).To(Say(`max-in-flight: 1`))
10341027
Expect(testUI.Out).NotTo(Say(`promote the canary deployment`))
10351028
})
1036-
1037-
It("does not display max-in-flight", func() {
1038-
Expect(testUI.Out).NotTo(Say(`max-in-flight`))
1039-
})
10401029
})
10411030
})
10421031
})
@@ -1054,9 +1043,7 @@ var _ = Describe("app summary displayer", func() {
10541043
})
10551044

10561045
It("does not display deployment info", func() {
1057-
Expect(testUI.Out).NotTo(Say(fmt.Sprintf("%s deployment currently %s",
1058-
cases.Title(language.English, cases.NoLower).String(string(summary.Deployment.Strategy)),
1059-
summary.Deployment.StatusReason)))
1046+
Expect(testUI.Out).NotTo(Say(`Active deployment with status`))
10601047
})
10611048

10621049
It("does not display max-in-flight", func() {

integration/v7/isolated/app_command_test.go

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -264,12 +264,15 @@ applications:
264264
When("the deployment strategy is rolling", func() {
265265
When("the deployment is in progress", func() {
266266
It("displays the message", func() {
267-
session := helpers.CF("restart", appName, "--strategy", "rolling")
267+
restartSession := helpers.CF("restart", appName, "--strategy", "rolling")
268268

269-
session1 := helpers.CF("app", appName)
270-
Eventually(session1).Should(Say("Rolling deployment currently DEPLOYING"))
271-
Eventually(session).Should(Exit(0))
272-
Eventually(session1).Should(Exit(0))
269+
Eventually(func(g Gomega) {
270+
session := helpers.CF("app", appName).Wait()
271+
g.Expect(session).Should(Say("Active deployment with status DEPLOYING"))
272+
g.Expect(session).Should(Say("strategy: rolling"))
273+
g.Expect(session).Should(Exit(0))
274+
}).Should(Succeed())
275+
Eventually(restartSession).Should(Exit(0))
273276
})
274277
})
275278
})
@@ -280,7 +283,8 @@ applications:
280283
Eventually(helpers.CF("restart", appName, "--strategy", "canary")).Should(Exit(0))
281284

282285
session1 := helpers.CF("app", appName)
283-
Eventually(session1).Should(Say("Canary deployment currently PAUSED"))
286+
Eventually(session1).Should(Say("Active deployment with status PAUSED"))
287+
Eventually(session1).Should(Say("strategy: canary"))
284288
Eventually(session1).Should(Exit(0))
285289
})
286290
})
@@ -292,7 +296,8 @@ applications:
292296

293297
Eventually(func(g Gomega) {
294298
session := helpers.CF("app", appName).Wait()
295-
g.Expect(session).Should(Say("Canary deployment currently CANCELING"))
299+
g.Expect(session).Should(Say("Active deployment with status CANCELING"))
300+
g.Expect(session).Should(Say("strategy: canary"))
296301
g.Expect(session).Should(Exit(0))
297302
}).Should(Succeed())
298303
})
@@ -310,7 +315,7 @@ applications:
310315
It("doesn not display the message", func() {
311316
session := helpers.CF("app", appName)
312317
Eventually(session).Should(Exit(0))
313-
Eventually(session).ShouldNot(Say(`\w+ deployment currently \w+`))
318+
Eventually(session).ShouldNot(Say(`Active deployment with status \w+`))
314319
})
315320
})
316321
})

integration/v7/isolated/copy_source_command_test.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -388,8 +388,9 @@ var _ = Describe("copy-source command", func() {
388388
Eventually(session).Should(Say("Copying source from app %s to target app %s in org %s / space %s as %s...", sourceAppName, targetAppName, orgName, spaceName, username))
389389
Eventually(session).Should(Say("Staging app %s in org %s / space %s as %s...", targetAppName, orgName, spaceName, username))
390390
Eventually(session).Should(Say("Waiting for app to deploy..."))
391-
Eventually(session).Should(Say("Canary deployment currently PAUSED"))
392-
Eventually(session).ShouldNot(Say("max-in-flight"))
391+
Eventually(session).Should(Say("Active deployment with status PAUSED"))
392+
Eventually(session).Should(Say("strategy: canary"))
393+
Eventually(session).Should(Say("max-in-flight: 1"))
393394
Eventually(session).Should(Say("Please run `cf continue-deployment %s` to promote the canary deployment, or `cf cancel-deployment %s` to rollback to the previous version.", targetAppName, targetAppName))
394395
Eventually(session).Should(Exit(0))
395396

@@ -408,8 +409,9 @@ var _ = Describe("copy-source command", func() {
408409
Eventually(session).Should(Say("Copying source from app %s to target app %s in org %s / space %s as %s...", sourceAppName, targetAppName, orgName, spaceName, username))
409410
Eventually(session).Should(Say("Staging app %s in org %s / space %s as %s...", targetAppName, orgName, spaceName, username))
410411
Eventually(session).Should(Say("Waiting for app to deploy..."))
411-
Eventually(session).Should(Say("Canary deployment currently PAUSED"))
412-
Eventually(session).Should(Say("max-in-flight: 2"))
412+
Eventually(session).Should(Say("Active deployment with status PAUSED"))
413+
Eventually(session).Should(Say("strategy: canary"))
414+
Eventually(session).Should(Say("max-in-flight: 2"))
413415
Eventually(session).Should(Say("Please run `cf continue-deployment %s` to promote the canary deployment, or `cf cancel-deployment %s` to rollback to the previous version.", targetAppName, targetAppName))
414416
Eventually(session).Should(Exit(0))
415417

0 commit comments

Comments
 (0)