status breaks backwards compat with exit code 2 when recoverable errors/warnings
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
cloud-init (Ubuntu) |
Fix Released
|
Undecided
|
Alberto Contreras | ||
Focal |
Fix Released
|
Undecided
|
Alberto Contreras | ||
Jammy |
Fix Released
|
Undecided
|
Alberto Contreras | ||
Lunar |
Won't Fix
|
Undecided
|
Alberto Contreras | ||
Mantic |
Fix Released
|
Undecided
|
Alberto Contreras |
Bug Description
[ Impact ]
`cloud-init status` introduced a new exit code of 2 with the meaning of recoverable errors / warnings.
Without this fix, status exited with 2 in cases where previously did it with 0, potentially breaking consumers (scripts or other programs) of `cloud-init status`.
The fix is to include a quilt patch retaining the exit code of 0 for recoverable errors / warnings for stable releases.
[ Test Plan ]
```sh
#!/usr/bin/bash -ux
NAME=lp2048522
RELEASE=jammy
# This cloud-config includes a deprecated key which is a recoverable warning
cat <<EOF > /tmp/user-data
#cloud-config
apt_update: false
EOF
lxc delete -f $NAME 2>/dev/null || true
lxc launch ubuntu-
sleep 1
lxc exec $NAME -- cloud-init status --wait
lxc exec $NAME -- sh -c 'cat <<EOF >"/etc/
# Install proposed cloud-init, clean and reboot
deb http://
EOF'
lxc exec $NAME -- sh -c "apt update && apt install cloud-init/
lxc exec $NAME -- cloud-init --version
lxc exec $NAME -- cloud-init clean --logs --reboot
sleep 2
lxc exec $NAME -- cloud-init status --wait
if lxc exec $NAME -- cloud-init status --long --format json; then
echo Test passed
exit 0
else
echo Test not passed
exit 1
fi
```
[ Where problems could occur ]
* Limited risk, as the quilt patch is a one liner substituting the exit code of 2 by 0.
[ Original description ]
Taken from https:/
In the cases where there are recoverable warnings/errors, users checking status by exit code will start failing without changes on their end to accommodate the new behavior. We suspect this will be an issue for deployments where some of the warnings/errors are considered "normal".
Consider a customer using the Ubuntu minimal images (on Azure) which is currently missing "eject" and an error is being emitted. I believe if cloud-init 23.4 rolls out as-is, the status checks will start failing 100% of the time.
```
cpatterson@
status: done
cpatterson@
2
cpatterson@
/usr/bin/cloud-init 23.4-0ubuntu1~
cpatterson@
{
"_schema_
"boot_
"datasource": "azure",
"detail": "DataSourceAzure [seed=/dev/sr0]",
"errors": [],
"extended_
"init": {
"errors": [],
"finished": 1704494973.501599,
"recoverabl
"start": 1704494969.534187
},
"init-local": {
"errors": [],
"finished": 1704494968.0249393,
"recoverabl
"ERROR": [
"Failed ejecting the provisioning iso: Unexpected error while running command.\nCommand: ['eject', '/dev/sr0']\nExit code: -\nReason: [Errno 2] No such file or directory: b'eject'\nStdout: -\nStderr: -"
]
},
"start": 1704494956.9926035
},
"last_update": "Fri, 05 Jan 2024 22:49:35 +0000",
"modules-config": {
"errors": [],
"finished": 1704494975.1977916,
"recoverabl
"start": 1704494974.6474068
},
"modules-final": {
"errors": [],
"finished": 1704494975.8049285,
"recoverabl
"start": 1704494975.5019412
},
"recoverable_
"ERROR": [
"Failed ejecting the provisioning iso: Unexpected error while running command.\nCommand: ['eject', '/dev/sr0']\nExit code: -\nReason: [Errno 2] No such file or directory: b'eject'\nStdout: -\nStderr: -"
]
},
"schemas": {
"1": {
"
"datasource": "azure",
"detail": "DataSourceAzure [seed=/dev/sr0]",
"errors": [],
"
"init": {
"errors": [],
"finished": 1704494973.501599,
"start": 1704494969.534187
},
"init-local": {
"errors": [],
"finished": 1704494968.0249393,
"ERROR": [
"Failed ejecting the provisioning iso: Unexpected error while running command.\nCommand: ['eject', '/dev/sr0']\nExit code: -\nReason: [Errno 2] No such file or directory: b'eject'\nStdout: -\nStderr: -"
]
},
"start": 1704494956.9926035
},
"
"
"errors": [],
"finished": 1704494975.1977916,
"start": 1704494974.6474068
},
"
"errors": [],
"finished": 1704494975.8049285,
"start": 1704494975.5019412
},
"
"ERROR": [
"Failed ejecting the provisioning iso: Unexpected error while running command.\nCommand: ['eject', '/dev/sr0']\nExit code: -\nReason: [Errno 2] No such file or directory: b'eject'\nStdout: -\nStderr: -"
]
},
"stage": null,
"status": "done"
}
},
"stage": null,
"status": "done"
}
```
Changed in cloud-init (Ubuntu Focal): | |
status: | Triaged → In Progress |
Changed in cloud-init (Ubuntu Jammy): | |
status: | Triaged → In Progress |
Changed in cloud-init (Ubuntu Lunar): | |
status: | Triaged → In Progress |
description: | updated |
description: | updated |
description: | updated |
tags: | added: verification-failed verification-failed-focal verification-failed-jammy verification-failed-mantic |
tags: |
added: verification-done verification-done-focal verification-done-jammy verification-done-mantic removed: verification-needed verification-needed-focal verification-needed-jammy verification-needed-mantic |
I mark the current devel release as `Fix Committed` but no fix is required as this is a new behavior that we want to patch out for stable releases.