Skip to content

Commit

Permalink
tests: conditionally reset-failed snapd.failure.service
Browse files Browse the repository at this point in the history
I've ran across a test failure caused by attempt to use systemctl to
reset the failed status of a service that was not loaded due to being
masked.

    + systemctl reset-failed snapd.service snapd.socket snapd.failure.service
    Failed to reset failed state of unit snapd.failure.service: Unit
    snapd.failure.service not loaded.

Use systemctl status as a way to check if a service is known before
attempting to reset it.

Signed-off-by: Zygmunt Krynicki <[email protected]>
  • Loading branch information
zyga authored and Meulengracht committed Sep 17, 2024
1 parent 91bc7cb commit b605298
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions tests/lib/prepare-restore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -786,9 +786,13 @@ restore_suite_each() {
done

if [[ "$variant" = full ]]; then
# reset the failed status of snapd, snapd.socket, and snapd.failure.socket
# to prevent hitting the system restart rate-limit for these services
systemctl reset-failed snapd.service snapd.socket snapd.failure.service
# Reset the failed status of snapd, snapd.socket, and snapd.failure.socket
# to prevent hitting the system restart rate-limit for these services.
systemctl reset-failed snapd.service snapd.socket
# This unit may not be present, it is masked on some systems.
if systemctl status snapd.failure.service; then
systemctl reset-failed snapd.failure.service
fi
fi

if [[ "$variant" = full ]]; then
Expand Down

0 comments on commit b605298

Please sign in to comment.