Skip to content

Commit b2659dc

Browse files
authored
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.
1 parent ada8043 commit b2659dc

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

src/sonic-host-services/scripts/hostcfgd

+1
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ class FeatureHandler(object):
180180
disable = feature.state in ("always_disabled", "disabled")
181181
elif cached_feature.state in ("always_enabled", "always_disabled"):
182182
disable = feature.state == "always_disabled"
183+
enable = feature.state == "always_enabled"
183184
elif cached_feature.state in ("enabled", "disabled"):
184185
enable = feature.state == "enabled"
185186
disable = feature.state == "disabled"

src/sonic-host-services/tests/hostcfgd/test_vectors.py

+21
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,15 @@
146146
"state": "enabled",
147147
"status": "enabled"
148148
},
149+
"sflow": {
150+
"auto_restart": "enabled",
151+
"has_global_scope": "True",
152+
"has_per_asic_scope": "False",
153+
"has_timer": "False",
154+
"high_mem_alert": "disabled",
155+
"set_owner": "local",
156+
"state": "always_enabled"
157+
},
149158
},
150159
},
151160
"expected_config_db": {
@@ -178,6 +187,15 @@
178187
"state": "enabled",
179188
"status": "enabled"
180189
},
190+
"sflow": {
191+
"auto_restart": "enabled",
192+
"has_global_scope": "True",
193+
"has_per_asic_scope": "False",
194+
"has_timer": "False",
195+
"high_mem_alert": "disabled",
196+
"set_owner": "local",
197+
"state": "always_enabled"
198+
},
181199
},
182200
},
183201
"expected_subprocess_calls": [
@@ -188,6 +206,9 @@
188206
call("sudo systemctl unmask telemetry.timer", shell=True),
189207
call("sudo systemctl enable telemetry.timer", shell=True),
190208
call("sudo systemctl start telemetry.timer", shell=True),
209+
call("sudo systemctl unmask sflow.service", shell=True),
210+
call("sudo systemctl enable sflow.service", shell=True),
211+
call("sudo systemctl start sflow.service", shell=True),
191212
],
192213
"popen_attributes": {
193214
'communicate.return_value': ('output', 'error')

0 commit comments

Comments
 (0)