canonical / canonical/cloud-init

runcmd considers the exit code for the last command only

Open
#7,037 2 comments 0 reactions 0 assignees View on GitHub
bug new
Dominant language
Python
Stars
3.8k
Forks
1.1k
Avg merge
2d 23h
Merged PRs (30d)
18

Description

# Bug report
When using runmd, the last command in that list will determine the result of the runcmd
step. If the last command fails, cloud-init will report an error. If the last command
succeeds, all the previous command may fail, and cloud-init still reports success.

This is an inconsistency that I couldn't find in the documentation.

## Steps to reproduce the problem
Use the following cloud-init config to see cloud-init report success:
```
#cloud-config
runcmd:
- /bin/false
- /bin/true
```

Use the following cloud-init config to see cloud-init report failure:
```
#cloud-config
runcmd:
- /bin/true
- /bin/false
```

## Environment details
- Cloud-init version: 26.1-0ubuntu2
- Operating System Distribution: Ubuntu 26.04
- Cloud provider, platform or installer type: lxd

## cloud-init logs

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the two configurations in the issue, using /bin/false and /bin/true in opposite orders, and trace the cloud-init runcmd step that reports completion. Identify how command results are collected and add regression coverage for both orderings. Done means the step's reported result consistently reflects the intended handling of failures, with the behavior documented in the tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
infrastructure
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.