Skip to content

Commit 4a247e9

Browse files
committed
[core] fix lost ACTIVE status notification during deploy
1 parent fab9e79 commit 4a247e9

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

‎core/environment/transition_deploy.go‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,13 @@ func (t DeployTransition) do(env *Environment) (err error) {
184184
185185
return*/
186186

187-
notifyStatus := make(chan task.Status)
187+
// notifyStatusCh is used only as a wake-up signal. To be sure that updates are not missed we need to
188+
// query the status wia wf.GetStatus() because senders is sending asynchronously so the value
189+
// inside the channel does not have to be the most recent. I didn't change the channel type to
190+
// not break something else.
191+
notifyStatusCh := make(chan task.Status, 1)
188192
subscriptionId := uuid.NewUUID().String()
189-
env.wfAdapter.SubscribeToStatusChange(subscriptionId, notifyStatus)
193+
env.wfAdapter.SubscribeToStatusChange(subscriptionId, notifyStatusCh)
190194
defer env.wfAdapter.UnsubscribeFromStatusChange(subscriptionId)
191195

192196
// listen to workflow State changes
@@ -230,7 +234,8 @@ func (t DeployTransition) do(env *Environment) (err error) {
230234
WORKFLOW_ACTIVE_LOOP:
231235
for {
232236
select {
233-
case wfStatus = <-notifyStatus:
237+
case <-notifyStatusCh:
238+
wfStatus = wf.GetStatus()
234239
log.WithField("status", wfStatus.String()).
235240
WithField("partition", env.Id().String()).
236241
Debug("workflow status change")
@@ -268,6 +273,10 @@ func (t DeployTransition) do(env *Environment) (err error) {
268273

269274
case <-time.After(deploymentTimeout):
270275
wfStatus = wf.GetStatus()
276+
// just a safety check in case we missed the final update
277+
if wfStatus == task.ACTIVE {
278+
break WORKFLOW_ACTIVE_LOOP
279+
}
271280
inactiveTaskRoles := make([]string, 0)
272281
undeployableTaskRoles := make([]string, 0)
273282
workflow.LeafWalk(wf, func(role workflow.Role) {

0 commit comments

Comments
 (0)