cloud-init-dev team mailing list archive
-
cloud-init-dev team
-
Mailing list archive
-
Message #00658
[Merge] lp:~brak/cloud-init/dont-overwrite-hostname into lp:cloud-init
Brian Rak has proposed merging lp:~brak/cloud-init/dont-overwrite-hostname into lp:cloud-init.
Requested reviews:
cloud init development team (cloud-init-dev)
For more details, see:
https://code.launchpad.net/~brak/cloud-init/dont-overwrite-hostname/+merge/256348
Based on what I understand, the 'update_hostname' task is only supposed to be setting the hostname once per instance. If something else modifies the hostname after update_hostname sets it, update_hostname should not overwrite those changes. (To overwrite, it seems you'd use 'set_hostname' instead).
The update_hostname function actually detects this case already, but all it does is emit a debug log entry about it.
This patch detects the case when the hostname has been changed by something else after cloud-init has set it, and will not overwrite the hostname again.
--
Your team cloud init development team is requested to review the proposed merge of lp:~brak/cloud-init/dont-overwrite-hostname into lp:cloud-init.
=== modified file 'cloudinit/distros/__init__.py'
--- cloudinit/distros/__init__.py 2015-01-26 16:14:06 +0000
+++ cloudinit/distros/__init__.py 2015-04-15 15:35:56 +0000
@@ -208,6 +208,15 @@
and sys_hostname != hostname):
update_files.append(sys_fn)
+ # If something else has changed the hostname after we set it
+ # initially, we should not overwrite those changes (we should
+ # only be setting the hostname once per instance)
+ if (sys_hostname and prev_hostname and
+ sys_hostname != prev_hostname):
+ LOG.info("%s differs from %s, assuming user maintained hostname.",
+ prev_hostname_fn, sys_fn)
+ return
+
# Remove duplicates (incase the previous config filename)
# is the same as the system config filename, don't bother
# doing it twice
@@ -222,11 +231,6 @@
util.logexc(LOG, "Failed to write hostname %s to %s", hostname,
fn)
- if (sys_hostname and prev_hostname and
- sys_hostname != prev_hostname):
- LOG.debug("%s differs from %s, assuming user maintained hostname.",
- prev_hostname_fn, sys_fn)
-
# If the system hostname file name was provided set the
# non-fqdn as the transient hostname.
if sys_fn in update_files:
Follow ups