From 9fda2b980e195d6d0477fc716102b43d4b985bfd Mon Sep 17 00:00:00 2001 From: Sudharsan Dhamal Gopalarathnam Date: Tue, 21 Sep 2021 23:14:16 +0000 Subject: [PATCH 1/2] Handle feature flow when state is always_enabled --- src/sonic-host-services/scripts/hostcfgd | 1 + 1 file changed, 1 insertion(+) diff --git a/src/sonic-host-services/scripts/hostcfgd b/src/sonic-host-services/scripts/hostcfgd index 95c8e1221407..b178f265142a 100755 --- a/src/sonic-host-services/scripts/hostcfgd +++ b/src/sonic-host-services/scripts/hostcfgd @@ -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" From 69dbba970ea5b0ee852daf046ee06d22283d3cd3 Mon Sep 17 00:00:00 2001 From: Sudharsan Dhamal Gopalarathnam Date: Wed, 22 Sep 2021 00:10:04 +0000 Subject: [PATCH 2/2] Enhancing tests to cover this scenario --- .../tests/hostcfgd/test_vectors.py | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/sonic-host-services/tests/hostcfgd/test_vectors.py b/src/sonic-host-services/tests/hostcfgd/test_vectors.py index f70e4a11c457..aaba66b64e4a 100644 --- a/src/sonic-host-services/tests/hostcfgd/test_vectors.py +++ b/src/sonic-host-services/tests/hostcfgd/test_vectors.py @@ -146,6 +146,15 @@ "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 @@ "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 @@ 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')