Browse Source

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
Georgy Kibardin 3 years ago
parent
commit
50bcd8448e
1 changed files with 8 additions and 1 deletions
  1. 8
    1
      agent

+ 8
- 1
agent View File

@@ -32,6 +32,7 @@ require 'uri'
32 32
 # TODO(vsharshov): replace below lines by this string after excluding Ruby 1.8
33 33
 require 'pathname'
34 34
 require 'rexml/document'
35
+require 'socket'
35 36
 include REXML
36 37
 
37 38
 unless Process.euid == 0
@@ -1036,6 +1037,10 @@ def write_data_to_file(logger, filename, data)
1036 1037
   end
1037 1038
 end
1038 1039
 
1040
+def provisioned?
1041
+  Socket.gethostname != 'bootstrap'
1042
+end
1043
+
1039 1044
 logger = Logger.new(STDOUT)
1040 1045
 
1041 1046
 if File.exist?('/etc/nailgun_uid')
@@ -1079,7 +1084,9 @@ begin
1079 1084
   end
1080 1085
   new_id = JSON.parse(resp.body)['id']
1081 1086
   mc_config = McollectiveConfig.new(logger)
1082
-  mc_config.replace_identity(new_id)
1087
+  unless provisioned?
1088
+    mc_config.replace_identity(new_id)
1089
+  end
1083 1090
   write_data_to_file(logger, '/etc/nailgun_uid', new_id.to_s)
1084 1091
 rescue => ex
1085 1092
   # NOTE(mihgen): There is no need to retry - cron will do it for us

Loading…
Cancel
Save