From 50bcd8448ecab85194b4559569ebc8568191e481 Mon Sep 17 00:00:00 2001 From: Georgy Kibardin Date: Thu, 21 Apr 2016 14:52:43 +0300 Subject: [PATCH] Do restart mcollective after provisioning nailgun agent must not change mcollective config after provisioning cloudinit is responsible for that. It may happen that nailgun agent may be started by cron earlier than it is reconfigured and started by cloudinit. This leads to the situation when cloudinit reconfigures mcollective and issues start which doesn't do anything since it is already started by nailgun agent. Finally, mcollective is left started with incorrect default configuration. Change-Id: I0c6f3720943ad21e22899368832e451bc906b098 Closes-Bug: #1455489 --- agent | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/agent b/agent index a83318c..7b41367 100755 --- a/agent +++ b/agent @@ -32,6 +32,7 @@ require 'uri' # TODO(vsharshov): replace below lines by this string after excluding Ruby 1.8 require 'pathname' require 'rexml/document' +require 'socket' include REXML unless Process.euid == 0 @@ -1036,6 +1037,10 @@ def write_data_to_file(logger, filename, data) end end +def provisioned? + Socket.gethostname != 'bootstrap' +end + logger = Logger.new(STDOUT) if File.exist?('/etc/nailgun_uid') @@ -1079,7 +1084,9 @@ begin end new_id = JSON.parse(resp.body)['id'] mc_config = McollectiveConfig.new(logger) - mc_config.replace_identity(new_id) + unless provisioned? + mc_config.replace_identity(new_id) + end write_data_to_file(logger, '/etc/nailgun_uid', new_id.to_s) rescue => ex # NOTE(mihgen): There is no need to retry - cron will do it for us