cloud-init 18.2/18.3 centos thinks its ubuntu

Bug #1779847 reported by Christian Setzer on 2018-07-03
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
cloud-init
Medium
Unassigned

Bug Description

im using the copr repo for cloud-init on centos 7.
i tested the latest 18.2 version cloud-init-18.2+5.g01ff5c2e-1.el7.centos.noarch
and the nightly build from yesterday for the 18.3 version.

both have the problem that if i use package_update package_upgrade for example apt is used instead of yum for installing packages.

in /var/log/cloud-init.log i found the following:

[root@SOLUTAPP020 log]# grep ubuntu cloud-init.log
2018-07-03 09:08:45,553 - stages.py[DEBUG]: Using distro class <class 'cloudinit.distros.ubuntu.Distro'>
2018-07-03 09:08:45,778 - stages.py[DEBUG]: Using distro class <class 'cloudinit.distros.ubuntu.Distro'>
2018-07-03 09:08:50,736 - stages.py[DEBUG]: Using distro class <class 'cloudinit.distros.ubuntu.Distro'>
2018-07-03 09:08:50,846 - stages.py[DEBUG]: Using distro class <class 'cloudinit.distros.ubuntu.Distro'>
2018-07-03 09:08:52,943 - stages.py[DEBUG]: Using distro class <class 'cloudinit.distros.ubuntu.Distro'>
2018-07-03 09:08:53,286 - stages.py[DEBUG]: Using distro class <class 'cloudinit.distros.ubuntu.Distro'>

--

that is my /etc/os-release

[root@SOLUTAPP020 log]# cat /etc/os-release
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"

--

as far as i understood the source code in stages.py and util.py is that /etc/os-releases is used for determining the distro.

apparently this fails.

Ryan Harper (raharper) wrote :

Hi,

I'm not able to reproduce this. Can you provide more information about the image or the /var/log/cloud-init.log ?

I attempted to reproduce with:

1. lxc launch images:centos/7/amd64 c7
2. lxc exec c7 /bin/bash
# inside
3. wget https://copr.fedorainfracloud.org/coprs/g/cloud-init/cloud-init-dev/repo/epel-7/group_cloud-init-cloud-init-dev-epel-7.repo -O /etc/yum.repos.d/cloud-init-dev.repo
4. yum install epel-release
5. yum install cloud-init
6. mkdir -p /var/lib/cloud/seed/nocloud-net
7. echo "instance-id: `uuidgen`" > /var/lib/cloud/seed/nocloud-net/meta-data
8. echo -e "#cloud-config\npassword: passw0rd" > /var/lib/cloud/seed/nocloud-net/user-data
9. reboot

Post reboot we have /var/log/cloud-init.log and I checked for ubuntu within the log file.

[root@c7 log]# rpm -qi cloud-init
Name : cloud-init
Version : 18.3+6.gbe9ecc12
Release : 1.el7
Architecture: noarch
Install Date: Tue Jul 3 15:21:59 2018
Group : System Environment/Base
Size : 2971250
License : Dual-licesed GPLv3 or Apache 2.0
Signature : RSA/SHA1, Mon Jul 2 00:02:59 2018, Key ID ad8206bc2741d741
Source RPM : cloud-init-18.3+6.gbe9ecc12-1.el7.src.rpm
Build Date : Mon Jul 2 00:02:55 2018
Build Host : 8bd4096f737c47ac872e445906dddf48
Relocations : (not relocatable)
URL : http://launchpad.net/cloud-init
Summary : Cloud instance init scripts
Description :
Cloud-init is a set of init scripts for cloud instances. Cloud instances
need special scripts to run during initialization to retrieve and install
ssh keys and to let the user run various scripts.

[root@c7 log]# cat /etc/os-release
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"

[root@c7 log]# grep -c distros.ubuntu /var/log/cloud-init.log
0

[root@c7 log]# grep -c distros.centos /var/log/cloud-init.log
6
# grep distros.centos /var/log/cloud-init.log
2018-07-03 15:23:34,415 - stages.py[DEBUG]: Using distro class <class 'cloudinit.distros.centos.Distro'>
2018-07-03 15:23:34,507 - stages.py[DEBUG]: Using distro class <class 'cloudinit.distros.centos.Distro'>
2018-07-03 15:23:37,100 - stages.py[DEBUG]: Using distro class <class 'cloudinit.distros.centos.Distro'>
2018-07-03 15:23:37,165 - stages.py[DEBUG]: Using distro class <class 'cloudinit.distros.centos.Distro'>
2018-07-03 15:24:02,552 - stages.py[DEBUG]: Using distro class <class 'cloudinit.distros.centos.Distro'>
2018-07-03 15:24:02,838 - stages.py[DEBUG]: Using distro class <class 'cloudinit.distros.centos.Distro'>

Changed in cloud-init:
importance: Undecided → Medium
status: New → Incomplete
Chad Smith (chad.smith) wrote :

Additionally if running on cloud-init 18.3.6 or later please report the following on the commandline
$ python -c 'from cloudinit.util import get_linux_distro; print(get_linux_distro())'
# I see this on our centos 7 container
('centos', '7', 'x86_64')

Christian Setzer (mookuh) wrote :
Download full text (99.3 KiB)

[root@myhost log]# python -c 'from cloudinit.util import get_linux_distro; print(get_linux_distro())'
('centos', '7', 'x86_64')

---

[root@myhost log]# cat cloud-init.log
2018-07-03 06:42:08,923 - util.py[DEBUG]: Cloud-init v. 18.3+6.gbe9ecc12-1.el7 running 'init-local' at Tue, 03 Jul 2018 06:42:08 +0000. Up 6.46 seconds.
2018-07-03 06:42:08,924 - main.py[DEBUG]: No kernel command line url found.
2018-07-03 06:42:08,924 - main.py[DEBUG]: Closing stdin.
2018-07-03 06:42:08,924 - util.py[DEBUG]: Restoring selinux mode for /var/lib/cloud (recursive=False)
2018-07-03 06:42:08,924 - util.py[DEBUG]: Restoring selinux mode for /var/lib/cloud (recursive=True)
2018-07-03 06:42:08,926 - util.py[DEBUG]: Restoring selinux mode for /var/lib/cloud/scripts (recursive=False)
2018-07-03 06:42:08,927 - util.py[DEBUG]: Restoring selinux mode for /var/lib/cloud/scripts (recursive=True)
2018-07-03 06:42:08,927 - util.py[DEBUG]: Restoring selinux mode for /var/lib/cloud/scripts/per-instance (recursive=False)
2018-07-03 06:42:08,927 - util.py[DEBUG]: Restoring selinux mode for /var/lib/cloud/scripts (recursive=True)
2018-07-03 06:42:08,929 - util.py[DEBUG]: Restoring selinux mode for /var/lib/cloud/scripts/per-once (recursive=False)
2018-07-03 06:42:08,929 - util.py[DEBUG]: Restoring selinux mode for /var/lib/cloud/scripts (recursive=True)
2018-07-03 06:42:08,930 - util.py[DEBUG]: Restoring selinux mode for /var/lib/cloud/scripts/per-boot (recursive=False)
2018-07-03 06:42:08,931 - util.py[DEBUG]: Restoring selinux mode for /var/lib/cloud/scripts (recursive=True)
2018-07-03 06:42:08,935 - util.py[DEBUG]: Restoring selinux mode for /var/lib/cloud/scripts/vendor (recursive=False)
2018-07-03 06:42:08,936 - util.py[DEBUG]: Restoring selinux mode for /var/lib/cloud (recursive=True)
2018-07-03 06:42:08,938 - util.py[DEBUG]: Restoring selinux mode for /var/lib/cloud/seed (recursive=False)
2018-07-03 06:42:08,939 - util.py[DEBUG]: Restoring selinux mode for /var/lib/cloud (recursive=True)
2018-07-03 06:42:08,940 - util.py[DEBUG]: Restoring selinux mode for /var/lib/cloud/instances (recursive=False)
2018-07-03 06:42:08,941 - util.py[DEBUG]: Restoring selinux mode for /var/lib/cloud (recursive=True)
2018-07-03 06:42:08,943 - util.py[DEBUG]: Restoring selinux mode for /var/lib/cloud/handlers (recursive=False)
2018-07-03 06:42:08,943 - util.py[DEBUG]: Restoring selinux mode for /var/lib/cloud (recursive=True)
2018-07-03 06:42:08,947 - util.py[DEBUG]: Restoring selinux mode for /var/lib/cloud/sem (recursive=False)
2018-07-03 06:42:08,947 - util.py[DEBUG]: Restoring selinux mode for /var/lib/cloud/data (recursive=False)
2018-07-03 06:42:08,948 - util.py[DEBUG]: Writing to /var/log/cloud-init.log - ab: [644] 0 bytes
2018-07-03 06:42:08,948 - util.py[DEBUG]: Restoring selinux mode for /var/log/cloud-init.log (recursive=False)
2018-07-03 06:42:08,948 - util.py[DEBUG]: Restoring selinux mode for /var/log/cloud-init.log (recursive=False)
2018-07-03 06:42:08,949 - util.py[DEBUG]: Changing the ownership of /var/log/cloud-init.log to 0:4
2018-07-03 06:42:08,949 - util.py[DEBUG]: Attempting to remove /var/lib/cloud/instance/boot-finished
2018-07-03 06:42:08,950 - util.py[DEBUG]: Attempt...

Christian Setzer (mookuh) wrote :

why is this still incomplete? do you guys need anything else?

Scott Moser (smoser) on 2018-07-11
Changed in cloud-init:
status: Incomplete → New
Scott Moser (smoser) wrote :

Possibly related error bug 1779847.

Chad Smith (chad.smith) wrote :

might have a related fix for you (we landed it in tip July 9th) https://bugs.launchpad.net/cloud-init/+bug/1780481

Our nightly builds should have the updates that would work for CentOS 7
https://copr.fedorainfracloud.org/coprs/g/cloud-init/cloud-init-dev/

There is a side-effect of the above fix that I hadn't accounted for on Copr centos 6 where /etc/os-release exists but is an empty file.

There is a subsequent bug that, when fixed, should work on most redhat/cent images.
watch this bug fix for notification of cent6 fixes.
https://bugs.launchpad.net/cloud-init/+bug/1781229

Changed in cloud-init:
status: New → Triaged
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers