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] Don't attempt to restart disabled services #944

Merged
merged 1 commit into from
Jun 12, 2020
Merged
Changes from all 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
35 changes: 34 additions & 1 deletion config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,32 @@ def _abort_if_false(ctx, param, value):
if not value:
ctx.abort()


def _get_disabled_services_list():
disabled_services_list = []

config_db = ConfigDBConnector()
config_db.connect()
feature_table = config_db.get_table('FEATURE')
if feature_table is not None:
for feature_name in feature_table.keys():
if not feature_name:
log_warning("Feature is None")
continue

status = feature_table[feature_name]['status']
if not status:
log_warning("Status of feature '{}' is None".format(feature_name))
continue

if status == "disabled":
disabled_services_list.append(feature_name)
else:
log_warning("Unable to retreive FEATURE table")

return disabled_services_list


def _stop_services():
# on Mellanox platform pmon is stopped by syncd
services_to_stop = [
Expand All @@ -514,6 +540,7 @@ def _stop_services():

execute_systemctl(services_to_stop, SYSTEMCTL_ACTION_STOP)


def _reset_failed_services():
services_to_reset = [
'bgp',
Expand All @@ -534,8 +561,8 @@ def _reset_failed_services():
'sflow',
'restapi'
]
execute_systemctl(services_to_reset, SYSTEMCTL_ACTION_RESET_FAILED)

execute_systemctl(services_to_reset, SYSTEMCTL_ACTION_RESET_FAILED)


def _restart_services():
Expand All @@ -555,6 +582,12 @@ def _restart_services():
'restapi'
]

disable_services = _get_disabled_services_list()

for service in disable_services:
if service in services_to_restart:
services_to_restart.remove(service)

if asic_type == 'mellanox' and 'pmon' in services_to_restart:
services_to_restart.remove('pmon')

Expand Down