[action] [PR:406] Lazy connect to config_db during first collect instead of during init - #433
Merged
Merged
Conversation
#### Why I did it Avoid reading CONFIG_DB when `sonic-hostservice` initializes. On DPU boot, the host service can start before database files are ready, causing a transient `parseDatabaseConfig` error even though artifact collection is not requested yet. Observed log: ```text 2026 Jul 7 09:27:01.087175 sonic INFO systemd[1]: Started sonic-hostservice.service - SONiC Host Service. 2026 Jul 7 09:27:01.092005 sonic ERR python3: :- parseDatabaseConfig: Sonic database config file doesn't exist at /var/run/redis/sonic-db/database_config.json 2026 Jul 7 09:27:01.095411 sonic INFO python3[1218]: Failed to read hostname/board_type from CONFIG_DB: Sonic database config file doesn't exist at /var/run/redis/sonic-db/database_config.json 2026 Jul 7 09:27:08.163389 sonic INFO systemd[1]: Starting database.service - Database container... ``` ##### Work item tracking - Microsoft ADO **(number only)**: N/A #### How I did it - Initialize debug artifact metadata with safe defaults in `DebugArtifactCollector.__init__`. - Keep CONFIG_DB metadata lookup lazy during the first `collect()` call. - Add a unit test to ensure constructor initialization does not read device metadata. #### How to verify it - Run `tests/debug_info_test.py`. - Restart `sonic-hostservice` before database readiness and verify init emits no `parseDatabaseConfig` error. #### Which release branch to backport (provide reason below if selected) - [ ] 201811 - [ ] 201911 - [ ] 202012 - [ ] 202106 - [ ] 202111 - [ ] 202205 - [ ] 202211 - [ ] 202305 - [ ] 202311 - [ ] 202405 - [ ] 202411 - [x] 202605 Reason: fixes a DPU boot-time false error log. #### Tested branch (Please provide the tested image version) - [x] 202605 - [x] master #### Description for the changelog Lazy connect to config_db during first collect instead of during init Signed-off-by: Sonic Build Admin <sonicbld@microsoft.com>
Author
|
Original PR: #406 |
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
14 tasks
Author
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
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
Avoid reading CONFIG_DB when
sonic-hostserviceinitializes. On DPU boot, the host service can start before database files are ready, causing a transientparseDatabaseConfigerror even though artifact collection is not requested yet.Observed log:
Work item tracking
How I did it
DebugArtifactCollector.__init__.collect()call.How to verify it
tests/debug_info_test.py.sonic-hostservicebefore database readiness and verify init emits noparseDatabaseConfigerror.Which release branch to backport (provide reason below if selected)
Reason: fixes a DPU boot-time false error log.
Tested branch (Please provide the tested image version)
Description for the changelog
Lazy connect to config_db during first collect instead of during init
Signed-off-by: Sonic Build Admin sonicbld@microsoft.com