cloud-init-local.service messages not written to /var/log/cloud-init.log in systemd
| Affects | Status | Importance | Assigned to | Milestone | |
|---|---|---|---|---|---|
| cloud-init |
Fix Released
|
Medium
|
Unassigned | ||
| cloud-init (Ubuntu) |
Fix Released
|
Medium
|
Unassigned | ||
| Xenial |
Fix Released
|
Medium
|
Unassigned | ||
| Yakkety |
Fix Released
|
Medium
|
Scott Moser | ||
Bug Description
=== Begin SRU Template ===
[Impact]
Cloud-init's logging is inconsistent due to availability of syslog during
boot.
Cloud-init logs to /var/log/
a way that was originally designed to prefer to use syslog if it was
available, and then fall back to writing directly to that file.
Over time this has been shown to be problematic.
a.) it relied on syslog during boot, and on some distros it wasn't
present.
b.) sometimes it would not be available during cloud-init-
and then would be during cloud-init.service. The result was that
the log would have two different time stamp formats (one written
by rsyslog and one by python logging).
c.) if rsyslog was used, micro seconds were not included in the log.
d.) since the move to systemd, there has even been times when cloud-init's
attempt to determine if syslog was available would false-positive.
that would result logging not being written to the file at all.
Over all, the complexity was just not found to worth the benefit.
[Test Case]
* Launch an instance.
* Look at /var/log/
on start, the cloud-int process logs a message like
'Cloud-init v 0.7.8 running'
Look at those messages specifically. In the example here (lxd), neither
cloud-
# grep Cloud-init /var/log/
Dec 2 18:06:56 y2 [CLOUDINIT] util.py[DEBUG]: Cloud-init v. 0.7.8 running 'modules:config' at 2016年12月02日 18:06:56 +0000. Up 5.0 seconds.
Dec 2 18:06:58 y2 [CLOUDINIT] util.py[DEBUG]: Cloud-init v. 0.7.8 running 'modules:final' at 2016年12月02日 18:06:58 +0000. Up 7.0 seconds.
Dec 2 18:06:58 y2 [CLOUDINIT] util.py[DEBUG]: Cloud-init v. 0.7.8 finished at 2016年12月02日 18:06:58 +0000. Datasource DataSourceNoCloud [seed=/
* update to proposed, cleanup reboot
# enable propose and update
# cleanup
sudo rm -Rf /var/log/
sudo reboot
* login again and look.
This time, all messages will have the format:
2016年12月02日 17:58:43,175 - util.py[DEBUG]: Cloud-init v. 0.7.8 running 'init-local' at 2016年12月02日 17:58:43 +0000. Up 13.73 seconds.
And you will have one for each 'init-local', 'init', 'modules:config' and
modules:final.
[Regression Potential]
Users relying on cloud-init writing entries to syslog will lose that.
[Other Info]
=== End SRU Template ===
output of cloud-init-
The result is that there is no output in /var/log/
There is some information in https:/
about how this occurrs and how it used to work.
copying part of that here:
Cloud-init's logging basically employed a "try syslog and fallback to direct log to file".
The proposed "just log to a file" is definitely dramatically simpler and advantageous in some cases.
The way the "try syslog and fallback" works (or worked) on Ubuntu up until systemd was:
a.) cloud-init init --local
1. read logging config,
2. attempt to log to syslog ([ *log_base, *log_syslog ])
3. that fail, so it log to file directly
b.) cloud-init init
1.) rsyslog would have /dev/log up functional at this point
2.) cloud-init logging config read and ends up logging to syslog
Systemd changed some things in teh way /dev/log was handled, and the above no longer worked well.
Additionally, cloud-init installs a file /etc/rsyslog.
The value of doing this in this way was that we use syslog, so if the user had configured the system to log remotely, cloud-init's logs would go to that remote system as they desired.
If we directly log to a file, then cloud-init's log messages will not without further configuration go to syslog.
One other thing to be aware of is that cloud-init can itself configure rsyslog through cloudinit/
Related branches
- cloud-init Commiters: Pending requested
-
Diff: 38 lines (+12/-4) 1 file modifiedapiconfig/cloud.cfg.d/05_logging.cfg (+12/-4)
I'm going to merge https:/
That will mean that by default cloud-init.service does nto send output to rsyslog, but we'll get consistent timestamps in /var/log/
This is fixed in cloud-init 0.7.9.
Hello Scott, or anyone else affected,
Accepted cloud-init into yakkety-proposed. The package will build now and be available at https:/
Please help us by testing this new package. See https:/
If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, and change the tag from verification-needed to verification-done. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-
Further information regarding the verification process can be found at https:/
$ lxc launch ubuntu-
$ sleep 10
$ lxc exec y1 /bin/bash
% head -n 1 /var/log/
Jan 20 15:17:35 y1 [CLOUDINIT] util.py[DEBUG]: Cloud-init v. 0.7.8 running 'modules:config' at 2017年1月20日 15:17:34 +0000. Up 11.0 seconds.
% dpkg-query --show cloud-init
cloud-init 0.7.8-49-
% cat /etc/cloud/
build_name: server
serial: 20170114
% m=http://
% echo "deb $m $(lsb_release -sc)-proposed main" > /etc/apt/
% apt update -q
% apt install cloud-init
% dpkg-query --show cloud-init
cloud-init 0.7.8-68-
# keep seed dir for lxd datasource
% ( cd /var/lib/cloud && for d in *; do [ "$d" = "seed" ] && continue; rm -Rf "$d"; done )
% rm -Rf /var/log/cloud*
% reboot
$ lxc exec y1 /bin/bash
% head -n 1 /var/log/
2017年01月20日 15:23:16,213 - util.py[DEBUG]: Cloud-init v. 0.7.8 running 'init-local' at 2017年1月20日 15:23:16 +0000. Up 1.0 seconds.
removed: verification-needed
The verification of the Stable Release Update for cloud-init has completed successfully and the package has now been released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regressions.
This bug was fixed in the package cloud-init - 0.7.8-68-
---------------
cloud-init (0.7.8-
* debian/cherry-pick: add utility for cherry picking commits from upstream
into patches in debian/patches.
* New upstream snapshot.
- mounts: use mount -a again to accomplish mounts (LP: #1647708)
- CloudSigma: Fix bug where datasource was not loaded in local search.
(LP: #1648380)
- when adding a user, strip whitespace from group list
[Lars Kellogg-Stedman] (LP: #1354694)
- fix decoding of utf-8 chars in yaml test
- Replace usage of sys_netdev_info with read_sys_net (LP: #1625766)
- fix problems found in python2.6 test.
- OpenStack: extend physical types to include hyperv, hw_veb, vhost_user.
(LP: #1642679)
- tests: fix assumptions that expected no eth0 in system. (LP: #1644043)
- net/cmdline: Consider ip= or ip6= on command line not only ip=
(LP: #1639930)
- Just use file logging by default [Joshua Harlow] (LP: #1643990)
- Improve formatting for ProcessExecutio
- flake8: fix trailing white space
- Doc: various documentation fixes [Sean Bright]
- cloudinit/
[Brent Baude]
- packages/redhat: fix rpm spec file.
- main: set TZ in environment if not already set. [Ryan Harper]
- disk_setup: Use sectors as unit when formatting MBR disks with sfdisk.
[Daniel Watkins] (LP: #1460715)
-- Scott Moser <email address hidden> 2016年12月19日 15:07:12 -0500
Hello Scott, or anyone else affected,
Accepted cloud-init into xenial-proposed. The package will build now and be available at https:/
Please help us by testing this new package. See https:/
If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, and change the tag from verification-needed to verification-done. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-
Further information regarding the verification process can be found at https:/
Hello Scott, or anyone else affected,
Accepted cloud-init into xenial-proposed. The package will build now and be available at https:/
Please help us by testing this new package. See https:/
If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, and change the tag from verification-needed to verification-done. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-
Further information regarding the verification process can be found at https:/
$ release=xenial
$ lxc launch ubuntu-
$ lxc exec $name -- dpkg-query --show cloud-init
cloud-init 0.7.8-49-
$ lxc file pull $name/etc/
build_name: server
serial: 20170207
$ lxc exec $name -- head -n 1 /var/log/
Feb 9 02:26:04 x1 [CLOUDINIT] util.py[DEBUG]: Cloud-init v. 0.7.8 running 'modules:config' at 2017年2月09日 02:26:03 +0000. Up 9.0 seconds.
## enable proposed, update
$ m=http://
$ echo "deb $m $release-proposed main" | lxc file push - $name/etc/
$ lxc exec $name -- sh -c 'apt-get update -q && apt-get install cloud-init' </dev/null
$ lxc exec $name -- dpkg-query --show cloud-init
cloud-init 0.7.9-0ubuntu1~
# clean up to make it look like first boot.
$ lxc exec $name -- sh -c 'cd /var/lib/cloud; for d in *; do [ "$d" = "seed" ] || rm -vRf "$d"; done'
$ lxc exec $name -- sh -c 'rm -f /var/log/cloud*'
$ lxc restart $name
$ lxc exec $name -- grep WARN /var/log/
no warn
$ lxc exec $name -- head -n 1 /var/log/
2017年02月09日 02:29:15,960 - util.py[DEBUG]: Cloud-init v. 0.7.9 running 'init-local' at 2017年2月09日 02:29:15 +0000. Up 1.0 seconds.
removed: verification-needed
This bug was fixed in the package cloud-init - 0.7.9-0ubuntu1~
---------------
cloud-init (0.7.9-
* debian/
cloud-init (0.7.9-
* debian/copyright: update License field to include Apache.
* debian/
has CONFIG_XEN=y (LP: #1379080).
* debian/
walinux agent in stable release.
* New upstream release.
- doc: adjust headers in tests documentation for consistency.
- pep8: fix issue found in zesty build with pycodestyle.
- integration test: initial commit of integration test framework
[Wesley Wiedenmeier]
- LICENSE: Allow dual licensing GPL-3 or Apache 2.0 [Jon Grimm]
- Fix config order of precedence, putting kernel command line over system.
[Wesley Wiedenmeier] (LP: #1582323)
- pep8: whitespace fix [Scott Moser]
- Update the list of valid ssh keys. [Michael Felt]
- network: add ENI unit test for statically rendered routes.
- set_hostname: avoid erroneously appending domain to fqdn
[Lars Kellogg-Stedman] (LP: #1647910)
- doc: change 'nobootwait' to 'nofail' in docs [Anhad Jai Singh]
- Replace an expired bit.ly link in code comment. [Joshua Harlow]
- user-groups: fix bug when groups was provided as string and had spaces
[Scott Moser] (LP: #1354694)
- when adding a user, strip whitespace from group list
[Lars Kellogg-Stedman] (LP: #1354694)
- fix decoding of utf-8 chars in yaml test
- Replace usage of sys_netdev_info with read_sys_net
[Joshua Harlow] (LP: #1625766)
- fix problems found in python2.6 test. [Joshua Harlow]
- Just use file logging by default [Joshua Harlow] (LP: #1643990)
- Improve formatting for ProcessExecutio
- flake8: fix trailing white space
- Doc: various documentation fixes [Sean Bright]
- cloudinit/
[Brent Baude]
- packages/redhat: fix rpm spec file.
- main: set TZ in environment if not already set. [Ryan Harper]
-- Scott Moser <email address hidden> 2017年2月06日 16:18:28 -0500
Tracked in Github Issues as https:/