Handle feature flow when state is always_enabled (#8811)
Why I did it When feature state is set to always_enabled hostcfgd throws error message Sep 21 22:30:55.135377 r-leopard-32 ERR /hostcfgd: Unexpected state value 'always_enabled' for feature bgp Sep 21 22:30:55.420268 r-leopard-32 ERR /hostcfgd: Unexpected state value 'always_enabled' for feature database Sep 21 22:30:58.672714 r-leopard-32 ERR /hostcfgd: Unexpected state value 'always_enabled' for feature swss This is due to feature == always_enabled not handled properly. How I did it Handled the scenario when feature is always enabled How to verify it Restart hostcfgd with feature state configured as always_enabled and check if there are no errors. Added UT to cover the scenario.
This commit is contained in:
parent
8832792a28
commit
e09bb5b2f6
@ -180,6 +180,7 @@ class FeatureHandler(object):
|
||||
disable = feature.state in ("always_disabled", "disabled")
|
||||
elif cached_feature.state in ("always_enabled", "always_disabled"):
|
||||
disable = feature.state == "always_disabled"
|
||||
enable = feature.state == "always_enabled"
|
||||
elif cached_feature.state in ("enabled", "disabled"):
|
||||
enable = feature.state == "enabled"
|
||||
disable = feature.state == "disabled"
|
||||
|
@ -146,6 +146,15 @@ HOSTCFGD_TEST_VECTOR = [
|
||||
"state": "enabled",
|
||||
"status": "enabled"
|
||||
},
|
||||
"sflow": {
|
||||
"auto_restart": "enabled",
|
||||
"has_global_scope": "True",
|
||||
"has_per_asic_scope": "False",
|
||||
"has_timer": "False",
|
||||
"high_mem_alert": "disabled",
|
||||
"set_owner": "local",
|
||||
"state": "always_enabled"
|
||||
},
|
||||
},
|
||||
},
|
||||
"expected_config_db": {
|
||||
@ -178,6 +187,15 @@ HOSTCFGD_TEST_VECTOR = [
|
||||
"state": "enabled",
|
||||
"status": "enabled"
|
||||
},
|
||||
"sflow": {
|
||||
"auto_restart": "enabled",
|
||||
"has_global_scope": "True",
|
||||
"has_per_asic_scope": "False",
|
||||
"has_timer": "False",
|
||||
"high_mem_alert": "disabled",
|
||||
"set_owner": "local",
|
||||
"state": "always_enabled"
|
||||
},
|
||||
},
|
||||
},
|
||||
"expected_subprocess_calls": [
|
||||
@ -188,6 +206,9 @@ HOSTCFGD_TEST_VECTOR = [
|
||||
call("sudo systemctl unmask telemetry.timer", shell=True),
|
||||
call("sudo systemctl enable telemetry.timer", shell=True),
|
||||
call("sudo systemctl start telemetry.timer", shell=True),
|
||||
call("sudo systemctl unmask sflow.service", shell=True),
|
||||
call("sudo systemctl enable sflow.service", shell=True),
|
||||
call("sudo systemctl start sflow.service", shell=True),
|
||||
],
|
||||
"popen_attributes": {
|
||||
'communicate.return_value': ('output', 'error')
|
||||
|
Loading…
Reference in New Issue
Block a user