state-engine: Return a noop when waiting for a dependency

We run the risk of the state engine exiting early when a dependency is
not ready, especially in local mode. This changes forces a noop to be
returned when we are waiting on another service, which is the process
used elsewhere in the state engine.

Change-type: patch
Signed-off-by: Cameron Diver <cameron@balena.io>
This commit is contained in:
Cameron Diver 2019-03-11 17:54:59 +00:00
parent 8f2d6f4d7b
commit 84356b82b8
No known key found for this signature in database
GPG Key ID: 49690ED87032539F
2 changed files with 4 additions and 4 deletions

View File

@ -547,7 +547,7 @@ module.exports = class ApplicationManager extends EventEmitter
# We only kill when dependencies are already met, so that we minimize downtime
return serviceAction('kill', target.serviceId, current, target)
else
return null
return { action: 'noop' }
'kill-then-download': (current, target) ->
return serviceAction('kill', target.serviceId, current, target)
'delete-then-download': (current, target) ->
@ -560,7 +560,7 @@ module.exports = class ApplicationManager extends EventEmitter
else if dependenciesMetForStart()
return serviceAction('handover', target.serviceId, current, target, timeout: timeout)
else
return null
return { action: 'noop' }
}
_nextStepForService: ({ current, target }, updateContext, localMode) =>

View File

@ -257,12 +257,12 @@ describe 'ApplicationManager', ->
@normaliseTarget(targetState[4], availableImages[2])
(current, target) =>
steps = @applications._inferNextSteps(false, availableImages[2], [], true, current, target, false, {})
expect(steps).to.eventually.deep.equal([{
expect(steps).to.eventually.have.deep.members([{
action: 'fetch'
image: @applications.imageForService(target.local.apps[0].services[0])
serviceId: 23
appId: 1234
}])
}, { action: 'noop', appId: 1234 }])
)
it 'infers to kill several services as long as there is no unmet dependency', ->