diff --git a/src/sonic-ctrmgrd/ctrmgr/ctrmgrd.py b/src/sonic-ctrmgrd/ctrmgr/ctrmgrd.py index 7e85c22f60c8..645724214bfd 100755 --- a/src/sonic-ctrmgrd/ctrmgr/ctrmgrd.py +++ b/src/sonic-ctrmgrd/ctrmgr/ctrmgrd.py @@ -489,7 +489,9 @@ def handle_update(self, feat, set_owner, ct_owner, remote_state): service_restart = False if set_owner == "local": - if ct_owner != "local": + # NOTE: no need to restart if the current owner is none, + # as none implies the container is not running. + if ct_owner != "local" and ct_owner != "none": service_restart = True else: if (ct_owner != "none") and (remote_state == "pending"): diff --git a/src/sonic-ctrmgrd/tests/ctrmgrd_test.py b/src/sonic-ctrmgrd/tests/ctrmgrd_test.py index 76651309ce6a..df7e2729d566 100755 --- a/src/sonic-ctrmgrd/tests/ctrmgrd_test.py +++ b/src/sonic-ctrmgrd/tests/ctrmgrd_test.py @@ -355,6 +355,38 @@ } } } + }, + 5: { + common_test.DESCR: "No restart for current_owner == none in config reload", + common_test.ARGS: "ctrmgrd", + common_test.PRE: { + common_test.CONFIG_DB_NO: { + common_test.FEATURE_TABLE: { + "swss": { + "set_owner": "local", + "state": "enabled", + "auto_restart": "enabled" + } + } + } + }, + common_test.UPD: { + common_test.STATE_DB_NO: { + common_test.FEATURE_TABLE: { + "swss": { + "system_state": "down", + "remote_state": "none", + "current_owner": "none", + "container_id": "", + "state": "enabled" + } + } + } + }, + common_test.POST: { + common_test.STATE_DB_NO: { + } + } } }