Strengthen Phase 7 AND provisioning, lease DB guarantees, and reconciliation#165
Merged
aidankhogg merged 1 commit intoJun 29, 2026
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Description
DomainRegistryHandler.allocate_addressand add a mock-only fallback in_allocate_addressinnetengine/phases/phase_ands.pywhen pools are not seeded.netengine/handlers/domain_registry_handler.pythat reuses existing leases forand_name, enumerates/24candidates inside a profile pool, skips already‑leased CIDRs, retries on collisions, usesupsertto persist leases and raisesRegistryErroron exhaustion.migrations/001_initial.sqlto includeCONSTRAINT address_leases_cidr_unique UNIQUE (cidr).ANDInstanceStatetyped schema andands_instancesfield innetengine/core/state.py, and persist profile feature flags (dynamic_ip,reverse_dns,bgp) with each stored AND instance innetengine/phases/phase_ands.py.netengine/phases/phase_ands.py(reconcile,_update_and_profile,_teardown_and,_repair_and) that handle creating/removing Docker networks, gateway rule application, DNS zone records, DHCP config, reverse DNS zones, BGP sidecars, and cleaning DB leases/and_instances rows.tests/test_phase_ands_strengthening.pyto cover address-pool exhaustion, CIDR collision skipping, dynamic IP/DHCP setup, reverse DNS setup, optional vs required BGP behavior, and reconciliation after partial failure.Testing
pytest tests/test_and_profiles.py tests/integration/test_m7_ands.py tests/test_phase_ands_strengthening.py -qand the targeted AND/registry tests passed.pytest tests/test_registry_handlers.py tests/test_phase_ands_strengthening.py -qto validate lease upsert and allocation/collision behavior and they passed.pytest -qand observed580 passed, 10 skippedindicating no regressions in existing tests.Codex Task