Skip to content

[action] [PR:406] Lazy connect to config_db during first collect instead of during init - #433

Merged
mssonicbld merged 1 commit into
sonic-net:202605from
mssonicbld:cherry/202605/406
Sep 14, 2026
Merged

mssonicbld merged 1 commit into
sonic-net:202605from
mssonicbld:cherry/202605/406

Conversation

@mssonicbld

Copy link
Copy Markdown

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:

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
  • 202605

Reason: fixes a DPU boot-time false error log.

Tested branch (Please provide the tested image version)

  • 202605
  • 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

#### 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>
@mssonicbld

Copy link
Copy Markdown
Author

Original PR: #406

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@mssonicbld

Copy link
Copy Markdown
Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@mssonicbld
mssonicbld merged commit e7426f9 into sonic-net:202605 Sep 14, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant