← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1736174] [NEW] update_hostname module fails on CentOS/RHEL with systemd

 

Public bug reported:

Cloud provider:  OpenStack

#cloud-config
hostname: somehostname.somedomain
fqdn: somehostname.somedomain

 __init__.py[INFO]: /var/lib/cloud/data/previous-hostname differs from
/etc/hostname, assuming user maintained hostname.

Error message is a little bit misleading, since when uses_systemd(),
/etc/hostname isn't actually read, instead, the result of
util.subp(['hostname']) is used.

Also, this comparison/test will never succeed, because when
uses_systemd() and filename.endswitch('/previous-hostname'), the return
is stripped of cr/lf, however, the result of util.subp(['hostname'])
will contain a lf, and it is not being stripped:

(from rhel.py)
if self.uses_systemd() and filename.endswith('/previous-hostname'):
            return util.load_file(filename).strip()
        elif self.uses_systemd():
            (out, _err) = util.subp(['hostname'])
            if len(out):
                return out
            else:
                return default

The simplest solution appears to be to add .strip() to return out; but
this fix may have other implications.

** Affects: cloud-init
     Importance: Undecided
         Status: New


** Tags: centos rhel

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to cloud-init.
https://bugs.launchpad.net/bugs/1736174

Title:
  update_hostname module fails on CentOS/RHEL with systemd

Status in cloud-init:
  New

Bug description:
  Cloud provider:  OpenStack

  #cloud-config
  hostname: somehostname.somedomain
  fqdn: somehostname.somedomain

   __init__.py[INFO]: /var/lib/cloud/data/previous-hostname differs from
  /etc/hostname, assuming user maintained hostname.

  Error message is a little bit misleading, since when uses_systemd(),
  /etc/hostname isn't actually read, instead, the result of
  util.subp(['hostname']) is used.

  Also, this comparison/test will never succeed, because when
  uses_systemd() and filename.endswitch('/previous-hostname'), the
  return is stripped of cr/lf, however, the result of
  util.subp(['hostname']) will contain a lf, and it is not being
  stripped:

  (from rhel.py)
  if self.uses_systemd() and filename.endswith('/previous-hostname'):
              return util.load_file(filename).strip()
          elif self.uses_systemd():
              (out, _err) = util.subp(['hostname'])
              if len(out):
                  return out
              else:
                  return default

  The simplest solution appears to be to add .strip() to return out; but
  this fix may have other implications.

To manage notifications about this bug go to:
https://bugs.launchpad.net/cloud-init/+bug/1736174/+subscriptions


Follow ups