Auto-merge for PR #625 via VersionBot

Do not try attach to containers that aren't running, and clean up dead containers
This commit is contained in:
resin-io-versionbot[bot] 2018-04-19 22:31:13 +00:00 committed by GitHub
commit 5be3736266
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 34 additions and 4 deletions

View File

@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file
automatically by Versionist. DO NOT EDIT THIS FILE MANUALLY!
This project adheres to [Semantic Versioning](http://semver.org/).
## v7.4.3 - 2018-04-19
* On startup, only attach to logs for running containers, and remove any containers marked as dead #625 [Pablo Carranza Velez]
## v7.4.2 - 2018-04-18
* Properly propagate delta failure #628 [Akis Kesoglou]

View File

@ -1,7 +1,7 @@
{
"name": "resin-supervisor",
"description": "This is resin.io's Supervisor, a program that runs on IoT devices and has the task of running user Apps (which are Docker containers), and updating them as Resin's API informs it to.",
"version": "7.4.2",
"version": "7.4.3",
"license": "Apache-2.0",
"repository": {
"type": "git",

View File

@ -266,6 +266,9 @@ module.exports = class ApplicationManager extends EventEmitter
delete @_containerStarted[step.current.containerId]
if step.options?.removeImage
@images.removeByDockerId(step.current.image)
remove: (step) =>
# Only called for dead containers, so no need to take locks or anything
@services.remove(step.current)
updateMetadata: (step, { force = false, skipLock = false } = {}) =>
skipLock or= checkTruthy(step.current.labels['io.resin.legacy-container'])
@_lockingIfNecessary step.current.appId, { force, skipLock: skipLock or step.options?.skipLock }, =>
@ -678,6 +681,10 @@ module.exports = class ApplicationManager extends EventEmitter
# There is already a kill step in progress for this service, so we wait
return { action: 'noop' }
if current?.status == 'Dead'
# Dead containers have to be removed
return serviceAction('remove', current.serviceId, current)
needsDownload = !_.some availableImages, (image) =>
image.dockerImageId == target?.image or @images.isSameImage(image, { name: target.imageName })

View File

@ -78,6 +78,15 @@ module.exports = class ServiceManager extends EventEmitter
kill: (service, { removeContainer = true, wait = false } = {}) =>
@_killContainer(service.containerId, service, { removeContainer, wait })
remove: (service) =>
@logger.logSystemEvent(logTypes.removeDeadService, { service })
@get(service)
.then (existingService) =>
@docker.getContainer(existingService.containerId).remove(v: true)
.catchReturn(NotFoundError, null)
.tapCatch (err) =>
@logger.logSystemEvent(logTypes.removeDeadServiceError, { service, error: err })
getAllByAppId: (appId) =>
@getAll("io.resin.app-id=#{appId}")
@ -278,5 +287,6 @@ module.exports = class ServiceManager extends EventEmitter
attachToRunning: =>
@getAll()
.map (service) =>
@logger.logSystemEvent(logTypes.startServiceNoop, { service })
@logger.attach(@docker, service.containerId, service)
if service.status == 'Running'
@logger.logSystemEvent(logTypes.startServiceNoop, { service })
@logger.attach(@docker, service.containerId, service)

View File

@ -429,6 +429,8 @@ module.exports = class Service
status = 'Running'
else if container.State.Status == 'created'
status = 'Installed'
else if container.State.Status == 'dead'
status = 'Dead'
else
status = 'Stopped'

View File

@ -15,6 +15,13 @@ module.exports =
eventName: 'Service stop error'
humanName: 'Failed to kill service'
removeDeadService:
eventName: 'Remove dead container'
humanName: 'Removing dead container'
removeDeadServiceError:
eventName: 'Remove dead container error'
humanName: 'Error removing dead container'
downloadImage:
eventName: 'Docker image download'
humanName: 'Downloading image'

View File

@ -29,7 +29,7 @@ RUN curl -sL https://raw.githubusercontent.com/resin-os/balena/${BALENA_VERSION}
RUN passwd -d root
# Change os release to a resin-sync compatible one
RUN sed -i 's/\(PRETTY_NAME=\).*/\1"ResinOS 1.2.1+dind"/' /etc/os-release
RUN sed -i 's/\(PRETTY_NAME=\).*/\1"Resin OS 2.12.5+dind"/' /etc/os-release
RUN echo 'VARIANT_ID="dev"' >> /etc/os-release
COPY config/openvpn/ /etc/openvpn/