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 2 commits
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
12 changes: 10 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 @@ -313,9 +314,16 @@ def _restart_services():
'lldp',
'hostcfgd',
]

# We first run "systemctl reset-failed" to remove the "failed"
# status from all services before we attempt to restart them
click.echo("Resetting all failed services ...")
run_command("systemctl reset-failed")
Copy link
Contributor

Choose a reason for hiding this comment

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

The concern I have is that this could possibly reset more services than the ones on the list we are meant to handle. Not sure if this is correct or desirable.

Choose a reason for hiding this comment

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

so maybe change approach to reset counter per service ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes I believe that approach would be better.


for service in services:
try:
run_command("systemctl restart %s" % service, display_cmd=True)
click.echo("Restarting {} ...".format(service))
run_command("systemctl restart {}".format(service))
except SystemExit as e:
log_error("Restart {} failed with error {}".format(service, e))
raise
Expand Down