hostcfgd: fix mgmtVrfEnabled state caching causing unnecessary interface restarts#400
Open
xhinhellhx wants to merge 1 commit into
Open
hostcfgd: fix mgmtVrfEnabled state caching causing unnecessary interface restarts#400xhinhellhx wants to merge 1 commit into
hostcfgd: fix mgmtVrfEnabled state caching causing unnecessary interface restarts#400xhinhellhx wants to merge 1 commit into
Conversation
…obal` table
The `MgmtIfaceCfg.load()` method was incorrectly reading `mgmtVrfEnabled`
directly from the top level of the `mgmt_vrf` dict, but the actual data
structure from ConfigDB is a full table dict keyed by row name
(e.g., `{'vrf_global': {'mgmtVrfEnabled': 'true'}}`).
This caused the internal cache to always be initialized to `''` (empty
string), `making update_mgmt_vrf()` detect a state change on
`config load` and unnecessarily restart the interfaces-config service.
The issue was discovered during repetitive execution of `config load -y`,
which caused unexpected SSH session teardowns as the networking stack
was being reconfigured unnecessarily.
Change the retrieval to access the nested `vrf_global` row following
the `sonic-mgmt_vrf` YANG model leaf path:
`/sonic-mgmt_vrf:sonic-mgmt_vrf/MGMT_VRF_CONFIG/vrf_global/mgmtVrfEnabled`
Signed-off-by: Andrew Bezzubtsev <xhinhellhx.sb@icloud.com>
|
|
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
Hi, there are workflow run(s) waiting for approval, you may be first-time contributor. I will notify maintainers to help approve once PR is approved. Thanks! ---Powered by SONiC BuildBot
|
Author
|
Guys, no volunteers to review that? :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem Summary
Executing
config load -yrepeatedly on a SONiC switch causes unexpected SSH session teardowns. The management interface would be reconfigured on every configuration load even when no actual configuration changes were made.Symptoms
config load -yoperationsinterfaces-configservice restarts unnecessarily on every config loadRoot Cause
The
MgmtIfaceCfg.load()method inhostcfgdwas incorrectly retrieving themgmtVrfEnabledvalue from the top level of themgmt_vrfdictionary:However, the actual data structure passed from
HostConfigDaemon.load()is a full table dict keyed by row name, following the YANG model forsonic-mgmt_vrf. This means the correct way to read the value is:Impact
The internal cache (
self.mgmt_vrf_enabled) was always initialized to''(empty string)update_mgmt_vrf()would compare the actual value ('true'or'false') against''This resulted in a "state change" detection interfaces-config service would be restarted on every config load, disrupting network connectivity.
Full changes description
MgmtIfaceCfg.load()to properly access the nestedvrf_globalrowtest_mgmtvrf_no_restart_on_same_state) that verifies:mgmt_vrf_enabledfrom the nested structure;test_mgmtvrf_route_check_failed) to use the correct nested dictionary structure.Evidence (system logs)
1.
hostcfgddetects VRF state change and restarts interfaces-config2.
interfaces-configservice is stopped (causing network disruption)3. Management interface goes down (
eth0)4. Network services restart causing connectivity loss