Skip to content

Commit 429ca3f

Browse files
author
Michal Tichák
committed
[core] Counting number of status updates in transition_deploy
1 parent 783fc89 commit 429ca3f

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

core/environment/transition_deploy.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,13 @@ func (t DeployTransition) do(env *Environment) (err error) {
217217

218218
deploymentTimeout := acquireDeploymentTimeout(wf)
219219

220+
numberOfLeaves := 0
221+
workflow.LeafWalk(wf, func(role workflow.Role) {
222+
numberOfLeaves += 1
223+
})
224+
225+
numberOfStatusChanges := 0
226+
220227
wfStatus := wf.GetStatus()
221228
if wfStatus != task.ACTIVE {
222229
log.WithField("partition", env.Id().String()).
@@ -228,6 +235,8 @@ func (t DeployTransition) do(env *Environment) (err error) {
228235
log.WithField("status", wfStatus.String()).
229236
WithField("partition", env.Id().String()).
230237
Debug("workflow status change")
238+
numberOfStatusChanges += 1
239+
231240
if wfStatus == task.ACTIVE {
232241
break WORKFLOW_ACTIVE_LOOP
233242
} else if wfStatus == task.UNDEPLOYABLE {
@@ -255,7 +264,11 @@ func (t DeployTransition) do(env *Environment) (err error) {
255264
inactiveTaskRolesS := strings.Join(undeployableTaskRoles, ", ")
256265

257266
err = fmt.Errorf("workflow deployment failed (one or more roles undeployable), aborting and cleaning up [undeployable roles: %s]", inactiveTaskRolesS)
267+
break WORKFLOW_ACTIVE_LOOP
268+
}
258269

270+
if numberOfStatusChanges >= numberOfLeaves {
271+
err = fmt.Errorf("workflow did not receive ACTIVE status after all (%d) roles reported their statuses", numberOfLeaves)
259272
break WORKFLOW_ACTIVE_LOOP
260273
}
261274
continue

0 commit comments

Comments
 (0)