canonical / canonical/cloud-init
Silent failure: config-package_update_upgrade_install crashes but not reported in cloud-init analyze or result.json
- Dominant language
- Python
- Stars
- 3.8k
- Forks
- 1.1k
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 18
Description
# Bug report
`config-package_update_upgrade_install` fails during execution (apt package install), but the failure is not reported in `cloud-init analyze`, `cloud-init status`, or `/run/cloud-init/result.json`. This makes automated failure detection unreliable and hides provisioning issues unless the user manually inspects logs.
## Steps to reproduce the problem
1. Launch an Ubuntu-based WSL2 instance with cloud-init installed.
2. Use a `cloud-config` file with `packages:` directive, e.g.:
```yaml
#cloud-config
packages:
- ca-certificates
- ansible
- tree
- bind9-dnsutils
```
3. Run:
```bash
sudo cloud-init clean --logs
sudo cloud-init init
sudo cloud-init modules --mode=config
sudo cloud-init modules --mode=final
```
4. Observe that `apt-get install` fails (exit code 100), visible in `/var/log/cloud-init.log` with a full traceback.
5. However:
* `cloud-init analyze show` reports the module as successful.
* `/run/cloud-init/result.json` contains no errors.
* `cloud-init status --wait` exits with code 0.
* `cloud-init analyze blame` does not flag the failed module.
## Environment details
* **Cloud-init version:** `23.4.2` (via Ubuntu WSL2 apt repo)
* **Operating System Distribution:** Ubuntu 22.04 running in WSL2
* **Cloud provider, platform or installer type:** Local WSL2 setup with cloud-init manually installed and run
## cloud-init logs
Relevant excerpt from `/var/log/cloud-init.log`:
```
2025-07-02 14:40:50,199 - log_util.py[WARNING]: Failure when attempting to install packages: ['ca-certificates', 'ansible', 'tree', 'bind9-dnsutils']
2025-07-02 14:40:50,200 - log_util.py[DEBUG]: Failure when attempting to install packages: ['ca-certificates', 'ansible', 'tree', 'bind9-dnsutils']
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/cloudinit/config/cc_package_update_upgrade_install.py", line 92, in handle
cloud.distro.install_packages(pkglist)
File "/usr/lib/python3/dist-packages/cloudinit/distros/__init__.py", line 268, in install_packages
failed = manager.install_packages(to_try)
...
cloudinit.subp.ProcessExecutionError: Unexpected error while running command.
Command: ['eatmydata', 'apt-get', '--option=Dpkg::Options::=--force-confold', ...]
Exit code: 100
```
Yet the `cloud-init analyze` output shows:
```
|`->running config-package_update_upgrade_install with frequency once-per-instance @05.06600s +301.62900s
```
No indication of failure is reported.
Contributor guide
Assessment
This issue has not been assessed yet.