Dont restart service on device name change

Change-type: patch
Closes: #659
Signed-off-by: Cameron Diver <cameron@resin.io>
This commit is contained in:
Cameron Diver 2018-07-19 11:25:48 +01:00
parent 065f79390f
commit f7958e6c6b
No known key found for this signature in database
GPG Key ID: 69264F9C923F55C1
3 changed files with 19 additions and 10 deletions

View File

@ -100,15 +100,25 @@ module.exports = class ServiceManager extends EventEmitter
.then (existingService) =>
return @docker.getContainer(existingService.containerId)
.catch NotFoundError, =>
conf = service.toContainerConfig()
nets = service.extraNetworksToJoin()
@logger.logSystemEvent(logTypes.installService, { service })
@reportNewStatus(mockContainerId, service, 'Installing')
@docker.createContainer(conf)
@config.get('name')
.then (deviceName) =>
service.environment['RESIN_DEVICE_NAME_AT_INIT'] = deviceName
conf = service.toContainerConfig()
nets = service.extraNetworksToJoin()
@logger.logSystemEvent(logTypes.installService, { service })
@reportNewStatus(mockContainerId, service, 'Installing')
@docker.createContainer(conf)
.tap (container) =>
service.containerId = container.id
Promise.map nets, ({ name, endpointConfig }) =>
@docker.getNetwork(name).connect({ Container: container.id, EndpointConfig: endpointConfig })
@docker
.getNetwork(name)
.connect({ Container: container.id, EndpointConfig: endpointConfig })
.tap =>
@logger.logSystemEvent(logTypes.installServiceSuccess, { service })
.tapCatch (err) =>

View File

@ -339,7 +339,6 @@ module.exports = class Service
RESIN_APP_NAME: appName
RESIN_SERVICE_NAME: @serviceName
RESIN_DEVICE_UUID: uuid
RESIN_DEVICE_NAME_AT_INIT: name
RESIN_DEVICE_TYPE: deviceType
RESIN_HOST_OS_VERSION: osVersion
RESIN_SUPERVISOR_VERSION: version
@ -713,9 +712,10 @@ module.exports = class Service
equalProps = _.isEqual(_.pick(this, propertiesToCompare), _.pick(otherService, propertiesToCompare))
equalEnv = _.isEqual(
_.omit(@environment, [ 'RESIN_DEVICE_NAME_AT_INIT ']),
_.omit(otherService.environment, [ 'RESIN_DEVICE_NAME_AT_INIT '])
_.omit(@environment, [ 'RESIN_DEVICE_NAME_AT_INIT' ]),
_.omit(otherService.environment, [ 'RESIN_DEVICE_NAME_AT_INIT' ])
)
equalNetworks = @hasSameNetworks(otherService)
equalArrays = _.every arraysToCompare, (property) =>
_.isEmpty(_.xorWith(this[property], otherService[property], _.isEqual))

View File

@ -32,7 +32,6 @@ describe 'compose/service.cofee', ->
RESIN_APP_ID: '23'
RESIN_APP_NAME: 'awesomeApp'
RESIN_DEVICE_UUID: '1234'
RESIN_DEVICE_NAME_AT_INIT: 'awesomeDevice'
RESIN_DEVICE_TYPE: 'raspberry-pi'
RESIN_HOST_OS_VERSION: 'Resin OS 2.0.2'
RESIN_SERVICE_NAME: 'serviceName'