mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2024-12-19 21:57:54 +00:00
Only wait for success if we're restarting due to an update attempt.
If we're restarting for binds/mounts then we're already in a non-working state, and starting the new supervisor may have to wait for bootstrap to complete (which takes an indefinite amount of time to complete, meaning the timeout was killing the new container before it could bootstrap in some cases)
This commit is contained in:
parent
8c774549ad
commit
2210b1be29
@ -24,7 +24,7 @@ getCurrentContainer = ->
|
||||
getContainerId().then (containerId) ->
|
||||
docker.getContainer(containerId).inspectAsync()
|
||||
|
||||
startNewSupervisor = (currentSupervisor) ->
|
||||
startNewSupervisor = (currentSupervisor, waitForSuccess = true) ->
|
||||
console.log('Creating supervisor container:', localImage)
|
||||
docker.createContainerAsync(
|
||||
Image: localImage
|
||||
@ -39,6 +39,8 @@ startNewSupervisor = (currentSupervisor) ->
|
||||
Binds: config.supervisorContainer.Binds
|
||||
)
|
||||
.then (container) ->
|
||||
if !waitForSuccess
|
||||
return
|
||||
# check that next supervisor outputs config.successMessage before this supervisor exits
|
||||
container.attachAsync({ stream: true, stdout: true, stderr: false, tty: true })
|
||||
.then (stream) ->
|
||||
@ -76,7 +78,14 @@ currentSupervisor = getCurrentContainer().tap (currentSupervisor) ->
|
||||
# Check all the expected binds and volumes exist, if not then start a new supervisor (which will add them correctly)
|
||||
if !_.isEqual(expectedVolumes, actualVolumes) or !_.isEqual(expectedBinds, actualBinds)
|
||||
console.log('Supervisor restart (for binds/mounts)')
|
||||
startNewSupervisor(currentSupervisor)
|
||||
restart = ->
|
||||
# When restarting for just binds/mounts we just wait for the supervisor updates to start.
|
||||
startNewSupervisor(currentSupervisor, false)
|
||||
.catch (err) ->
|
||||
console.error('Error restarting', err)
|
||||
# If there's an error just keep attempting to restart to get to a useful state.
|
||||
restart()
|
||||
restart()
|
||||
|
||||
# This is a promise that resolves when we have fully initialised.
|
||||
exports.initialised = currentSupervisor.then (currentSupervisor) ->
|
||||
|
Loading…
Reference in New Issue
Block a user