cloud-init fails for minimal images (can't find locale-gen)

Bug #1759003 reported by Robert C Jennings on 2018-03-26
12
This bug affects 1 person
Affects Status Importance Assigned to Milestone
cloud-images
Undecided
Unassigned
livecd-rootfs (Ubuntu)
Undecided
Michael Hudson-Doyle
Xenial
Undecided
Unassigned

Bug Description

[Impact]

 * Locale is not set for cloud images and minimal images lack the locale-gen executable. This causes cloud-init to fail, however there is no need to call locale-gen if we set the locale.

 * Update minimal ubuntu-cpc images to set the locale to C.UTF-8 at build time.

[Test Case]

 * Launch the minimal cloud image and observe locale failure in cloud init log (/var/log/cloud-init.log)

 * Launch the minimal cloud image built with the proposed change and observer that user does not get a warning about locales on the terminal and cloud init log (/var/log/cloud-init.log) does not contain locale failures (also 'systemctl list-units --failed' will not list a cloud-init failure)

[Regression Potential]

 * There is no regression as this change is scoped to ubuntu-cpc minimal images only, which have not been announced.

=================

Original description:

Opening initially as a cloud-images bug to ensure that the lack of 'locale-gen' is desired. If so, then this should go to cloud-init to dtrt for minimal images.

Related branches

Robert C Jennings (rcj) wrote :

I launched a xenial minimal cloud-image (20180321) via LXD:

$ lxc remote add minimal-ubuntu-daily https://cloud-images.ubuntu.com/minimal/daily --protocol simplestreams

$ lxc image list minimal-ubuntu-daily
+-------+--------------+--------+---------------------------------------------+--------+---------+-------------------------------+
| ALIAS | FINGERPRINT | PUBLIC | DESCRIPTION | ARCH | SIZE | UPLOAD DATE |
+-------+--------------+--------+---------------------------------------------+--------+---------+-------------------------------+
| | 4278883fd349 | yes | ubuntu 16.04 LTS amd64 (daily) (20180321) | x86_64 | 92.16MB | Mar 21, 2018 at 12:00am (UTC) |

$ lxc launch minimal-ubuntu-daily:4278883fd349 x-min

Robert C Jennings (rcj) wrote :

Failure is:

2018-03-26 18:34:13,191 - stages.py[DEBUG]: Running module locale (<module 'cloudinit.config.cc_locale' from '/usr/lib/python3/dist-packages/cloudinit/config/cc_locale.py'>) with frequency once-per-instance
2018-03-26 18:34:13,191 - handlers.py[DEBUG]: start: modules-config/config-locale: running config-locale with frequency once-per-instance
2018-03-26 18:34:13,191 - util.py[DEBUG]: Writing to /var/lib/cloud/instances/x-min/sem/config_locale - wb: [644] 24 bytes
2018-03-26 18:34:13,192 - helpers.py[DEBUG]: Running config-locale using lock (<FileLock using file '/var/lib/cloud/instances/x-min/sem/config_locale'>)
2018-03-26 18:34:13,192 - cc_locale.py[DEBUG]: Setting locale to en_US.UTF-8
2018-03-26 18:34:13,192 - debian.py[DEBUG]: Generating locales for en_US.UTF-8
2018-03-26 18:34:13,192 - util.py[DEBUG]: Running command ['locale-gen', 'en_US.UTF-8'] with allowed return codes [0] (shell=False, capture=False)
2018-03-26 18:34:13,194 - handlers.py[DEBUG]: finish: modules-config/config-locale: FAIL: running config-locale with frequency once-per-instance
2018-03-26 18:34:13,194 - util.py[WARNING]: Running module locale (<module 'cloudinit.config.cc_locale' from '/usr/lib/python3/dist-packages/cloudinit/config/cc_locale.py'>) failed
2018-03-26 18:34:13,194 - util.py[DEBUG]: Running module locale (<module 'cloudinit.config.cc_locale' from '/usr/lib/python3/dist-packages/cloudinit/config/cc_locale.py'>) failed
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/cloudinit/util.py", line 1871, in subp
    env=env, shell=shell)
  File "/usr/lib/python3.5/subprocess.py", line 947, in __init__
    restore_signals, start_new_session)
  File "/usr/lib/python3.5/subprocess.py", line 1551, in _execute_child
    raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'locale-gen'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/cloudinit/stages.py", line 793, in _run_modules
    freq=freq)
  File "/usr/lib/python3/dist-packages/cloudinit/cloud.py", line 54, in run
    return self._runners.run(name, functor, args, freq, clear_on_fail)
  File "/usr/lib/python3/dist-packages/cloudinit/helpers.py", line 187, in run
    results = functor(*args)
  File "/usr/lib/python3/dist-packages/cloudinit/config/cc_locale.py", line 45, in handle
    cloud.distro.apply_locale(locale, locale_cfgfile)
  File "/usr/lib/python3/dist-packages/cloudinit/distros/debian.py", line 97, in apply_locale
    regenerate_locale(locale, out_fn, keyname=keyname)
  File "/usr/lib/python3/dist-packages/cloudinit/distros/debian.py", line 299, in regenerate_locale
    util.subp(['locale-gen', locale], capture=False)
  File "/usr/lib/python3/dist-packages/cloudinit/util.py", line 1877, in subp
    stderr="-" if decode else b"-")
