`charmcraft build` sometimes fails on `apt install` inside the lxd container
Metadata
Current evaluation
Closed as a duplicate of #567; its dpkg-lock fix merged via PR #745 (commit b1adccd5), adding provider warmup to avoid competing APT updates.
Resolution: closed superseded
Reason: Maintainer facundobatista explicitly marked #647 as a duplicate of #567. PR #745 merged as commit b1adccd5 and added provider warmup support, preventing automatic container APT updates from racing later apt-get operations.
Evaluated by: mr-cal-bot
No scores available.
Issue body
It seems like it might be `unattended-upgrades` might be getting in the way:
```
E: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 563 (apt-get)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?
```
Longer log:
```
Executing in container: lxc --project charmcraft exec local:charmcraft-ceph-rbd-mirror-258104-0-0-amd64 -- env PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin CHARMCRAFT_MANAGED_MODE=1 apt-get install -y apt-utils
:: 2022-02-01 20:00:30.065 Requested build-packages: ['git', 'python3-dev', 'python3-pip', 'python3-setuptools', 'python3-venv', 'python3-wheel', 'tox']
3-pip', 'python3-setuptools', 'python3-venv', 'python3-wheel', 'tox'] - (2.2s)
3-pip', 'python3-setuptools', 'python3-venv', 'python3-wheel', 'tox'] \ (2.3s)
3-pip', 'python3-setuptools', 'python3-venv', 'python3-wheel', 'tox'] | (2.4s)
3-pip', 'python3-setuptools', 'python3-venv', 'python3-wheel', 'tox'] / (2.7s)
3-pip', 'python3-setuptools', 'python3-venv', 'python3-wheel', 'tox'] - (2.8s)
3-pip', 'python3-setuptools', 'python3-venv', 'python3-wheel', 'tox']
:: 2022-02-01 20:00:32.908 Marking python3-pip (and its dependencies) to be fetched
:: 2022-02-01 20:00:32.910 package: python3-pip
:: 2022-02-01 20:00:32.957 Marking git (and its dependencies) to be fetched
:: 2022-02-01 20:00:32.958 package: git
:: 2022-02-01 20:00:33.008 Marking python3-venv (and its dependencies) to be fetched
:: 2022-02-01 20:00:33.011 package: python3-venv
:: 2022-02-01 20:00:33.046 Marking python3-setuptools (and its dependencies) to be fetched
:: 2022-02-01 20:00:33.047 package: python3-setuptools
:: 2022-02-01 20:00:33.068 Marking python3-wheel (and its dependencies) to be fetched
:: 2022-02-01 20:00:33.068 package: python3-wheel
:: 2022-02-01 20:00:33.103 Marking tox (and its dependencies) to be fetched
:: 2022-02-01 20:00:33.104 package: tox
:: 2022-02-01 20:00:33.159 Marking python3-dev (and its dependencies) to be fetched
:: 2022-02-01 20:00:33.160 package: python3-dev
:: 2022-02-01 20:00:33.266 Installing packages: git=1:2.25.1-1ubuntu3.2 git-man=1:2.25.1-1ubuntu3.2 libasn1-8-heimdal=7.7.0+dfsg-1ubuntu1 libbrotli1=1.0.7-6ubuntu0.1 libcurl3-gnutls=7.68.0-1ubuntu2.7 liberror-perl=0.17029-1 libexpat1-dev=2.2.9-1build1 libgssapi3-heimdal=7.7.0+dfsg-1ubuntu1 libhcrypto4-heimdal=7.7.0+dfsg-1ubuntu1 libheimbase1-heimdal=7.7.0+dfsg-1ubuntu1 libheimntlm0-heimdal=7.7.0+dfsg-1ubuntu1 libhx509-5-heimdal=7.7.0+dfsg-1ubuntu1 libjs-jquery=3.3.1~dfsg-3 libjs-sphinxdoc=1.8.5-7ubuntu3 libjs-underscore=1.9.1~dfsg-1ubuntu0.20.04.1 libkrb5-26-heimdal=7.7.0+dfsg-1ubuntu1 libldap-2.4-2=2.4.49+dfsg-2ubuntu1.8 libldap-common=2.4.49+dfsg-2ubuntu1.8 libnghttp2-14=1.40.0-1build1 libpsl5=0.21.0-1ubuntu1 libpython3-dev=3.8.2-0ubuntu2 libpython3.8=3.8.10-0ubuntu1~20.04.2 libpython3.8-dev=3.8.10-0ubuntu1~20.04.2 libroken18-heimdal=7.7.0+dfsg-1ubuntu1 librtmp1=2.4+20151223.gitfa8646d.1-2build1 libsasl2-2=2.1.27+dfsg-2 libsasl2-modules-db=2.1.27+dfsg-2 libssh-4=0.9.3-2ubuntu2.2 libwind0-heimdal=7.7.0+dfsg-1ubuntu1 python-pip-whl=20.0.2-5ubuntu1.6 python3-appdirs=1.4.3-2.1 python3-dev=3.8.2-0ubuntu2 python3-distlib=0.3.0-1 python3-distutils=3.8.10-0ubuntu1~20.04 python3-filelock=3.0.12-2 python3-importlib-metadata=1.5.0-1 python3-lib2to3=3.8.10-0ubuntu1~20.04 python3-more-itertools=4.2.0-1build1 python3-packaging=20.3-1 python3-pip=20.0.2-5ubuntu1.6 python3-pkg-resources=45.2.0-1 python3-pluggy=0.13.0-2 python3-py=1.8.1-1ubuntu0.1 python3-pyparsing=2.4.6-1 python3-setuptools=45.2.0-1 python3-six=1.14.0-2 python3-toml=0.10.0-3 python3-venv=3.8.2-0ubuntu2 python3-virtualenv=20.0.17-1ubuntu0.4 python3-wheel=0.34.2-1 python3-zipp=1.0.0-1 python3.8-dev=3.8.10-0ubuntu1~20.04.2 python3.8-venv=3.8.10-0ubuntu1~20.04.2 tox=3.13.2-2 virtualenv=20.0.17-1ubuntu0.4 zlib1g-dev=1:1.2.11.dfsg-2ubuntu1.2
:: 2022-02-01 20:00:33.342 :: E: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 563 (apt-get)
:: 2022-02-01 20:00:33.343 :: E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?
:: 2022-02-01 20:00:33.345 Parts processing error: Cannot install all requested build packages: git=1:2.25.1-1ubuntu3.2, git-man=1:2.25.1-1ubuntu3.2, libasn1-8-heimdal=7.7.0+dfsg-1ubuntu1, libbrotli1=1.0.7-6ubuntu0.1, libcurl3-gnutls=7.68.0-1ubuntu2.7, liberror-perl=0.17029-1, libexpat1-dev=2.2.9-1build1, libgssapi3-heimdal=7.7.0+dfsg-1ubuntu1, libhcrypto4-heimdal=7.7.0+dfsg-1ubuntu1, libheimbase1-heimdal=7.7.0+dfsg-1ubuntu1, libheimntlm0-heimdal=7.7.0+dfsg-1ubuntu1, libhx509-5-heimdal=7.7.0+dfsg-1ubuntu1, libjs-jquery=3.3.1~dfsg-3, libjs-sphinxdoc=1.8.5-7ubuntu3, libjs-underscore=1.9.1~dfsg-1ubuntu0.20.04.1, libkrb5-26-heimdal=7.7.0+dfsg-1ubuntu1, libldap-2.4-2=2.4.49+dfsg-2ubuntu1.8, libldap-common=2.4.49+dfsg-2ubuntu1.8, libnghttp2-14=1.40.0-1build1, libpsl5=0.21.0-1ubuntu1, libpython3-dev=3.8.2-0ubuntu2, libpython3.8=3.8.10-0ubuntu1~20.04.2, libpython3.8-dev=3.8.10-0ubuntu1~20.04.2, libroken18-heimdal=7.7.0+dfsg-1ubuntu1, librtmp1=2.4+20151223.gitfa8646d.1-2build1, libsasl2-2=2.1.27+dfsg-2, libsasl2-modules-db=2.1.27+dfsg-2, libssh-4=0.9.3-2ubuntu2.2, libwind0-heimdal=7.7.0+dfsg-1ubuntu1, python-pip-whl=20.0.2-5ubuntu1.6, python3-appdirs=1.4.3-2.1, python3-dev=3.8.2-0ubuntu2, python3-distlib=0.3.0-1, python3-distutils=3.8.10-0ubuntu1~20.04, python3-filelock=3.0.12-2, python3-importlib-metadata=1.5.0-1, python3-lib2to3=3.8.10-0ubuntu1~20.04, python3-more-itertools=4.2.0-1build1, python3-packaging=20.3-1, python3-pip=20.0.2-5ubuntu1.6, python3-pkg-resources=45.2.0-1, python3-pluggy=0.13.0-2, python3-py=1.8.1-1ubuntu0.1, python3-pyparsing=2.4.6-1, python3-setuptools=45.2.0-1, python3-six=1.14.0-2, python3-toml=0.10.0-3, python3-venv=3.8.2-0ubuntu2, python3-virtualenv=20.0.17-1ubuntu0.4, python3-wheel=0.34.2-1, python3-zipp=1.0.0-1, python3.8-dev=3.8.10-0ubuntu1~20.04.2, python3.8-venv=3.8.10-0ubuntu1~20.04.2, tox=3.13.2-2, virtualenv=20.0.17-1ubuntu0.4, zlib1g-dev=1:1.2.11.dfsg-2ubuntu1.2
:: 2022-02-01 20:00:33.352 Traceback (most recent call last):
:: 2022-02-01 20:00:33.352 File "/snap/charmcraft/x1/lib/craft_parts/packages/deb.py", line 467, in _install_packages
:: 2022-02-01 20:00:33.353 process_run(apt_command + package_names, env=env, stdin=subprocess.DEVNULL)
:: 2022-02-01 20:00:33.353 File "/snap/charmcraft/x1/lib/craft_parts/packages/deb.py", line 602, in process_run
:: 2022-02-01 20:00:33.354 os_utils.process_run(command, logger.debug, **kwargs)
:: 2022-02-01 20:00:33.354 File "/snap/charmcraft/x1/lib/craft_parts/utils/os_utils.py", line 360, in process_run
:: 2022-02-01 20:00:33.355 raise subprocess.CalledProcessError(ret, command)
:: 2022-02-01 20:00:33.355 subprocess.CalledProcessError: Command '['apt-get', '--no-install-recommends', '-y', '-oDpkg::Use-Pty=0', '--allow-downgrades', 'install', 'git=1:2.25.1-1ubuntu3.2', 'git-man=1:2.25.1-1ubuntu3.2', 'libasn1-8-heimdal=7.7.0+dfsg-1ubuntu1', 'libbrotli1=1.0.7-6ubuntu0.1', 'libcurl3-gnutls=7.68.0-1ubuntu2.7', 'liberror-perl=0.17029-1', 'libexpat1-dev=2.2.9-1build1', 'libgssapi3-heimdal=7.7.0+dfsg-1ubuntu1', 'libhcrypto4-heimdal=7.7.0+dfsg-1ubuntu1', 'libheimbase1-heimdal=7.7.0+dfsg-1ubuntu1', 'libheimntlm0-heimdal=7.7.0+dfsg-1ubuntu1', 'libhx509-5-heimdal=7.7.0+dfsg-1ubuntu1', 'libjs-jquery=3.3.1~dfsg-3', 'libjs-sphinxdoc=1.8.5-7ubuntu3', 'libjs-underscore=1.9.1~dfsg-1ubuntu0.20.04.1', 'libkrb5-26-heimdal=7.7.0+dfsg-1ubuntu1', 'libldap-2.4-2=2.4.49+dfsg-2ubuntu1.8', 'libldap-common=2.4.49+dfsg-2ubuntu1.8', 'libnghttp2-14=1.40.0-1build1', 'libpsl5=0.21.0-1ubuntu1', 'libpython3-dev=3.8.2-0ubuntu2', 'libpython3.8=3.8.10-0ubuntu1~20.04.2', 'libpython3.8-dev=3.8.10-0ubuntu1~20.04.2', 'libroken18-heimdal=7.7.0+dfsg-1ubuntu1', 'librtmp1=2.4+20151223.gitfa8646d.1-2build1', 'libsasl2-2=2.1.27+dfsg-2', 'libsasl2-modules-db=2.1.27+dfsg-2', 'libssh-4=0.9.3-2ubuntu2.2', 'libwind0-heimdal=7.7.0+dfsg-1ubuntu1', 'python-pip-whl=20.0.2-5ubuntu1.6', 'python3-appdirs=1.4.3-2.1', 'python3-dev=3.8.2-0ubuntu2', 'python3-distlib=0.3.0-1', 'python3-distutils=3.8.10-0ubuntu1~20.04', 'python3-filelock=3.0.12-2', 'python3-importlib-metadata=1.5.0-1', 'python3-lib2to3=3.8.10-0ubuntu1~20.04', 'python3-more-itertools=4.2.0-1build1', 'python3-packaging=20.3-1', 'python3-pip=20.0.2-5ubuntu1.6', 'python3-pkg-resources=45.2.0-1', 'python3-pluggy=0.13.0-2', 'python3-py=1.8.1-1ubuntu0.1', 'python3-pyparsing=2.4.6-1', 'python3-setuptools=45.2.0-1', 'python3-six=1.14.0-2', 'python3-toml=0.10.0-3', 'python3-venv=3.8.2-0ubuntu2', 'python3-virtualenv=20.0.17-1ubuntu0.4', 'python3-wheel=0.34.2-1', 'python3-zipp=1.0.0-1', 'python3.8-dev=3.8.10-0ubuntu1~20.04.2', 'python3.8-venv=3.8.10-0ubuntu1~20.04.2', 'tox=3.13.2-2', 'virtualenv=20.0.17-1ubuntu0.4', 'zlib1g-dev=1:1.2.11.dfsg-2ubuntu1.2']' returned non-zero exit status 100.
:: 2022-02-01 20:00:33.356
:: 2022-02-01 20:00:33.356 The above exception was the direct cause of the following exception:
:: 2022-02-01 20:00:33.357 Traceback (most recent call last):
:: 2022-02-01 20:00:33.357 File "/snap/charmcraft/x1/lib/charmcraft/parts.py", line 320, in run
:: 2022-02-01 20:00:33.357 with self._lcm.action_executor() as aex:
:: 2022-02-01 20:00:33.357 File "/snap/charmcraft/x1/lib/craft_parts/executor/executor.py", line 253, in __enter__
:: 2022-02-01 20:00:33.357 self._executor.prologue()
:: 2022-02-01 20:00:33.357 File "/snap/charmcraft/x1/lib/craft_parts/executor/executor.py", line 86, in prologue
:: 2022-02-01 20:00:33.357 self._install_build_packages()
:: 2022-02-01 20:00:33.363 File "/snap/charmcraft/x1/lib/craft_parts/executor/executor.py", line 196, in _install_build_packages
:: 2022-02-01 20:00:33.363 packages.Repository.install_packages(sorted(build_packages))
:: 2022-02-01 20:00:33.363 File "/snap/charmcraft/x1/lib/craft_parts/packages/deb.py", line 436, in install_packages
:: 2022-02-01 20:00:33.363 cls._install_packages(packages)
:: 2022-02-01 20:00:33.364 File "/snap/charmcraft/x1/lib/craft_parts/packages/deb.py", line 469, in _install_packages
:: 2022-02-01 20:00:33.365 raise errors.BuildPackagesNotInstalled(packages=package_names) from err
:: 2022-02-01 20:00:33.365 craft_parts.packages.errors.BuildPackagesNotInstalled: Cannot install all requested build packages: git=1:2.25.1-1ubuntu3.2, git-man=1:2.25.1-1ubuntu3.2, libasn1-8-heimdal=7.7.0+dfsg-1ubuntu1, libbrotli1=1.0.7-6ubuntu0.1, libcurl3-gnutls=7.68.0-1ubuntu2.7, liberror-perl=0.17029-1, libexpat1-dev=2.2.9-1build1, libgssapi3-heimdal=7.7.0+dfsg-1ubuntu1, libhcrypto4-heimdal=7.7.0+dfsg-1ubuntu1, libheimbase1-heimdal=7.7.0+dfsg-1ubuntu1, libheimntlm0-heimdal=7.7.0+dfsg-1ubuntu1, libhx509-5-heimdal=7.7.0+dfsg-1ubuntu1, libjs-jquery=3.3.1~dfsg-3, libjs-sphinxdoc=1.8.5-7ubuntu3, libjs-underscore=1.9.1~dfsg-1ubuntu0.20.04.1, libkrb5-26-heimdal=7.7.0+dfsg-1ubuntu1, libldap-2.4-2=2.4.49+dfsg-2ubuntu1.8, libldap-common=2.4.49+dfsg-2ubuntu1.8, libnghttp2-14=1.40.0-1build1, libpsl5=0.21.0-1ubuntu1, libpython3-dev=3.8.2-0ubuntu2, libpython3.8=3.8.10-0ubuntu1~20.04.2, libpython3.8-dev=3.8.10-0ubuntu1~20.04.2, libroken18-heimdal=7.7.0+dfsg-1ubuntu1, librtmp1=2.4+20151223.gitfa8646d.1-2build1, libsasl2-2=2.1.27+dfsg-2, libsasl2-modules-db=2.1.27+dfsg-2, libssh-4=0.9.3-2ubuntu2.2, libwind0-heimdal=7.7.0+dfsg-1ubuntu1, python-pip-whl=20.0.2-5ubuntu1.6, python3-appdirs=1.4.3-2.1, python3-dev=3.8.2-0ubuntu2, python3-distlib=0.3.0-1, python3-distutils=3.8.10-0ubuntu1~20.04, python3-filelock=3.0.12-2, python3-importlib-metadata=1.5.0-1, python3-lib2to3=3.8.10-0ubuntu1~20.04, python3-more-itertools=4.2.0-1build1, python3-packaging=20.3-1, python3-pip=20.0.2-5ubuntu1.6, python3-pkg-resources=45.2.0-1, python3-pluggy=0.13.0-2, python3-py=1.8.1-1ubuntu0.1, python3-pyparsing=2.4.6-1, python3-setuptools=45.2.0-1, python3-six=1.14.0-2, python3-toml=0.10.0-3, python3-venv=3.8.2-0ubuntu2, python3-virtualenv=20.0.17-1ubuntu0.4, python3-wheel=0.34.2-1, python3-zipp=1.0.0-1, python3.8-dev=3.8.10-0ubuntu1~20.04.2, python3.8-venv=3.8.10-0ubuntu1~20.04.2, tox=3.13.2-2, virtualenv=20.0.17-1ubuntu0.4, zlib1g-dev=1:1.2.11.dfsg-2ubuntu1.2
:: 2022-02-01 20:00:33.365 Full execution log: '/root/snap/charmcraft/common/cache/charmcraft/log/charmcraft-20220201-200029.985793.log'
```
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| stealth/space-bunny-alpha | — | closed superseded | Closed as a duplicate of #567; its dpkg-lock fix merged via PR #745 (commit b1adccd5), adding provider warmup to avoid competing APT updates. | |
| stealth/space-bunny-alpha | — | closed superseded | Closed as a duplicate of canonical/charmcraft#567, where automatic APT cache updates in containers caused dpkg lock contention; resolved by merged PR #745 and commit b1adccd5. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Closed as a duplicate of issue #567. The report details intermittent apt-get lock failures during charmcraft build inside LXD containers, suspected to be caused by unattended-upgrades. | |
| qwen/qwen3.6-35b-a3b | — | — | Closed as a duplicate of issue #567. The report details intermittent apt install failures in charmcraft build caused by dpkg lock conflicts, likely triggered by unattended-upgrades. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Closed as duplicate of #567. Report details intermittent apt install failures inside charmcraft LXD containers from dpkg lock conflicts, likely unattended-upgrades. Tracking and resolution moved to the referenced duplicate. |
Update history
No update history recorded yet.
Related work
-
Duplicate Of:
charmcraft#567
(confidence 100%)
A maintainer explicitly closed #647 as a duplicate of this earlier dpkg-lock issue.
-
Likely Fixed By:
charmcraft#745
(confidence 98%)
Merged as commit b1adccd5 to add provider warmup and avoid APT-update lock contention in build containers.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #511 `charmcraft pack` fails running `apt update` | charmcraft | closed | Closed with no Charmcraft code change: maintainers determined the `apt update` failure came from a broken host/LXD (fan bridge) networking setup, not a Charmcraft bug; guidance posted to Charmhub Discourse and the LXD forum. | |
| #1594 Running `charmcraft pack` fails and returns `Instance setup failed. Check LXD logs for more details` | charmcraft | closed | Closed as an environment conflict, not a Charmcraft defect: Docker had changed networking in a way that interfered with LXD, and the reporter confirmed that uninstalling Docker and restarting fixed it. | |
| #660 `charmcraft pack` fails with error writing to lxd unix socket | charmcraft | closed | A transient LXD socket timeout stopped packing; `charmcraft clean` restored operation, the error did not recur, and the reporter closed the report without a code fix. | |
| #925 providers: set lxd project to 'charmcraft' | charmcraft | merged | Merged PR #925 in d82b9bb8, fixing the LXD provider regression by using the charmcraft project instead of default. | |
| #823 more transparency for container build in first charmcraft pack | charmcraft | closed | Firewall-blocked LXD setup hung `charmcraft pack` indefinitely on instance network setup. No charmcraft change needed; maintainer tracked the missing timeout in craft-providers and closed the issue. | |
| #1260 Charmcraft hangs or fails with LXD 5.18 | charmcraft | closed | LXD released a fix for the 5.18 image lookup failure; Charmcraft’s separate edge retry hang was fixed by craft-providers#415 (commit da95d03). | |
| #507 charmcraft pack fails for apt-utils is not available | charmcraft | closed | Closed as an environment conflict: Docker altered iptables and blocked LXD networking, preventing apt-utils installation. | |
| #736 `charmcraft` lxc container starts failing with `FileNotFoundError` during iterative design | charmcraft | closed | Closed as unreproducible on Charmcraft 2.7/3; the maintainer requested a current reproducer. No fix PR or commit was linked. | |
| #560 Charmcraft pack is giving error frequently | charmcraft | closed | The failure was traced to external LXD networking blocking access to archive.ubuntu.com during snapd installation; no Charmcraft fix was merged, and the reported firewall workaround did not help. | |
| #815 charmcraft pack fails - connection timed out could not connect | charmcraft | closed | User-reported charmcraft pack failure was a local host/network problem (archive.ubuntu.com/security.ubuntu.com unreachable during apt cache update in the LXD build container). Author rebooted their machine and packing worked again, then self-closed the issue. |