Breaking Change: HOSTNAME variable changed format, breaking apps

82 views
Skip to first unread message

Anders Brown

unread,
Jan 14, 2017, 5:49:05 PM1/14/17
to gce-discussion
After yum update yesterday, the HOSTNAME environment variable on CentOS 7 is no longer the machine name ("orcale"), but rather a FQDN ("oracle.c.projectname.internal"). This breaks several scripts, that assume otherwise.

Why is this and how can the previous behavior be restored?

Carlos (Cloud Platform Support)

unread,
Jan 16, 2017, 7:46:36 PM1/16/17
to gce-dis...@googlegroups.com
Hi Anders,

Thank you for your message.

I believe you have also opened this report on regards the same issue , I will be working with you on that link. Nevertheless,I would like to mention here that it is a normal behavior for GCE CentOS images to get the hostname via DHCP. An initial though I have is that the DHCP client configuration might have changed when the VM got updated. Here there is another interesting discussion.


Phill Booth

unread,
Jan 17, 2017, 4:50:57 AM1/17/17
to gce-discussion
Hi, I solved a similar the problem by doing this.

Making the /etc/resolv.conf Immutable (unwritable)
Once you are satisfied that you have set the DNS nameservers you'd like to use for host to ip resolution, you can now safely make the file unwritable, to prevent nova-agent automation from changing it on reboots. This should not affect your regular networking configuration, and only affects DNS resolution.

chattr +i /etc/resolv.conf

To remove the immutable file at any point later on you can do:

chattr -i /etc/resolv.conf

Carlos (Cloud Platform Support)

unread,
Jan 18, 2017, 10:02:52 AM1/18/17
to gce-discussion
Hi Phill, 

That is an interesting workaround to avoid changes in resolv.conf. Another way to achieve the same would be re-configuring the dhcp client. 

Anders Brown

unread,
Jan 25, 2017, 3:00:41 PM1/25/17
to gce-discussion
Interestingly and gladly, the issue went away magically today after yet another yum update and reboot. Hostname is now the machine name again. This seemed to have been a transient issue that either Google developers or Red Hat developers have solved in the meanwhile. Knowingly or by accident -- who knows.  I'm glad it works again. Thanks so much for your help. The Google Cloud team is really doing a great job.

Zach Marano

unread,
Jan 26, 2017, 1:05:59 PM1/26/17
to gce-discussion
Hi Anders,
We fixed this issue (thanks for finding it by the way!) in an update that went out on 1/24/2017. Release notes for those images are here. And the change in question is here. Let us know if you run into any further trouble. And thanks for reporting and finding this problem!
Reply all
Reply to author
Forward
0 new messages