Skip to content

Commit fad481e

Browse files
authored
Enhanced Feature table to support 'always_enabled' value for state and auto-restart fields. (#6000)
Added new flag value 'always_enabled' for the state and auto-restart field of feature table init_cfg.json is updated to initialize state field of database/swss/syncd/teamd feature and auto-restart field of database feature as always_enabled Once the state/auto-restart value is initialized as "always_enabled" it is immutable and cannot be change via feature config commands. (config feature..) PR#sonic-net/sonic-utilities#1271 hostcfgd will not take any action if state field value is 'always_enabled' Since we have always_enabled field for auto-restart updated supervisor-proc-exit-listener not to have special check for database and always rely on value from Feature table.
1 parent 7fca9f6 commit fad481e

File tree

3 files changed

+27
-24
lines changed

3 files changed

+27
-24
lines changed

files/build_templates/init_cfg.json.j2

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@
1818
}
1919
},
2020
{%- set features = [("bgp", "enabled", false, "enabled"),
21-
("database", "enabled", false, "disabled"),
21+
("database", "always_enabled", false, "always_enabled"),
2222
("dhcp_relay", "enabled", false, "enabled"),
2323
("lldp", "enabled", false, "enabled"),
2424
("pmon", "enabled", false, "enabled"),
2525
("radv", "enabled", false, "enabled"),
2626
("snmp", "enabled", true, "enabled"),
27-
("swss", "enabled", false, "enabled"),
28-
("syncd", "enabled", false, "enabled"),
29-
("teamd", "enabled", false, "enabled")] %}
27+
("swss", "always_enabled", false, "enabled"),
28+
("syncd", "always_enabled", false, "enabled"),
29+
("teamd", "always_enabled", false, "enabled")] %}
3030
{%- if sonic_asic_platform == "vs" %}{% do features.append(("gbsyncd", "enabled", false, "enabled")) %}{% endif %}
3131
{%- if include_iccpd == "y" %}{% do features.append(("iccpd", "disabled", false, "enabled")) %}{% endif %}
3232
{%- if include_mgmt_framework == "y" %}{% do features.append(("mgmt-framework", "enabled", true, "enabled")) %}{% endif %}

files/scripts/supervisor-proc-exit-listener

+19-20
Original file line numberDiff line numberDiff line change
@@ -77,27 +77,26 @@ def main(argv):
7777
groupname = payload_headers['groupname']
7878

7979
# Read the status of auto-restart feature from Config_DB.
80-
if container_name != 'database':
81-
config_db = swsssdk.ConfigDBConnector()
82-
config_db.connect()
83-
features_table = config_db.get_table(FEATURE_TABLE_NAME)
84-
if not features_table:
85-
syslog.syslog(syslog.LOG_ERR, "Unable to retrieve features table from Config DB. Exiting...")
86-
sys.exit(2)
87-
88-
if container_name not in features_table:
89-
syslog.syslog(syslog.LOG_ERR, "Unable to retrieve feature '{}'. Exiting...".format(container_name))
90-
sys.exit(3)
91-
92-
restart_feature = features_table[container_name].get('auto_restart')
93-
if not restart_feature:
94-
syslog.syslog(syslog.LOG_ERR, "Unable to determine auto-restart feature status for '{}'. Exiting...".format(container_name))
95-
sys.exit(4)
96-
97-
# If container is database or auto-restart feature is enabled and at the same time
80+
config_db = swsssdk.ConfigDBConnector()
81+
config_db.connect()
82+
features_table = config_db.get_table(FEATURE_TABLE_NAME)
83+
if not features_table:
84+
syslog.syslog(syslog.LOG_ERR, "Unable to retrieve features table from Config DB. Exiting...")
85+
sys.exit(2)
86+
87+
if container_name not in features_table:
88+
syslog.syslog(syslog.LOG_ERR, "Unable to retrieve feature '{}'. Exiting...".format(container_name))
89+
sys.exit(3)
90+
91+
restart_feature = features_table[container_name].get('auto_restart')
92+
if not restart_feature:
93+
syslog.syslog(syslog.LOG_ERR, "Unable to determine auto-restart feature status for '{}'. Exiting...".format(container_name))
94+
sys.exit(4)
95+
96+
# If auto-restart feature is not disabled and at the same time
9897
# a critical process exited unexpectedly, terminate supervisor
99-
if ((container_name == 'database' or restart_feature == 'enabled') and expected == 0 and
100-
(processname in critical_process_list or groupname in critical_group_list)):
98+
if (restart_feature != 'disabled' and expected == 0 and
99+
(processname in critical_process_list or groupname in critical_group_list)):
101100
MSG_FORMAT_STR = "Process {} exited unxepectedly. Terminating supervisor..."
102101
msg = MSG_FORMAT_STR.format(payload_headers['processname'])
103102
syslog.syslog(syslog.LOG_INFO, msg)

src/sonic-host-services/scripts/hostcfgd

+4
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,10 @@ class HostConfigDaemon:
252252

253253

254254
def update_feature_state(self, feature_name, state, feature_table):
255+
if state == "always_enabled":
256+
syslog.syslog(syslog.LOG_INFO, "Feature '{}' service is always enabled"
257+
.format(feature_name))
258+
return
255259
has_timer = ast.literal_eval(feature_table[feature_name].get('has_timer', 'False'))
256260
has_global_scope = ast.literal_eval(feature_table[feature_name].get('has_global_scope', 'True'))
257261
has_per_asic_scope = ast.literal_eval(feature_table[feature_name].get('has_per_asic_scope', 'False'))

0 commit comments

Comments
 (0)