-
Notifications
You must be signed in to change notification settings - Fork 1.8k
[services] Fix Delay Start of SNMP And Telemetry #5211
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,11 +42,12 @@ def obfuscate(data): | |
|
|
||
|
|
||
| def update_feature_state(feature_name, state): | ||
| feature_suffix = "timer" if feature_name in ["snmp", "telemetry"] else "service" | ||
| if state == "enabled": | ||
| start_cmds = [] | ||
| start_cmds.append("sudo systemctl unmask {}.service".format(feature_name)) | ||
| start_cmds.append("sudo systemctl enable {}.service".format(feature_name)) | ||
| start_cmds.append("sudo systemctl start {}.service".format(feature_name)) | ||
| start_cmds.append("sudo systemctl unmask {}.{}".format(feature_name, feature_suffix)) | ||
| start_cmds.append("sudo systemctl enable {}.{}".format(feature_name, feature_suffix)) | ||
| start_cmds.append("sudo systemctl start {}.{}".format(feature_name, feature_suffix)) | ||
| for cmd in start_cmds: | ||
| syslog.syslog(syslog.LOG_INFO, "Running cmd: '{}'".format(cmd)) | ||
| try: | ||
|
|
@@ -55,12 +56,12 @@ def update_feature_state(feature_name, state): | |
| syslog.syslog(syslog.LOG_ERR, "'{}' failed. RC: {}, output: {}" | ||
| .format(err.cmd, err.returncode, err.output)) | ||
| continue | ||
| syslog.syslog(syslog.LOG_INFO, "Feature '{}' is enabled and started".format(feature_name)) | ||
| syslog.syslog(syslog.LOG_INFO, "Feature '{}.{}' is enabled and started".format(feature_name, feature_suffix)) | ||
| elif state == "disabled": | ||
| stop_cmds = [] | ||
| stop_cmds.append("sudo systemctl stop {}.service".format(feature_name)) | ||
| stop_cmds.append("sudo systemctl disable {}.service".format(feature_name)) | ||
| stop_cmds.append("sudo systemctl mask {}.service".format(feature_name)) | ||
| stop_cmds.append("sudo systemctl stop {}.{}".format(feature_name, feature_suffix)) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When stopping the service, if the service has a .timer file, I believe we need to stop both the timer AND the service. If the timer has already started the service, we need to stop the service. If the timer is currently running and hasn't started the service, we need to stop the timer. Thus, we should always stop both to be safe. |
||
| stop_cmds.append("sudo systemctl disable {}.{}".format(feature_name, feature_suffix)) | ||
| stop_cmds.append("sudo systemctl mask {}.{}".format(feature_name, feature_suffix)) | ||
| for cmd in stop_cmds: | ||
| syslog.syslog(syslog.LOG_INFO, "Running cmd: '{}'".format(cmd)) | ||
| try: | ||
|
|
@@ -71,7 +72,8 @@ def update_feature_state(feature_name, state): | |
| continue | ||
| syslog.syslog(syslog.LOG_INFO, "Feature '{}' is stopped and disabled".format(feature_name)) | ||
| else: | ||
| syslog.syslog(syslog.LOG_ERR, "Unexpected state value '{}' for feature '{}'".format(state, feature_name)) | ||
| syslog.syslog(syslog.LOG_ERR, "Unexpected state value '{}' for feature '{}.{}'" | ||
| .format(state, feature_name, feature_suffix)) | ||
|
|
||
|
|
||
| class Iptables(object): | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.