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:
CameronDiver 2019-03-13 12:22:43 +00:00 committed by GitHub
commit 1f5ef1ab03
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 6 deletions

View File

@ -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

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', ->