Skip to content

fix(api): preserve automatic networking on legacy instance updates#3594

Merged
chet merged 1 commit into
NVIDIA:mainfrom
chet:gh-issue-3592
Jul 16, 2026
Merged

fix(api): preserve automatic networking on legacy instance updates#3594
chet merged 1 commit into
NVIDIA:mainfrom
chet:gh-issue-3592

Conversation

@chet

@chet chet commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Instance config updates sent in the legacy InstanceNetworkConfig.auto wire format now preserve the instance's automatic networking, instead of being rejected.

The auto boolean was deprecated in favor of auto_config, and the allocation path translates a legacy auto: true into a real auto_config -- but the update path never did. On update, RPC->model conversion derives auto-ness solely from auto_config, so a legacy request arrives as auto_config: None; the immutable-network check then compares that against the stored Some(vpc_id) and rejects an otherwise no-op change. It's a rolling-upgrade gap -- any component still emitting the deprecated boolean (an older REST build, or a nico-rest-site-agent that drops the unknown field over Temporal) trips it, which is also why re-sending --auto-network true doesn't help.

The fix extends the allocation-path compatibility to updates, but sources the value differently: instead of re-resolving from the host's segment, it restores the instance's stored auto_config -- the authoritative value Core already holds. It's scoped tightly to the legacy shape (auto: true with no auto_config and no explicit interfaces), and the existing guardrails stand:

  • Enabling automatic networking on a non-auto instance via the deprecated boolean is still rejected, with a distinct message.
  • Legacy auto: false, a different explicit auto_config.vpc_id, and explicit interfaces all still reject.
  • Copying the stored value means it works even when the Flat HostInband segment isn't bound to a VPC.

Related issues

This supports #3592

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

test_update_instance_config_restores_deprecated_auto_config covers the legacy update preserving the VPC, plus the auto-enable / auto-disable / different-VPC / incomplete-auto_config rejects, and asserts the segment is unbound so the compatibility path can't lean on segment resolution. A deprecated-auto reject case was added to test_reject_invalid_instance_config_updates.

Additional Notes

  • cargo test -p carbide-api-core test_update_instance_config_restores_deprecated_auto_config --lib
  • cargo test -p carbide-api-core test_reject_invalid_instance_config_updates --lib -- --nocapture
  • cargo make format-nightly
  • cargo make clippy
  • cargo make carbide-lints

Closes #3592

@chet
chet requested a review from a team as a code owner July 16, 2026 06:06
@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

update_instance_config restores stored auto_config for deprecated automatic-networking requests and rejects unsupported transitions. SQLx-backed tests cover configuration preservation, interface behavior, and validation errors.

Changes

Legacy network configuration compatibility

Layer / File(s) Summary
Legacy auto configuration restoration
crates/api-core/src/handlers/instance.rs
Detects the deprecated wire form, restores the existing instance’s auto_config, and returns InvalidArgument when restoration is unavailable.
Compatibility transition validation
crates/api-core/src/tests/instance_config_update.rs
Adds integration coverage for restoration, VPC preservation, interface resolution, rejected transitions, deprecated error messaging, and import reordering.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant RPCRequest
  participant update_instance_config
  participant ExistingInstance
  RPCRequest->>update_instance_config: legacy auto=true request
  update_instance_config->>ExistingInstance: read stored auto_config
  ExistingInstance-->>update_instance_config: auto_config or missing
  update_instance_config->>update_instance_config: restore auto_config or return InvalidArgument
Loading

Possibly related issues

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
Title check ✅ Passed The title clearly summarizes the main change: preserving automatic networking during legacy instance updates.
Description check ✅ Passed The description accurately explains the bug, the legacy update path fix, and the validation behavior added by the PR.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@chet

chet commented Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai full_review, thanks!

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

@chet Sounds good — kicking off a full review of all the changes now.

🐇✨

✅ Action performed

Full review finished.

@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/tests/instance_config_update.rs (1)

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

Use scenarios! for this rejection matrix. Replace the custom RejectCase loop with the standard table-driven helper so these negative RPC cases match the rest of the test suite.

🤖 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/tests/instance_config_update.rs` around lines 472 - 525,
Replace the custom RejectCase struct and loop with the repository’s standard
scenarios! table-driven helper, preserving all four network inputs, scenario
descriptions, expected InvalidArgument status, and message assertions in the
existing rejection test.

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/tests/instance_config_update.rs`:
- Around line 472-525: Replace the custom RejectCase struct and loop with the
repository’s standard scenarios! table-driven helper, preserving all four
network inputs, scenario descriptions, expected InvalidArgument status, and
message assertions in the existing rejection test.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: b775efeb-d8f3-4d59-a581-5bec9589d6d4

📥 Commits

Reviewing files that changed from the base of the PR and between 0d28ae5 and 06abf17.

📒 Files selected for processing (2)
  • crates/api-core/src/handlers/instance.rs
  • crates/api-core/src/tests/instance_config_update.rs

@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/tests/instance_config_update.rs (1)

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

Use scenarios! or check_cases for the invalid-network cases. The custom RejectCase loop is harder to scan; a table-driven helper would preserve per-row reporting and align this test with the repository’s convention.

🤖 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/tests/instance_config_update.rs` around lines 472 - 525,
Replace the custom RejectCase loop with the repository’s scenarios! or
check_cases helper for these invalid-network cases. Preserve each case’s
scenario name, network input, expected InvalidArgument code, and
expected-message assertion, including per-row failure reporting.

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/tests/instance_config_update.rs`:
- Around line 472-525: Replace the custom RejectCase loop with the repository’s
scenarios! or check_cases helper for these invalid-network cases. Preserve each
case’s scenario name, network input, expected InvalidArgument code, and
expected-message assertion, including per-row failure reporting.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 600e5935-6f15-4336-8709-c583308ad8c1

📥 Commits

Reviewing files that changed from the base of the PR and between 0d28ae5 and 06abf17.

📒 Files selected for processing (2)
  • crates/api-core/src/handlers/instance.rs
  • crates/api-core/src/tests/instance_config_update.rs

Clients that still send the deprecated `InstanceNetworkConfig.auto` boolean can now update an automatically networked instance without losing its immutable VPC. Core recognizes the legacy `auto=true` request and restores the stored `auto_config`, rather than treating the omitted replacement field as a requested network change.

Explicit `auto_config` requests remain authoritative, and legacy requests cannot enable or disable automatic networking. Using the instance's stored VPC also keeps the path independent of whether a Flat `HostInband` segment is bound.

Tests added!

This supports NVIDIA#3592

Signed-off-by: Chet Nichols III <chetn@nvidia.com>
@chet

chet commented Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai full_review, thanks!

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

@chet Understood — re-running the full review now to verify the check_cases_async helper and the four rejection-matrix rows against InvalidArgument and the expected messages.

✅ Action performed

Full review finished.

@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown

🔍 Container Scan Summary

Service Total Critical High Medium Low Other
boot-artifacts-aarch64 3 0 0 3 0 0
boot-artifacts-x86_64 3 0 0 3 0 0
forge-admin-cli-x86_64 259 16 29 79 7 128
machine-validation-runner 532 39 113 184 15 181
machine_validation 532 39 113 184 15 181
machine_validation-aarch64 532 39 113 184 15 181
nvmetal-carbide 532 39 113 184 15 181
TOTAL 2393 172 481 821 67 852

Per-CVE detail lives in the per-service grype-* artifacts (JSON + SARIF). Severity counts only — no CVE IDs published here.

@chet

chet commented Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

CI note: the ARM ephemeral-image job failed twice in Setup mkosi environment, before any project build step, because Ubuntu ARM mirror package downloads timed out. The same job is concurrently failing on unrelated PRs #3473, #3453, #3597, and #3598, so this is a shared runner/mirror incident rather than this diff. All other PR gates, including the service tests, lint, DCO, REST, and CodeRabbit, passed. Holding further retries until an unrelated ARM run succeeds.

@chet
chet merged commit d27779e into NVIDIA:main Jul 16, 2026
153 of 157 checks passed
@chet
chet deleted the gh-issue-3592 branch July 16, 2026 17:25
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.

fix(api): preserve automatic networking on legacy instance updates

2 participants