From 7f38248cfa5c62adf3ce09ab4b030b90f8115fcc Mon Sep 17 00:00:00 2001 From: Pagan Gazzard Date: Wed, 1 Oct 2014 18:26:32 +0100 Subject: [PATCH] Let the new supervisor handle tagging itself as a working supervisor, this means that the check that a supervisor update is a working update will not be nullified by a reboot. --- src/app.coffee | 5 ++--- src/supervisor-update.coffee | 20 ++++++++++++-------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/app.coffee b/src/app.coffee index 811588bc..3aafd335 100644 --- a/src/app.coffee +++ b/src/app.coffee @@ -5,7 +5,6 @@ knex = require './db' utils = require './utils' {spawn} = require 'child_process' bootstrap = require './bootstrap' -config = require './config' utils.mixpanelTrack('Supervisor start') @@ -95,5 +94,5 @@ knex('config').select('value').where(key: 'uuid').then ([ uuid ]) -> console.log('Starting connectivity check..') ensureConnected(true) - # Let the previous supervisor know that we started successfully - console.log(config.successMessage) + # Tell the supervisor updater that we have successfully started, so that it can do whatever it needs to. + supervisor.startupSuccessful() diff --git a/src/supervisor-update.coffee b/src/supervisor-update.coffee index e26b122f..c0252fb1 100644 --- a/src/supervisor-update.coffee +++ b/src/supervisor-update.coffee @@ -112,15 +112,9 @@ exports.initialised = currentSupervisor.then (currentSupervisor) -> stream.on('end', resolve) .then -> - console.log('Tagging supervisor:', remoteImage) - docker.getImage(remoteImage).tagAsync( - repo: localImage - force: true - ) - .then -> - console.log('Inspecting newly tagged supervisor:', localImage) + console.log('Inspecting new supervisor:', remoteImage) Promise.all([ - docker.getImage(localImage).inspectAsync() + docker.getImage(remoteImage).inspectAsync() currentSupervisor ]) .spread (localImageInfo, currentSupervisor) -> @@ -135,3 +129,13 @@ exports.initialised = currentSupervisor.then (currentSupervisor) -> # The error here is intentionally not propagated further up the chain, # because the supervisor-update module internally handles update failures # and makes sure that ill updates do not affect the rest of the system. + + exports.startupSuccessful = -> + # Let the previous supervisor know that we started successfully + console.log(config.successMessage) + + console.log('Tagging ourselves as a working supervisor:', remoteImage) + docker.getImage(remoteImage).tagAsync( + repo: localImage + force: true + )