Skip to content

Report failed upgrades with a non-zero exit status - #1115

Open
Amadeus-22 wants to merge 1 commit into
linuxmint:masterfrom
Amadeus-22:report-exit-status
Open

Amadeus-22 wants to merge 1 commit into
linuxmint:masterfrom
Amadeus-22:report-exit-status

Conversation

@Amadeus-22

Copy link
Copy Markdown
Contributor

Fixes #1107

Problem

A failed cache refresh or a failed apt-get still ends with exit status 0 everywhere: mint-refresh-cache prints an error and exits 0, mintupdate-cli ignores the status of both the refresh and apt-get, and system_automatic_upgrades.py ignores the result and always logs -- Automatic Upgrade completed. mintupdate-automation-upgrade.service is never marked failed, so runs like the ones in #1109 only show up in /var/log/mintupdate.log.

Fix

  • mint-refresh-cache: sys.exit(1) when the update fails or when run without admin privileges.
  • mintupdate-cli.py: exit with apt-get's status. If the refresh failed, the upgrade still runs on the current cache as before (one unreachable repository shouldn't block every update), but the exit status is 1 when apt-get succeeded.
  • system_automatic_upgrades.py: log -- Automatic Upgrade failed (exit N) and exit with that status. A run skipped on battery still exits 0.

Successful runs are unchanged.

How tested

  • tests/test_exit_status.py (cli exit status for each refresh/apt-get combination, mint-refresh-cache without root); /usr/bin/python3 -m unittest discover -s tests, 17 tests OK.
  • With a fake apt-get on PATH that exits 100, mintupdate-cli upgrade --dry-run exits 100 (0 on master). A real --dry-run still exits 0.
  • system_automatic_upgrades.py with its paths pointed at a temporary directory and a fake systemd-inhibit: exit 0 logs -- Automatic Upgrade completed and exits 0; exit 100 logs -- Automatic Upgrade failed (exit 100) and exits 100.

🤖 Generated with Claude Code

mint-refresh-cache, mintupdate-cli and system_automatic_upgrades.py all
exited with 0 when the cache refresh or apt-get failed, and the log
always ended with "-- Automatic Upgrade completed", so a failed
automatic upgrade looked like a successful one to systemd and to any
script (linuxmint#1107).

- mint-refresh-cache: Exit with 1 when the update fails or when it is
  run without admin privileges.
- mintupdate-cli.py: Exit with apt-get's status. When the refresh
  failed the upgrade still runs on the current cache as before, but the
  exit status is 1 if apt-get itself succeeded.
- system_automatic_upgrades.py: Log "-- Automatic Upgrade failed
  (exit N)" and exit with that status, so
  mintupdate-automation-upgrade.service is marked failed.

Successful runs are unchanged. Add tests/test_exit_status.py.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Report failed upgrades with a non-zero exit status (mintupdate-cli, mint-refresh-cache, automatic upgrades)

1 participant