Skip Redis client init for DBs not in database_config.json#683
Open
yijingyan2 wants to merge 3 commits into
Open
Skip Redis client init for DBs not in database_config.json#683yijingyan2 wants to merge 3 commits into
yijingyan2 wants to merge 3 commits into
Conversation
Signed-off-by: Yijing Yan <yijingyan@microsoft.com>
Contributor
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR reduces startup log noise in sonic-gnmi by avoiding Redis client initialization attempts for gNMI Target enum DBs that are not present in the platform’s database_config.json (e.g., DPU_COUNTERS_DB on non-DPU platforms). This fits into the sonic_data_client startup path by tightening how Redis clients are pre-created for DB-backed targets.
Changes:
- Add a helper to compute the set of DB names present in
database_config.json. - In both TCP and UNIX-socket Redis client init paths, skip targets not present in that configured set (with a
V(2)log) rather than callingGetDbSock/GetDbTcpAddrand triggering ERR logs.
Comment on lines
+583
to
+585
| // configuredDbSet returns the set of DB names defined in the device's | ||
| // SONiC database_config.json for the given namespace. | ||
| func configuredDbSet(dbNamespace string) map[string]struct{} { |
Comment on lines
+609
to
+616
| configured := configuredDbSet(dbNamespace) | ||
| for dbName, dbn := range spb.Target_value { | ||
| if dbName != "OTHERS" { | ||
| if configured != nil { | ||
| if _, ok := configured[dbName]; !ok { | ||
| log.V(2).Infof("Skipping %s in namespace %s: not configured on this platform", dbName, dbNamespace) | ||
| continue | ||
| } |
theasianpianist
previously approved these changes
May 22, 2026
Contributor
theasianpianist
left a comment
There was a problem hiding this comment.
lgtm, suggest adding a new test case as per the copilot comment
Signed-off-by: Yijing Yan <yijingyan@microsoft.com>
Contributor
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
theasianpianist
previously approved these changes
May 26, 2026
Signed-off-by: Yijing Yan <yijingyan@microsoft.com>
Contributor
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
theasianpianist
approved these changes
May 27, 2026
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.
Why I did it
initRedisDbClients()anduseRedisTcpClient()iterate over every entry in thespb.Target_valueproto enum and callsdcfg.GetDbSock/sdcfg.GetDbTcpAddrfor each one. When aTargetenum value corresponds to a DB that is not present in the device's database_config.json (e.g. DPU_COUNTERS_DB on a non-smartswitch / non-DPU platform), the underlyingSonicDBConfig::getDbInfocall logs an ERR-level message to syslog:This was introduced as a side-effect of adding
DPU_COUNTERS_DB = 18to theTargetenum. SinceDPU_COUNTERS_DBis only configured on smartswitch / DPU platforms, every other platform now emits these benign ERR logs every timegnmi / dialout_client_clistarts up.How I did it
configuredDbSet(dbNamespace)that returns the set of DB names actually present indatabase_config.jsonfor the given namespace.useRedisTcpClient()(TCP path) andinitRedisDbClients()(UNIX socket path), look up the configured DB set before iteratingspb.Target_value. If a Target enum entry isn't in the configured set, skip it with aV(2)info log instead of callingsdcfg.GetDbSock/sdcfg.GetDbTcpAddrand triggering the ERR.GetDbListitself fails or returns empty, the helper returns nil and behaviour falls back to the original "try them all" path, so this is a strictly additive guard.How to verify it
with this change, the test passed https://elastictest.org/scheduler/testplan/6a0ff4fe5ec6b5a1f3a20c7a?searchTestCase=rota&testcase=telemetry%2Ftest_telemetry_cert_rotation.py&type=console
Which release branch to backport (provide reason below if selected)
Description for the changelog
Link to config_db schema for YANG module changes
A picture of a cute animal (not mandatory but encouraged)