cloud-init is calling localedef (and getting killed)

Bug #2038945 reported by Dave Jones
14
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Ubuntu Image
Fix Released
Critical
Łukasz Zemczak
cloud-init (Ubuntu)
Fix Released
High
James Falcon

Bug Description

With the current "final" mantic Ubuntu server for raspi arm64 images, on the pi boards with 512MB of RAM (specifically the 3A+ and the Zero 2W), cloud-init's attempt to call localedef on first boot results in localedef getting OOM killed (with ~150MB of RAM under its belt), with the consequence that cloud-config.service fails and rather important tasks like creating the default user (or more precisely setting its password) go unfinished.

The cloud config in question does not specify anything for the locale module, and as far as I can tell neither does the default cloud-init configuration, so why is it calling localedef?

Dave Jones (waveform)
tags: added: raspi-image
Revision history for this message
Dave Jones (waveform) wrote :
Revision history for this message
Dave Jones (waveform) wrote :
Revision history for this message
Dave Jones (waveform) wrote :
Chad Smith (chad.smith)
Changed in cloud-init (Ubuntu):
importance: Undecided → Critical
assignee: nobody → James Falcon (falcojr)
Revision history for this message
Ubuntu QA Website (ubuntuqa) wrote :

This bug has been reported on the Ubuntu ISO testing tracker.

A list of all reports related to this bug can be found here:
https://iso.qa.ubuntu.com/qatracker/reports/bugs/2038945

tags: added: iso-testing
Revision history for this message
Łukasz Zemczak (sil2100) wrote :

Would be really good to understand when this started happening, since this cycle we for instance switched to use ubuntu-image 3.0 for building the image - so I'm of course thinking if maybe the way we prepare the cloud-init configuration could be wrong or something. Or is it cloud-init itself changing behavior?

Revision history for this message
Łukasz Zemczak (sil2100) wrote :

(by the image I mean the pi images)

Revision history for this message
Steve Langasek (vorlon) wrote :

Two pieces to this. The raspi images are generated with ubuntu-image rather than the legacy livecd-rootfs code; but the legacy livecd-rootfs code includes this fixup in live-build/auto/build:

        case $PROJECT:${SUBPROJECT:-} in
                ubuntu-server:*|ubuntu-cpc:*|ubuntu:desktop-preinstalled|ubuntu-
wsl:*)
                        # Set locale to C.UTF-8 by default. We should
                        # probably do this for all images early in the
                        # 18.10 cycle but for now just do it for
                        # server and cpc products.
                        echo "LANG=C.UTF-8" > chroot/etc/default/locale
                        ;;
        esac

Instead, the Pi image has:

$ cat /mnt/etc/default/locale
# File generated by update-locale
$

So there is no default locale set.

This is wrong, because when there is no locale set in the environment, glibc defaults to C instead of C.UTF-8 and we do not want to ever anywhere be using ASCII as our default character set instead of UTF-8. (I *think* this is still the meaning of 'POSIX' as a locale in glibc. If 'POSIX' does now map to C.UTF-8, then it's not actually wrong but as we don't know that's the case and haven't de-configured the other images, we should for the time being assume glibc is wrong and make sure our images enforce the intended default.)

It is also wrong that, when no locale is configured in the target, cloud-init decides the default should be en_US.UTF-8. cloud-init should ALSO default to C.UTF-8, which is statically available in our glibc package, instead of generating an en_US.UTF-8 locale.

Changed in ubuntu-image:
importance: Undecided → Critical
Changed in cloud-init (Ubuntu):
importance: Critical → High
Revision history for this message
Steve Langasek (vorlon) wrote :

jiggling severities - ubuntu-image can be fixed for release, cloud-init is not something we want to change Tuesday of release week.

Changed in ubuntu-image:
assignee: nobody → Łukasz Zemczak (sil2100)
status: New → In Progress
Revision history for this message
Dave Jones (waveform) wrote :

A few additional notes on this:

In answer to Łukasz's question of when this started, presumably at the point we started building the pi images with ubuntu-image instead of livecd-rootfs. However, this specific failure (OOM killed) didn't occur in the beta so I suspect we were "sailing close to the wind" with memory during localedef and just about got away with it. That brings me onto...

I've implemented a workaround for this; in the OOM output you can see the next biggest process is multipathd which is something we simply don't care about on Pi. I've added "multipath=off" to the classic pi-gadget to disable running multipathd on boot (without actually removing the package or changing our seeds) and this frees up enough that the initial boot succeeds on both Pi Zero 2W and 3A+. So, we're still sailing close to the wind with localedef and ideally wouldn't be running it at all, but if the images are re-spun with that change they will at least survive first boot ... until someone runs localedef with other things loaded :)

Revision history for this message
Alberto Contreras (aciba) wrote :

The cloud-init part is being addressed in the following upstream PR: https://github.com/canonical/cloud-init/pull/4503

Changed in cloud-init (Ubuntu):
status: New → In Progress
Paul Mars (upils)
Changed in ubuntu-image:
status: In Progress → Fix Committed
James Falcon (falcojr)
Changed in cloud-init (Ubuntu):
status: In Progress → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package cloud-init - 23.4~3g0cb0b80f-0ubuntu1

---------------
cloud-init (23.4~3g0cb0b80f-0ubuntu1) noble; urgency=medium

  * d/p/do-not-block-user-login.patch:
    - Revert behavior, allow user login after cloud-init stage (LP: #2039505)
  * d/control: add python3-apt as Recommends to read APT config from apt_pkg
  * drop the following cherry-picks now included:
    + d/p/cpick-0d9f149a-Pytestify-apt-config-test-modules-4424
    + d/p/cpick-5023e9f9-Refactor-test_apt_source_v1.py-to-use-pytest-4427
    + d/p/cpick-e9cdd7e3-Install-gnupg-if-gpg-not-found-4431
    + d/p/cpick-015543d3-apt-install-software-properties-common-when-absent-but
  * Upstream snapshot based on upstream/main at 0cb0b80f.
    - Bugs fixed in this snapshot: (LP: #2034273, #2030729)
      (LP: #2038945, #2039453)

 -- Chad Smith <email address hidden> Wed, 08 Nov 2023 22:24:09 -0700

Changed in cloud-init (Ubuntu):
status: Fix Committed → Fix Released
Paul Mars (upils)
Changed in ubuntu-image:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.