feat(dns): remove a reverse-DNS zone with its network segment#2783
Conversation
|
@coderabbitai PTAL, thanks! |
|
Important Review skippedNo new commits to review since the last review. ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
WalkthroughThe PR introduces a ChangesReverse-DNS zone cleanup on network segment deletion
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related issues
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "=== PR Details ==="
gh pr view 2783 --repo NVIDIA/infra-controller --json title,body,files,additions,deletions
echo ""
echo "=== PR Diff ==="
gh pr diff 2783 --repo NVIDIA/infra-controllerLength of output: 5517
1.
// Option A – explicit single-owner
if let Some(domain) = domain::find_by_name(&mut *txn, &zone).await?.into_iter().next() {
tracing::info!(%zone, %prefix, "removing reverse-DNS zone for deleted network prefix");
domain::delete(domain, &mut *txn).await?;
}2. No IPv6 test case The test exercises 3. Minor log field inconsistency tracing::info!(zone = %zone, %prefix, "removing reverse-DNS zone …");
4. Handler simplification — positive note Removing the intermediate Ok(Response::new(rpc::NetworkSegmentDeletionResult {}))is a clear improvement in readability. No notes here. Summary The PR is functionally correct, well-documented, and the tests cover the critical paths (create/delete, idempotent delete, non-aligned no-op). The items above are non-blocking; item 1 is the most worth addressing for long-term clarity. Happy to approve once you've had a look at these. |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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/dns/mod.rs`:
- Around line 148-160: The remove_reverse_zone function deletes domains by name
only without validating ownership, which can accidentally remove pre-existing
manual domains that share the same reverse-zone name. Modify the logic to
persist ownership metadata (associating the domain with the specific
prefix/segment) when creating reverse-DNS zones, then update the deletion loop
to filter by that ownership marker before calling domain::delete. This ensures
only domains actually owned by the deleted segment are removed, not any
pre-existing domains that happen to match the zone name.
- Around line 234-244: The test in the remove_reverse_zone idempotency block
(around lines 235-243) only verifies that the operations do not error by using
unwrap(), but does not assert the actual database state after each operation.
Add explicit post-condition assertions after the first remove_reverse_zone call
(the second removal) to verify that no reverse zone exists, and after the second
remove_reverse_zone call with the unaligned prefix to verify that the database
state remains unchanged and no zone was affected. This ensures that regressions
in no-op behavior are caught.
🪄 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: 21ff5378-2a4b-40eb-827d-e61520f3ffc2
📒 Files selected for processing (2)
crates/api-core/src/handlers/network_segment.rscrates/api-db/src/dns/mod.rs
🔍 Container Scan Summary
Per-CVE detail lives in the per-service |
A network's reverse-DNS zone is derived from its prefix and created with the segment, so PTR lookups resolve without anyone hand-authoring the zone. This completes that lifecycle at the other end: deleting a segment now removes the reverse zone it created, so a torn-down network leaves no orphaned in-addr.arpa / ip6.arpa domain behind. - Add db::dns::remove_reverse_zone, the inverse of ensure_reverse_zone -- it derives the same arpa zone from the prefix and soft-deletes the domain. - Hook it into the network_segment::delete handler, mirroring the create-time hook in save. - No refcount needed: prefixes are globally non-overlapping, so a zone has exactly one owner; re-deleting a segment finds no live zone and is a no-op. Tests added! This supports NVIDIA#2774 Signed-off-by: Chet Nichols III <chetn@nvidia.com>
|
@coderabbitai review |
✅ Action performedReview finished.
|
A network's reverse-DNS zone is derived from its prefix and created with the segment, so PTR lookups resolve without anyone hand-authoring the zone. This completes that lifecycle at the other end: deleting a segment removes the reverse zone it created, so a torn-down network leaves no orphaned
in-addr.arpa/ip6.arpadomain behind.db::dns::remove_reverse_zone, the inverse ofensure_reverse_zone-- it derives the same arpa zone from the prefix and soft-deletes the domain.network_segment::deletehandler, mirroring the create-time hook insave.Tests added!
This supports #2774