MCPcopy Index your code
hub / github.com/cloudfoundry/multiapps-cli-plugin / Monitor

Method Monitor

commands/execution_monitor.go:68–114  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

66}
67
68func (m *ExecutionMonitor) Monitor() ExecutionStatus {
69 totalRetries := m.retries
70 for {
71 operation, err := m.mtaClient.GetMtaOperation(m.operationID, m.embed)
72 if err != nil {
73 ui.Failed("Could not get ongoing operation: %s", baseclient.NewClientError(err))
74 return Failure
75 }
76 m.reportOperationMessages(operation)
77 switch operation.State {
78 case models.StateRUNNING:
79 time.Sleep(3 * time.Second)
80 case models.StateFINISHED:
81 ui.Say("Process finished.")
82 m.reportCommandForDownloadOfProcessLogs(m.operationID)
83 return Success
84 case models.StateABORTED:
85 ui.Say("Process was aborted.")
86 m.reportCommandForDownloadOfProcessLogs(m.operationID)
87 return Failure
88 case models.StateERROR:
89 if canRetry(m.retries, operation) {
90 ui.Say("Proceeding with automatic retry... (%d of %d attempts left)", m.retries, totalRetries)
91 executeRetryAction(m)
92 continue
93 }
94 messageInError := findErrorMessage(operation.Messages)
95 if messageInError == nil {
96 ui.Failed("There is no error message for operation with ID %s", m.operationID)
97 return Failure
98 }
99 ui.Say("Process failed.")
100 m.reportAvaiableActions(m.operationID)
101 m.reportCommandForDownloadOfProcessLogs(m.operationID)
102 return Failure
103 case models.StateACTIONREQUIRED:
104 intermediatePhase, flag := getIntermediatePhaseAndFlag(m.commandName)
105 ui.Say("Process has entered %s phase. After testing your new deployment you can resume or abort the process.", intermediatePhase)
106 m.reportAvaiableActions(m.operationID)
107 ui.Say("Hint: Use the %q option of the %s command to skip this phase.", flag, m.commandName)
108 return Success
109 default:
110 ui.Failed("Process is in illegal state %s.", terminal.EntityNameColor(string(operation.State)))
111 return Failure
112 }
113 }
114}
115
116func getIntermediatePhaseAndFlag(commandName string) (string, string) {
117 //for backwards compatibility until the bg-deploy deprecation period expires

Callers 6

ExecuteMethod · 0.80
executeInternalMethod · 0.80
executeInternalMethod · 0.80
ExecuteMethod · 0.80
executeInternalMethod · 0.80

Calls 11

reportAvaiableActionsMethod · 0.95
FailedFunction · 0.92
NewClientErrorFunction · 0.92
SayFunction · 0.92
canRetryFunction · 0.85
executeRetryActionFunction · 0.85
findErrorMessageFunction · 0.85
GetMtaOperationMethod · 0.65

Tested by

no test coverage detected