Skip to content

Add ignored BMC MAC persistence and helpers#3853

Open
ericpretzel wants to merge 3 commits into
NVIDIA:mainfrom
ericpretzel:ignored-bmc-macs
Open

Add ignored BMC MAC persistence and helpers#3853
ericpretzel wants to merge 3 commits into
NVIDIA:mainfrom
ericpretzel:ignored-bmc-macs

Conversation

@ericpretzel

@ericpretzel ericpretzel commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

When NICo is uningesting/decommissioning a machine, we need a way to prevent site explorer from exploring and re-ingesting its BMC(s). Additionally, as the last step in uningestion/decommissioning, we want a way to have the DHCP server no longer lease an IP address to the BMC(s) and be able to verify when the BMC has expired its lease (i.e. it sends a new DHCPDISCOVER).

In this PR we add a new SQL table with helper functions to enable the above. The logic for site explorer/DHCP will come in later PRs.

Related issues

Closes #3815

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.)

@ericpretzel
ericpretzel requested a review from a team as a code owner July 22, 2026 17:44
@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Summary by CodeRabbit

  • New Features
    • Added persistent management of BMC MAC addresses that should be ignored during discovery.
    • Added independent suppression controls for Site Explorer and DHCP discovery.
    • Added suppression reasons, acknowledgement timestamps, and creation/update tracking.
    • Added support for updating, querying, and removing ignored BMC MAC address records.

Walkthrough

Adds the ignored_bmc_macs table, public Rust models, persistence helpers for independent Site Explorer and DHCP suppression, acknowledgement tracking, and SQLx integration tests for state transitions and idempotency.

Changes

Ignored BMC MAC persistence

Layer / File(s) Summary
Schema and public persistence contract
crates/api-db/migrations/20260722120000_ignored_bmc_macs.sql, crates/api-model/src/ignored_bmc_mac.rs, crates/api-model/src/lib.rs, crates/api-db/src/lib.rs
Creates the ignored_bmc_macs table, defines persisted and input models, and exports the new modules.
Suppression CRUD and queries
crates/api-db/src/ignored_bmc_mac.rs
Adds upsert, lookup, Site Explorer filtering, DHCP suppression checks, acknowledgement recording, and single or batch deletion helpers.
Suppression lifecycle validation
crates/api-db/src/ignored_bmc_mac.rs
Tests independent flags, acknowledgement timestamp preservation and clearing, and deletion semantics.

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

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant ignored_bmc_mac
  participant PostgreSQL
  Caller->>ignored_bmc_mac: upsert or query BMC suppression state
  ignored_bmc_mac->>PostgreSQL: execute SQL against ignored_bmc_macs
  PostgreSQL-->>ignored_bmc_mac: return record, flags, or count
  ignored_bmc_mac-->>Caller: return DatabaseResult
Loading
sequenceDiagram
  participant DHCPCaller
  participant record_dhcp_discover_suppressed
  participant PostgreSQL
  DHCPCaller->>record_dhcp_discover_suppressed: submit BMC MAC discovery
  record_dhcp_discover_suppressed->>PostgreSQL: update observation when DHCP suppression is enabled
  PostgreSQL-->>record_dhcp_discover_suppressed: return matching-row status
  record_dhcp_discover_suppressed-->>DHCPCaller: return suppression result
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: adding ignored BMC MAC persistence and helpers.
Description check ✅ Passed The description accurately describes the new ignored BMC MAC table and helper functions.
Linked Issues check ✅ Passed The PR adds the required ignored BMC MAC table, helpers, and independent Site Explorer/DHCP suppression flags for #3815.
Out of Scope Changes check ✅ Passed The changes stay within the requested persistence and helper layer, with no unrelated scope added.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@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.

Actionable comments posted: 1

🤖 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.

Inline comments:
In `@crates/api-db/src/ignored_bmc_mac.rs`:
- Around line 27-50: Move the public IgnoredBmcMac model and the upsert input
contract from this database module into api-model, then import and reuse those
types here. Keep upsert and other persistence functions in this module,
preserving their existing behavior while removing local model definitions.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 44343bb2-92b3-493c-afe6-94b933989ab0

📥 Commits

Reviewing files that changed from the base of the PR and between 7d5c98a and 3c3c88e.

📒 Files selected for processing (3)
  • crates/api-db/migrations/20260722120000_ignored_bmc_macs.sql
  • crates/api-db/src/ignored_bmc_mac.rs
  • crates/api-db/src/lib.rs

Comment thread crates/api-db/src/ignored_bmc_mac.rs Outdated
@ericpretzel

Copy link
Copy Markdown
Contributor Author

@coderabbitai review please

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

@ericpretzel, I’ll review the changes in #3853, with particular attention to schema correctness, SQL update semantics, and the independent DHCP/Site Explorer suppression invariants.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@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-db/src/ignored_bmc_mac.rs (1)

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

Assert repeated acknowledgements are no-ops.

The test records each acknowledgement only once, so it does not enforce the documented first-timestamp preservation contract. Repeat both calls after initial, then assert both acknowledgement timestamps and updated_at remain unchanged.

Proposed test addition
         let initial = find(txn.as_mut(), mac(1)).await.unwrap().unwrap();
 
+        assert!(record_site_explorer_suppressed(txn.as_mut(), mac(1)).await.unwrap());
+        assert!(record_dhcp_discover_suppressed(txn.as_mut(), mac(1)).await.unwrap());
+        let repeated = find(txn.as_mut(), mac(1)).await.unwrap().unwrap();
+        assert_eq!(repeated.site_explorer_suppressed_at, initial.site_explorer_suppressed_at);
+        assert_eq!(repeated.dhcp_discover_suppressed_at, initial.dhcp_discover_suppressed_at);
+        assert_eq!(repeated.updated_at, initial.updated_at);
+
         let record = upsert(txn.as_mut(), &upsert_input(1, "retry", true, true))
🤖 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-db/src/ignored_bmc_mac.rs` around lines 363 - 375, Update
idempotent_upsert_preserves_acknowledgements to call both
record_site_explorer_suppressed and record_dhcp_discover_suppressed again after
capturing initial. Fetch the row afterward and assert both acknowledgement
timestamps and updated_at match initial, preserving the first-timestamp
contract.
🤖 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-db/src/ignored_bmc_mac.rs`:
- Around line 363-375: Update idempotent_upsert_preserves_acknowledgements to
call both record_site_explorer_suppressed and record_dhcp_discover_suppressed
again after capturing initial. Fetch the row afterward and assert both
acknowledgement timestamps and updated_at match initial, preserving the
first-timestamp contract.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: f608a13b-e031-480f-bb57-ff324b8348fa

📥 Commits

Reviewing files that changed from the base of the PR and between 1e9809c and 0110d7d.

📒 Files selected for processing (3)
  • crates/api-db/migrations/20260722120000_ignored_bmc_macs.sql
  • crates/api-db/src/ignored_bmc_mac.rs
  • crates/api-model/src/ignored_bmc_mac.rs
🚧 Files skipped from review as they are similar to previous changes (2)
  • crates/api-db/migrations/20260722120000_ignored_bmc_macs.sql
  • crates/api-model/src/ignored_bmc_mac.rs

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.

Add ignored BMC MAC persistence and helpers

1 participant