Bug 1032403

Summary: cloud-init not persisting hostname
Product: [Fedora] Fedora Reporter: Ian Wienand <iwienand>
Component: cloud-initAssignee: Garrett Holmstrom <gholms>
Status: CLOSED EOL QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 19CC: apevec, bexelbie, gholms, Jan.van.Eldik, mattdm, p, shardy
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-02-17 19:19:08 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
full cloud-init log none

Description Ian Wienand 2013-11-20 06:05:01 UTC
Description of problem:

I am setting a short hostname in user data

---
[fedora@gerritbot etc]$ curl http://169.254.169.254/2009-04-04/user-data
#cloud-config
hostname: gerritbot
disable_root: 0
---

the system boots, and the hostname is set correctly, but /etc/hostname is not updated and remains the very long instance-name e.g.

---
[fedora@gerritbot etc]$ cat hostname
gerritbot-55968-blahblahblah-oslab-fedora19-20131119232722.noval
[fedora@gerritbot etc]$ hostname
gerritbot
---

thus when the system reboots, it gets the incorrect value from /etc/hostname

here is a grep of hostname related things in the logs

---
[fedora@gerritbot etc]$ cat /var/log/cloud-init.log  | grep hostname
Nov 20 05:51:10 localhost [CLOUDINIT] importer.py[DEBUG]: Looking for modules ['cc_set_hostname', 'cloudinit.config.cc_set_hostname'] that have attributes ['handle']
Nov 20 05:51:10 localhost [CLOUDINIT] importer.py[DEBUG]: Found cc_set_hostname with attributes ['handle'] in ['cloudinit.config.cc_set_hostname']
Nov 20 05:51:10 localhost [CLOUDINIT] importer.py[DEBUG]: Looking for modules ['cc_update_hostname', 'cloudinit.config.cc_update_hostname'] that have attributes ['handle']
Nov 20 05:51:10 localhost [CLOUDINIT] importer.py[DEBUG]: Found cc_update_hostname with attributes ['handle'] in ['cloudinit.config.cc_update_hostname']
Nov 20 05:51:13 localhost [CLOUDINIT] util.py[DEBUG]: Writing to /var/lib/cloud/instances/i-00000377/sem/config_set_hostname - wb: [420] 18 bytes
Nov 20 05:51:13 localhost [CLOUDINIT] util.py[DEBUG]: Restoring selinux mode for /var/lib/cloud/instances/i-00000377/sem/config_set_hostname (recursive=False)
Nov 20 05:51:13 localhost [CLOUDINIT] util.py[DEBUG]: Restoring selinux mode for /var/lib/cloud/instances/i-00000377/sem/config_set_hostname (recursive=False)
Nov 20 05:51:13 localhost [CLOUDINIT] helpers.py[DEBUG]: Running config-set_hostname using lock (<FileLock using file '/var/lib/cloud/instances/i-00000377/sem/config_set_hostname'>)
Nov 20 05:51:13 localhost [CLOUDINIT] cc_set_hostname.py[DEBUG]: Setting the hostname to gerritbot-55968-blahblahblah-oslab-fedora19-20131119232722.novalocal (gerritbot)
Nov 20 05:51:13 localhost [CLOUDINIT] util.py[DEBUG]: Running command ['hostnamectl', 'set-hostname', 'gerritbot-55968-blahblahblah-oslab-fedora19-20131119232722.novalocal'] with allowed return codes [0] (shell=False, capture=True)
Nov 20 05:51:13 localhost [CLOUDINIT] __init__.py[DEBUG]: Non-persistently setting the system hostname to gerritbot
Nov 20 05:51:13 localhost [CLOUDINIT] util.py[DEBUG]: Running command ['hostname', 'gerritbot'] with allowed return codes [0] (shell=False, capture=True)
Nov 20 05:51:13 localhost [CLOUDINIT] helpers.py[DEBUG]: Running config-update_hostname using lock (<cloudinit.helpers.DummyLock object at 0x2fce190>)
Nov 20 05:51:13 localhost [CLOUDINIT] cc_update_hostname.py[DEBUG]: Updating hostname to gerritbot-55968-blahblahblah-oslab-fedora19-20131119232722.novalocal (gerritbot)
Nov 20 05:51:13 localhost [CLOUDINIT] util.py[DEBUG]: Running command ['hostname'] with allowed return codes [0] (shell=False, capture=True)
Nov 20 05:51:13 localhost [CLOUDINIT] __init__.py[DEBUG]: Attempting to update hostname to gerritbot-55968-blahblahblah-oslab-fedora19-20131119232722.novalocal in 1 files
Nov 20 05:51:13 localhost [CLOUDINIT] util.py[DEBUG]: Running command ['hostnamectl', 'set-hostname', 'gerritbot-55968-blahblahblah-oslab-fedora19-20131119232722.novalocal'] with allowed return codes [0] (shell=False, capture=True)
---

Version-Release number of selected component (if applicable):

Installed Packages
Name        : cloud-init
Arch        : noarch
Version     : 0.7.2
Release     : 1.fc19
Size        : 1.0 M
Repo        : installed
From repo   : koji-override-0

Comment 1 Ian Wienand 2013-11-20 06:07:39 UTC
Created attachment 826442 [details]
full cloud-init log

Comment 2 Matthew Miller 2014-08-13 14:49:01 UTC
I think this should work correctly in F20.

Comment 3 Brian (bex) Exelbierd 2014-08-14 08:33:20 UTC
This is still occuring in the latest Fedora Atomic Image

Comment 4 Fedora End Of Life 2015-01-09 20:38:31 UTC
This message is a notice that Fedora 19 is now at end of life. Fedora 
has stopped maintaining and issuing updates for Fedora 19. It is 
Fedora's policy to close all bug reports from releases that are no 
longer maintained. Approximately 4 (four) weeks from now this bug will
be closed as EOL if it remains open with a Fedora 'version' of '19'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 19 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 5 Fedora End Of Life 2015-02-17 19:19:08 UTC
Fedora 19 changed to end-of-life (EOL) status on 2015-01-06. Fedora 19 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.