cloudinit.util.ProcessExecutionError: Unexpected error while running command.
Command: ['locale-gen', 'en_US.UTF-8']
Exit code: -
Reason: [Errno 2] No such file or directory: 'locale-gen'
Stdout: -
Stderr: -

Changed in livecd-rootfs (Ubuntu):
assignee: nobody → Michael Hudson-Doyle (mwhudson)
status: New → In Progress
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package livecd-rootfs - 2.515

---------------
livecd-rootfs (2.515) bionic; urgency=medium

  * Set the default locale to C.UTF-8 in all server and cloud images.
   (LP: #1751051, #1759003)

 -- Michael Hudson-Doyle <email address hidden> Tue, 27 Mar 2018 09:59:02 +1300

Changed in livecd-rootfs (Ubuntu):
status: In Progress → Fix Released
tags: added: id-5ab93fb4f5bc0159b6998d14
Robert C Jennings (rcj) wrote :

mwhudson, if you're bringing this back to xenial could you ensure this affects ubuntu-cpc/minimized only but not the rest of ubuntu-cpc? We'd like that as a first pass.

Michael Hudson-Doyle (mwhudson) wrote :

I wasn't planning on doing the xenial back port myself, but I can if you want...

Robert C Jennings (rcj) wrote :

A back-port that affects ubuntu-cpc:minimized (but not non-minimized) would be great because cloud-init does explode in the minimal images without the fix. We just don't want to see a change in the standard images.

Robert C Jennings (rcj) on 2018-05-09
description: updated
Robie Basak (racb) wrote :

> There is no regression as this change is scoped to ubuntu-cpc minimal images only, which have not been announced.

This sounds reasonable, but please could you check during SRU verification that the change has correctly affected this subset of images only? It seems to be that the largest risk here is that the change ends up being wider than intended by accident.

Changed in livecd-rootfs (Ubuntu Xenial):
status: New → Fix Committed
tags: added: verification-needed verification-needed-xenial

Hello Robert, or anyone else affected,

Accepted livecd-rootfs into xenial-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/livecd-rootfs/2.408.30 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed.Your feedback will aid us getting this update out to other Ubuntu users.

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-xenial to verification-done-xenial. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-xenial. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

tags: added: id-5aea189ff2e03c354277099e
Dan Watkins (daniel-thewatkins) wrote :

I'm going to perform verification of this now.

I have just performed two livefs builds using the proposed version (i.e. 2.408.30), one with the minimized subproject and one without.

In the minimized image, /etc/default/locale contains "LANG=C.UTF-8". In the non-minimized image, it contains "# File generated by update-locale".

This looks as expected to me, but I'm performing a non-minimized build using the updates version (i.e. 2.408.29) to confirm that.

The -updates version produces the same content as the -proposed version for non-minimized builds.

tags: added: verification-done verification-done-xenial
removed: verification-needed verification-needed-xenial
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package livecd-rootfs - 2.408.30

---------------
livecd-rootfs (2.408.30) xenial; urgency=medium

  * Set the default locale to C.UTF-8 in minimized cloud images.
    (LP: #1759003)

 -- Robert C Jennings <email address hidden> Tue, 08 May 2018 11:32:29 -0500

Changed in livecd-rootfs (Ubuntu Xenial):
status: Fix Committed → Fix Released

The verification of the Stable Release Update for livecd-rootfs 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.

tags: added: id-5b21b1006874c4e4159dea3f
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers