Skip to content

refactor(api): move resource initialization into api crate#3864

Merged
poroh merged 1 commit into
NVIDIA:mainfrom
poroh:api-bootstrap/03-resources
Jul 24, 2026
Merged

refactor(api): move resource initialization into api crate#3864
poroh merged 1 commit into
NVIDIA:mainfrom
poroh:api-bootstrap/03-resources

Conversation

@poroh

@poroh poroh commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Reduce the scope and growth of carbide-api-core by moving process initialization into the carbide-api composition crate. This PR moves database, Vault, credential, certificate, KMS, and secret-import setup without intended functional or configuration changes.

This is the third change in a planned series:

  1. Move logging initialization and the top-level run entry point - refactor(api): move logging initialization into api crate #3851.
  2. Move metrics initialization, the metrics endpoint, and process task ownership - refactor(api): move metrics initialization into api crate #3860.
  3. Move database, Vault, credentials, certificates, KMS, and secret-import setup - this PR.
  4. Move dynamic settings, IPMI, Redfish, RMS, InfiniBand, NMX-C, DPF, and component-manager client setup.

The existing credential routing, certificate configuration, KMS validation, Vault import behavior, and database pool configuration are preserved. Dependencies no longer used by api-core move with the implementation.

Related issues

#3851
#3860

Type of Change

  • Add - New feature or capability
  • Change - Changes in existing functionality
  • Fix - Bug fixes
  • Remove - Removed features or deprecated functionality
  • Internal - Internal changes (refactoring, tests, docs, etc.)

Breaking Changes

  • This PR contains breaking changes

Testing

  • Unit tests added/updated
  • Integration tests added/updated
  • Manual testing performed
  • No testing required (docs, internal refactor, etc.)

Additional Notes

This PR is stacked on #3860 and should merge after it.

@copy-pr-bot

copy-pr-bot Bot commented Jul 22, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Summary by CodeRabbit

  • New Features

    • Added centralized runtime resource setup for database, certificate, credential, and secrets services.
    • Added support for selecting the IPMI tool implementation at runtime.
    • Added startup configuration handling and Vault import session coordination.
  • Improvements

    • Streamlined API startup by reusing preconfigured runtime resources.
    • Added validation for database pool settings and secrets configuration.

Walkthrough

The API crate now initializes shared runtime resources, including Postgres, credentials, certificates, KMS, and optional Vault import state. api-core receives these resources through CoreRunInputs, while startup logging and dynamic settings initialization move into reusable bootstrap wiring.

Changes

Runtime resource initialization

Layer / File(s) Summary
Resource assembly and database setup
crates/api/src/resources.rs, crates/api/src/lib.rs, crates/api/Cargo.toml
Adds RuntimeResources and builds Vault, certificate, Postgres, local credential, and configured fallback-store resources with pool validation and TLS settings.
KMS routing and Vault import
crates/api/src/resources.rs, crates/api-core/src/bootstrap.rs
Builds routed KMS providers and performs a session-locked, one-time strict Vault-to-Postgres secrets import.
Injected core startup dependencies
crates/api-core/src/bootstrap.rs, crates/api-core/src/run.rs, crates/api-core/src/setup.rs, crates/api/src/run.rs, crates/api-core/Cargo.toml
Adds dynamic-settings startup, changes CoreRunInputs to accept injected resources, wires them from API startup, and removes duplicate pool and secret initialization from api-core.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant API
  participant setup_resources
  participant Postgres
  participant Vault
  participant api_core
  API->>setup_resources: initialize RuntimeResources
  setup_resources->>Postgres: connect and validate pool configuration
  setup_resources->>Vault: build clients and optionally import secrets
  setup_resources-->>API: return injected resources
  API->>api_core: invoke run_core with resources and DynamicSettings
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: moving resource initialization into the api crate.
Description check ✅ Passed The description matches the refactor and its scope, including moving database, Vault, credential, certificate, KMS, and secret-import setup.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@poroh
poroh force-pushed the api-bootstrap/03-resources branch 2 times, most recently from ec18c0e to bfc9e57 Compare July 22, 2026 21:09
@poroh
poroh marked this pull request as ready for review July 22, 2026 21:14
@poroh
poroh requested a review from a team as a code owner July 22, 2026 21:14
@poroh
poroh force-pushed the api-bootstrap/03-resources branch from bfc9e57 to ecdafd9 Compare July 22, 2026 21:42
@poroh
poroh force-pushed the api-bootstrap/03-resources branch from ecdafd9 to 9ad4de6 Compare July 23, 2026 19:24
@poroh
poroh force-pushed the api-bootstrap/03-resources branch from 9ad4de6 to d665b1d Compare July 23, 2026 19:38
@github-actions

Copy link
Copy Markdown

Move database, Vault, credential, certificate, KMS, and secret-import
setup into the api composition crate. Keep api-core focused on API
implementation and domain logic.

Signed-off-by: Dmitry Porokh <dporokh@nvidia.com>
@poroh
poroh force-pushed the api-bootstrap/03-resources branch from d665b1d to ed195f3 Compare July 23, 2026 23:49

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
crates/api-core/src/bootstrap.rs (1)

67-67: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use % formatting for listen_address.

Avoid eagerly allocating a String and recording it with Debug formatting; pass the existing Display value directly.

Proposed fix
-        listen_address = carbide_config.listen.to_string(),
+        listen_address = %carbide_config.listen,

As per coding guidelines, use % for Display values in structured tracing fields.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/api-core/src/bootstrap.rs` at line 67, Update the structured tracing
field for listen_address in the surrounding bootstrap configuration to use `%`
formatting with carbide_config.listen directly, replacing the eager to_string()
conversion and Debug-style recording while preserving the existing field name.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@crates/api-core/src/bootstrap.rs`:
- Line 67: Update the structured tracing field for listen_address in the
surrounding bootstrap configuration to use `%` formatting with
carbide_config.listen directly, replacing the eager to_string() conversion and
Debug-style recording while preserving the existing field name.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 056220cd-dcf2-4003-a476-35b86c8456f0

📥 Commits

Reviewing files that changed from the base of the PR and between d665b1d and ed195f3.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (8)
  • crates/api-core/Cargo.toml
  • crates/api-core/src/bootstrap.rs
  • crates/api-core/src/run.rs
  • crates/api-core/src/setup.rs
  • crates/api/Cargo.toml
  • crates/api/src/lib.rs
  • crates/api/src/resources.rs
  • crates/api/src/run.rs
🚧 Files skipped from review as they are similar to previous changes (7)
  • crates/api/src/lib.rs
  • crates/api-core/Cargo.toml
  • crates/api/Cargo.toml
  • crates/api/src/run.rs
  • crates/api-core/src/setup.rs
  • crates/api-core/src/run.rs
  • crates/api/src/resources.rs

@poroh
poroh merged commit 90a60ca into NVIDIA:main Jul 24, 2026
62 checks passed
poroh added a commit that referenced this pull request Jul 24, 2026
Reduce the public surface and clarify the boundary of carbide-api-core
by keeping service runtime assembly private while exposing a narrow
bootstrap interface to the carbide-api composition crate.

This is the fourth change in the series:
1. Move logging initialization and the top-level run entry point —
#3851.
2. Move metrics initialization, the metrics endpoint, and process task
ownership — #3860.
3. Move database, Vault, credentials, certificates, KMS, and
secret-import setup — #3864.
4. Consolidate the remaining service runtime assembly behind the hidden
bootstrap interface — this PR.

This PR replaces the thin run boundary adapter with RuntimeInputs and
start_runtime in the existing hidden bootstrap module. Dynamic settings
and Redfish client setup remain internal to api-core, alongside API
construction, controller startup, listener startup, and readiness
signaling.

The existing startup behavior and configuration handling are preserved.
Dependencies no longer used by api-core are removed, while test-only
dependencies move to dev-dependencies.

## Related issues

#3851
#3860
#3864

## Type of Change
- [ ] **Add** - New feature or capability
- [ ] **Change** - Changes in existing functionality
- [ ] **Fix** - Bug fixes
- [ ] **Remove** - Removed features or deprecated functionality
- [x] **Internal** - Internal changes (refactoring, tests, docs, etc.)

## Breaking Changes
- [ ] **This PR contains breaking changes**

## Testing
- [ ] Unit tests added/updated
- [ ] Integration tests added/updated
- [x] Manual testing performed
- [ ] No testing required (docs, internal refactor, etc.)

## Additional Notes

This PR is stacked on #3864 and should merge after it.

Signed-off-by: Dmitry Porokh <dporokh@nvidia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants