Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[config] Call 'systemctl reset-failed' before 'systemctl restart' when restarting services #607

Merged
merged 3 commits into from
Aug 20, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,8 @@ def _stop_services():
]
for service in services:
try:
run_command("systemctl stop %s" % service, display_cmd=True)
click.echo("Stopping {} ...".format(service))
run_command("systemctl stop {}".format(service))
except SystemExit as e:
log_error("Stopping {} failed with error {}".format(service, e))
raise
Expand All @@ -315,7 +316,11 @@ def _restart_services():
]
for service in services:
try:
run_command("systemctl restart %s" % service, display_cmd=True)
# We first run "systemctl reset-failed" to ensure that we
# can restart the service, even if it has entered a failed state
click.echo("Restarting {} ...".format(service))
run_command("systemctl reset-failed {}".format(service))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume the error code returned by reset-failed if the services is not in failed state, doesn't trigger the exception. Looks good to me otherwise.

Copy link
Contributor Author

@jleveque jleveque Aug 14, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calling systemctl reset-failed on a service not in a failed state will still return 0. There should be no issues.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great. Thank you for fixing this.

run_command("systemctl restart {}".format(service))
except SystemExit as e:
log_error("Restart {} failed with error {}".format(service, e))
raise
Expand Down