During build time mask only those feature/services that are disabled excplicitly (#13283)
What I did: Fix : #13117 How I did: During build time mask only those feature/services that are disabled explicitly. Some of the features ((eg: teamd/bgp/dhcp-relay/mux/etc..)) state is determine run-time so for those feature by default service will be up and running and then later hostcfgd will mask them if needed. So Default behavior will be init_cfg.json.j2 during build time make state as disabled then mask the service init_cfg.json.j2 during build time make state as another jinja2 template render string than do no mask the service init_cfg.json.j2 during build time make state as enabled then do not mask the service How I verify: Manual Verification. Signed-off-by: Abhishek Dosi <abdosi@microsoft.com>
This commit is contained in:
parent
2c02a76d4f
commit
9ecd27ddbb
@ -4,10 +4,20 @@ import json
|
||||
import subprocess
|
||||
|
||||
INIT_CFG_FILE_PATH = '/etc/sonic/init_cfg.json'
|
||||
WARM_OR_FAST_BOOT_DATAPLANE_NEEDED_SERVICES = ['database', 'swss', 'syncd', 'teamd', 'bgp']
|
||||
|
||||
with open(INIT_CFG_FILE_PATH) as init_cfg_file:
|
||||
init_cfg = json.load(init_cfg_file)
|
||||
if 'FEATURE' in init_cfg:
|
||||
for feature_name, feature_props in init_cfg['FEATURE'].items():
|
||||
if 'state' in feature_props and feature_props['state'] != 'enabled' and feature_props['state'] != 'always_enabled':
|
||||
subprocess.run(['systemctl', 'mask', '{}.service'.format(feature_name)])
|
||||
# For warm/fast boot we want to have all crtical dataplane needed service
|
||||
# to start immediately before hostcfgd can render `state` field unless the `state` field is marked disabled
|
||||
# explicitly during build time rendering of init_cfg.json
|
||||
if feature_name in WARM_OR_FAST_BOOT_DATAPLANE_NEEDED_SERVICES:
|
||||
if 'state' in feature_props and (feature_props['state'] == 'disabled' or feature_props['state'] == 'always_disabled'):
|
||||
subprocess.run(['systemctl', 'mask', '{}.service'.format(feature_name)])
|
||||
# For other services by default mask out the service if not enable explicitly. This service can get enable later on when
|
||||
# hostcfgd render the state as enable. This should not cause dataplane impact.
|
||||
else:
|
||||
if 'state' in feature_props and feature_props['state'] != 'enabled' and feature_props['state'] != 'always_enabled':
|
||||
subprocess.run(['systemctl', 'mask', '{}.service'.format(feature_name)])
|
||||
|
Loading…
Reference in New Issue
Block a user