mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-04-16 15:28:52 +00:00
Merge pull request #929 from balena-io/fix-local-mode-env-var
Fix changing local mode environment variables from compose file
This commit is contained in:
commit
1f5ef1ab03
@ -477,7 +477,12 @@ module.exports = class ApplicationManager extends EventEmitter
|
||||
# Unless the update strategy requires an early kill (i.e. kill-then-download, delete-then-download), we only want
|
||||
# to kill a service once the images for the services it depends on have been downloaded, so as to minimize
|
||||
# downtime (but not block the killing too much, potentially causing a deadlock)
|
||||
_dependenciesMetForServiceKill: (target, targetApp, availableImages) ->
|
||||
_dependenciesMetForServiceKill: (target, targetApp, availableImages, localMode) ->
|
||||
# Because we only check for an image being available, in local mode this will always
|
||||
# be the case, so return true regardless. If this function ever checks for anything else,
|
||||
# we'll need to change the logic here
|
||||
if localMode
|
||||
return true
|
||||
if target.dependsOn?
|
||||
for dependency in target.dependsOn
|
||||
dependencyService = _.find(targetApp.services, serviceName: dependency)
|
||||
@ -542,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) ->
|
||||
@ -555,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) =>
|
||||
@ -581,7 +586,7 @@ module.exports = class ApplicationManager extends EventEmitter
|
||||
dependenciesMetForStart = =>
|
||||
@_dependenciesMetForServiceStart(target, networkPairs, volumePairs, installPairs.concat(updatePairs))
|
||||
dependenciesMetForKill = =>
|
||||
!needsDownload and @_dependenciesMetForServiceKill(target, targetApp, availableImages)
|
||||
!needsDownload and @_dependenciesMetForServiceKill(target, targetApp, availableImages, localMode)
|
||||
|
||||
# If the service is using a network or volume that is being updated, we need to kill it
|
||||
# even if its strategy is handover
|
||||
|
@ -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', ->
|
||||
|
Loading…
x
Reference in New Issue
Block a user