DHCP leases refer to their scope by id, so renaming a scope keeps its leases #58

Closed
opened 2026-10-31 12:41:58 -04:00 by claude · 0 comments
Owner
  • Draft: BUG-41
  • Priority: medium (a scope rename can orphan leases written under the old name)
  • Agent: storage-coder
  • Depends on: none
  • Decisions: none

Why

LeaseEntity.ScopeName (src/dotnet/src/Ninlil.Dhcp.Data.Abstractions/Entity/LeaseEntity.cs:25) links a lease to its scope by name. Reservations and custom options already use ScopeId. The owner routed the id link to a post-release issue (OD-B13-b). DhcpDnsRegistrationService looks the scope up by the lease's name (src/dotnet/src/Ninlil.Dhcp.Server.DnsIntegration/DhcpDnsRegistrationService.cs:102-105), so a renamed scope also stops DNS registration for its leases.

What changes

  • Add ScopeId (Guid) to LeaseEntity and its configuration.
  • Migration per relational provider with a data backfill from ScopeName (a migrationBuilder.Sql in Up/Down, as *ConvertDhcpLeaseTimesToTicks.cs does).
  • MongoDB backfill plus a MongoSchemaSteps.Known step.
  • Update lease writers and readers in Ninlil.Dhcp.Server.Core and DhcpDnsRegistrationService.
  • Whether ScopeName stays as a display copy is the storage-coder's call: keep it only if a reader needs it. Say so in the PR.
  • No REST shape change unless a model exposes the id. If one does, a separate api-regen issue follows.
  • Later issues build on the id: #170 (lease to reservation) resolves the scope by ScopeId and depends on this issue; #115 counts active leases per scope id once this lands (DEDUPE.md P2). #188 also edits DhcpDnsRegistrationService; whichever lands second rebases.

Acceptance

  • Red: rename a scope with active leases. The leases still belong to it, the DHCP engine renews them and their DNS records are still registered (fails on HEAD).
  • src/dotnet/tests/Ninlil.Dhcp.Server.Core.Tests, src/dotnet/tests/Ninlil.Dhcp.Server.DnsIntegration.Tests, src/dotnet/tests/Ninlil.Dhcp.Data.EntityFrameworkCore.Tests and src/dotnet/tests/Ninlil.Dns.Data.Integration.Tests (all engines, Docker) pass.
  • Four migrations plus a MongoDB step.

Source

bughunt-plan.md:522 (from the B13 design, OD-B13-b).

- **Draft:** BUG-41 - **Priority:** medium (a scope rename can orphan leases written under the old name) - **Agent:** storage-coder - **Depends on:** none - **Decisions:** none ### Why `LeaseEntity.ScopeName` (`src/dotnet/src/Ninlil.Dhcp.Data.Abstractions/Entity/LeaseEntity.cs:25`) links a lease to its scope by name. Reservations and custom options already use `ScopeId`. The owner routed the id link to a post-release issue (OD-B13-b). `DhcpDnsRegistrationService` looks the scope up by the lease's name (`src/dotnet/src/Ninlil.Dhcp.Server.DnsIntegration/DhcpDnsRegistrationService.cs:102-105`), so a renamed scope also stops DNS registration for its leases. ### What changes - Add `ScopeId` (Guid) to `LeaseEntity` and its configuration. - Migration per relational provider with a data backfill from `ScopeName` (a `migrationBuilder.Sql` in `Up`/`Down`, as `*ConvertDhcpLeaseTimesToTicks.cs` does). - MongoDB backfill plus a `MongoSchemaSteps.Known` step. - Update lease writers and readers in `Ninlil.Dhcp.Server.Core` and `DhcpDnsRegistrationService`. - Whether `ScopeName` stays as a display copy is the storage-coder's call: keep it only if a reader needs it. Say so in the PR. - No REST shape change unless a model exposes the id. If one does, a separate `api-regen` issue follows. - Later issues build on the id: #170 (lease to reservation) resolves the scope by `ScopeId` and depends on this issue; #115 counts active leases per scope id once this lands (DEDUPE.md P2). #188 also edits `DhcpDnsRegistrationService`; whichever lands second rebases. ### Acceptance - [ ] Red: rename a scope with active leases. The leases still belong to it, the DHCP engine renews them and their DNS records are still registered (fails on HEAD). - [ ] `src/dotnet/tests/Ninlil.Dhcp.Server.Core.Tests`, `src/dotnet/tests/Ninlil.Dhcp.Server.DnsIntegration.Tests`, `src/dotnet/tests/Ninlil.Dhcp.Data.EntityFrameworkCore.Tests` and `src/dotnet/tests/Ninlil.Dns.Data.Integration.Tests` (all engines, Docker) pass. - [ ] Four migrations plus a MongoDB step. ### Source `bughunt-plan.md:522` (from the B13 design, OD-B13-b).
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
lantea-one/ninlil#58
No description provided.