Skip to content

Commit c904e40

Browse files
pivotalgeorgeGreg Wereschjoaopapereira
authored
Print max-in-flight value alongside deployment status [main] (#3098)
* Deduplicate tests from previous merge Co-authored-by: Greg Weresch <[email protected]> * Print max-in-flight value as part of deployment information in process table when it is set to non-default value (currently 1) Co-authored-by: Greg Weresch <[email protected]> * Fix flakey tests that look for output from cf app - these tests depend on a short-lived state Co-authored-by: Greg Weresch <[email protected]> * Apply suggestions from code review Co-authored-by: João Pereira <[email protected]> * Refactor app summary displayer tests to use Say instead of MatchRegexp Co-authored-by: Greg Weresch <[email protected]> --------- Co-authored-by: Greg Weresch <[email protected]> Co-authored-by: João Pereira <[email protected]>
1 parent 31ffcb2 commit c904e40

File tree

4 files changed

+304
-116
lines changed

4 files changed

+304
-116
lines changed

api/cloudcontroller/ccv3/constant/deployment.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,5 @@ 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: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,12 @@ func (display AppSummaryDisplayer) displayProcessTable(summary v7action.Detailed
162162
if summary.Deployment.StatusValue == constant.DeploymentStatusValueActive {
163163
display.UI.DisplayNewline()
164164
display.UI.DisplayText(display.getDeploymentStatusText(summary))
165+
166+
var maxInFlight = summary.Deployment.Options.MaxInFlight
167+
if maxInFlight > 0 && maxInFlight != constant.DeploymentMaxInFlightDefaultValue {
168+
display.UI.DisplayText(fmt.Sprintf("max-in-flight: %d", maxInFlight))
169+
}
170+
165171
if summary.Deployment.Strategy == constant.DeploymentStrategyCanary && summary.Deployment.StatusReason == constant.DeploymentStatusReasonPaused {
166172
display.UI.DisplayNewline()
167173
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))
@@ -171,25 +177,15 @@ func (display AppSummaryDisplayer) displayProcessTable(summary v7action.Detailed
171177

172178
func (display AppSummaryDisplayer) getDeploymentStatusText(summary v7action.DetailedApplicationSummary) string {
173179
var lastStatusChangeTime = display.getLastStatusChangeTime(summary)
174-
175180
if lastStatusChangeTime != "" {
176181
return fmt.Sprintf("%s deployment currently %s (since %s)",
177182
cases.Title(language.English, cases.NoLower).String(string(summary.Deployment.Strategy)),
178183
summary.Deployment.StatusReason,
179184
lastStatusChangeTime)
180185
} else {
181-
var sb strings.Builder
182-
sb.WriteString(fmt.Sprintf("%s deployment currently %s.",
186+
return fmt.Sprintf("%s deployment currently %s.",
183187
cases.Title(language.English, cases.NoLower).String(string(summary.Deployment.Strategy)),
184-
summary.Deployment.StatusReason))
185-
186-
if summary.Deployment.Strategy == constant.DeploymentStrategyCanary && summary.Deployment.StatusReason == constant.DeploymentStatusReasonPaused {
187-
sb.WriteString("\n")
188-
sb.WriteString(fmt.Sprintf(
189-
"Please run `cf continue-deployment %s` to promote the canary deployment, or `cf cancel-deployment %s` to rollback to the previous version.",
190-
summary.Application.Name, summary.Application.Name))
191-
}
192-
return sb.String()
188+
summary.Deployment.StatusReason)
193189
}
194190
}
195191

0 commit comments

Comments
 (0)