From 3bfe9dddf98f129889efeb6cf669091ac9b1eb01 Mon Sep 17 00:00:00 2001 From: Jimmy Kaplowitz Date: Tue, 5 Aug 2014 16:55:14 -0700 Subject: [PATCH] Reinstate hostname hook for GCE This DHCP exit hook to shorten the system hostname on GCE was previously installed by build-debian-cloud and bootstrap-vz, but seems to have been inadvertently removed in commit c81045cc6e0f6a2c90002ab50219a15c337630f1 as part of a broad cross-cloud cleanup. Again, this was caught by our validation tests, and we might be done with the fixes at this point. In this commit, I'm reinstating the hook with a name change and an explanatory comment, to reduce the risk of this vanishing accidentally in the future. Change-Id: I4e7268f8b9ab3b2a7fc8b510898c6fbdd685aa53 --- bootstrapvz/providers/gce/__init__.py | 2 +- bootstrapvz/providers/gce/tasks/host.py | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/bootstrapvz/providers/gce/__init__.py b/bootstrapvz/providers/gce/__init__.py index d6a187d..4fbe5b1 100644 --- a/bootstrapvz/providers/gce/__init__.py +++ b/bootstrapvz/providers/gce/__init__.py @@ -36,7 +36,7 @@ def resolve_tasks(taskset, manifest): tasks.configuration.GatherReleaseInformation, tasks.host.DisableIPv6, - tasks.host.SetHostname, + tasks.host.InstallHostnameHook, tasks.boot.ConfigureGrub, initd.InstallInitScripts, ssh.AddSSHKeyGeneration, diff --git a/bootstrapvz/providers/gce/tasks/host.py b/bootstrapvz/providers/gce/tasks/host.py index bd61878..aabd017 100644 --- a/bootstrapvz/providers/gce/tasks/host.py +++ b/bootstrapvz/providers/gce/tasks/host.py @@ -17,12 +17,25 @@ class DisableIPv6(Task): print >>config_file, "net.ipv6.conf.all.disable_ipv6 = 1" -class SetHostname(Task): - description = "Setting hostname" +class InstallHostnameHook(Task): + description = "Installing hostname hook" phase = phases.system_modification @classmethod def run(cls, info): + # There's a surprising amount of software out there which doesn't react well to the system + # hostname being set to a potentially long the fully qualified domain name, including Java 7 + # and lower, quite relevant to a lot of cloud use cases such as Hadoop. Since Google Compute + # Engine's out-of-the-box domain names are long but predictable based on project name, we + # install this hook to set the hostname to the short hostname but add a suitable /etc/hosts + # entry. + # + # Since not all operating systems which Google supports on Compute Engine work with the + # /etc/dhcp/dhclient-exit-hooks.d directory, Google's internally-built packaging uses the + # consistent install path of /usr/share/google/set-hostname, and OS-specific build steps are + # used to activate the DHCP hook. In any future Debian-maintained distro-specific packaging, + # the updated deb could handle installing the below symlink or the script itself into + # /etc/dhcp/dhclient-exit-hooks.d. log_check_call(['chroot', info.root, 'ln', '-s', '/usr/share/google/set-hostname', '/etc/dhcp/dhclient-exit-hooks.d/set-hostname'])