Skip to content

backport ESM fix for importlib error#6941

Merged
blackboxsw merged 2 commits into
canonical:ubuntu/bionicfrom
blackboxsw:ubuntu/bionic
Jul 24, 2026
Merged

backport ESM fix for importlib error#6941
blackboxsw merged 2 commits into
canonical:ubuntu/bionicfrom
blackboxsw:ubuntu/bionic

Conversation

@blackboxsw

@blackboxsw blackboxsw commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

CPC is looking to sync changes to ESM images for importlib errors seen on Pro images.
Backport upstream fix a97e746 as a quilt patch to ensure both focal and bionic get the destination patch.

Proposed Commit Message

Separate commits

* releasing cloud-init version 23.1.2-0ubuntu0~18.04.1+esm2

* fix: import specific importlib.util avoiding traces in pro auto-attach
    
    Use direct submodule import of importlib.util to avoid AttributeError
    tracebacks from ua-auto-attach.service on GCE.
    
    Backport-of: a97e7466
    Fixes GH-6924

Additional Context

As this is an ESM fix, this release will be reviewed by security team to be included in ESM infra PPA instead of typical Ubuntiu SRU process.
This upstream fix will make it into LTS releases via typical SRU process.

Test Steps

quilt push -a  # patches apply

lxc launch ubuntu-minimal:bionic b-min
lxc exec b-min -- pro attach <YOUR_TOKEN>
lxc exec b-min -- apt install ubuntu-pro-client cloud-init
lxc file push cloudinit/importer.py b-min/usr/lib/python3/dist-packages/cloudinit/
lxc exec b-min -- python3 /usr/lib/ubuntu-advantage/auto_attach.py   # confirm no traceback
quilt pop -a    # patched removed without issue

PPA for testing https://launchpad.net/~chad.smith/+archive/ubuntu/esm-test-pro-importlib

Merge type

  • Squash merge using "Proposed Commit Message"
  • Rebase and merge unique commits. Requires commit messages per-commit each referencing the pull request number (#<PR_NUM>)
  • git merge from command line after approval.

@blackboxsw
blackboxsw requested a review from holmanb July 17, 2026 13:45
@blackboxsw blackboxsw changed the title Ubuntu/bionic backport ESM fix for importlib error Jul 17, 2026
@github-actions github-actions Bot added the packaging Supplemental package review requested label Jul 17, 2026
@blackboxsw

Copy link
Copy Markdown
Collaborator Author

Manual verifcation performed: SUCCESS

cat > ESM.yaml <<EOF
#cloud-config
ubuntu_advantage:
  token: MY_TOKEN
EOF

cat > ESM.list <<EOF
deb [ allow-insecure=yes ] https://ppa.launchpadcontent.net/chad.smith/esm-backport-testing/ubuntu bionic main
EOF

lxc launch ubuntu-minimal:bionic b-esm-verification -c user.user-data="$(cat ESM_VALIDATION.yaml)"
lxc exec b-esm-verification -- cloud-init stauts --wait --format=yaml
lxc exec b-esm-verification -- apt install ubuntu-pro-client cloud-init -y  # latest ESM-released content

lxc exec b-esm-verification -- python3 /usr/lib/ubuntu-advantage/auto_attach.py   # confirm error
...
  File "/usr/lib/python3/dist-packages/cloudinit/mergers/__init__.py", line 134, in construct
    m_name, [__name__], [MERGER_ATTR]
  File "/usr/lib/python3/dist-packages/cloudinit/importer.py", line 52, in find_module
    if not importlib.util.find_spec(full_path):
AttributeError: module 'importlib' has no attribute 'util'


# install -proposed package from PPA
lxc file push ESM.list b-esm-verification/etc/apt/sources.list.d/

lxc exec b-esm-verification -- apt update
lxc exec b-esm-verification -- apt install cloud-init=23.1.2-0ubuntu0~18.04.1+esm2 --allow-unauthenticated -y
lxc exec b-esm-verification -- python3 /usr/lib/ubuntu-advantage/auto_attach.py   # confirm NO error
...
["2026-07-22T22:18:27.745", "INFO", "ubuntupro.lib.auto_attach", "main", 68, "cloud-init userdata has ubuntu-advantage key.", {}]
["2026-07-22T22:18:27.746", "INFO", "ubuntupro.lib.auto_attach", "main", 70, "Skipping auto-attach and deferring to cloud-init to setup and configure auto-attach", {}]
...

@blackboxsw
blackboxsw force-pushed the ubuntu/bionic branch 2 times, most recently from c8a2d8f to 323bcc1 Compare July 23, 2026 13:36
Use direct submodule import of importlib.util to avoid AttributeError
tracebacks from ua-auto-attach.service on GCE.

Backport-of: a97e746
Fixes canonicalGH-6924
@blackboxsw

Copy link
Copy Markdown
Collaborator Author

Bumping quilt patch to explicitly retain an import importlib for importlib.import_module calls.

@blackboxsw
blackboxsw merged commit 3a58ab0 into canonical:ubuntu/bionic Jul 24, 2026
3 of 23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

packaging Supplemental package review requested security

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants