-
Notifications
You must be signed in to change notification settings - Fork 138
feat(dns): serve forward A/AAAA for overlay instance addresses #2786
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
crates/api-db/migrations/20260623054901_serve_overlay_instance_forward_dns.sql
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| -- Serve forward A/AAAA DNS for overlay (DPU-managed) instances. | ||
| -- | ||
| -- An overlay instance's addresses are allocated from its segment's pool into | ||
| -- instance_addresses and never reach machine_interface_addresses, so the | ||
| -- shortname/adm views never published them -- overlay instances had no forward | ||
| -- record. This adds an instance arm to the served dns_records view. | ||
| -- | ||
| -- The published name is the address in the host-naming strategy's IP-derived | ||
| -- form (<dashed-address>.<zone>.), the same convention machine interfaces use. | ||
| -- Rather than re-derive it in SQL, the hostname is computed once in Rust by the | ||
| -- host_naming::address_to_hostname helper -- the single source of truth shared | ||
| -- with machine_interfaces.hostname -- and stored on instance_addresses; the view | ||
| -- just reads the column. New addresses are populated at allocation time. | ||
| -- | ||
| -- Not published here: rows with no hostname (instance forward DNS has been | ||
| -- unserved since the old view was orphaned over a year ago, so existing rows | ||
| -- simply stay unpublished -- nothing to retrofit), and host_inband segments -- | ||
| -- a host_inband address is the host's own interface address, already served by | ||
| -- the shortname view. | ||
|
|
||
| ALTER TABLE instance_addresses ADD COLUMN hostname varchar(63); | ||
|
|
||
| CREATE OR REPLACE VIEW dns_records_instance AS | ||
| SELECT | ||
| concat(ia.hostname, '.', d.name, '.') AS q_name, | ||
| ia.address AS resource_record, | ||
| (CASE WHEN family(ia.address) = 6 THEN 'AAAA' ELSE 'A' END)::varchar(10) AS q_type, | ||
| -- Instances carry no per-record TTL metadata; find_record COALESCEs this to | ||
| -- the default (300s), so no dns_record_metadata join is needed here. | ||
| NULL::integer AS ttl, | ||
| d.id AS domain_id | ||
| FROM | ||
| instance_addresses ia | ||
| JOIN network_segments ns ON ns.id = ia.segment_id | ||
| JOIN domains d ON d.id = ns.subdomain_id | ||
| WHERE | ||
| ia.hostname IS NOT NULL | ||
| AND ns.network_segment_type <> 'host_inband'; | ||
|
|
||
| -- Re-publish the combined view with the instance arm attached. | ||
| DROP VIEW IF EXISTS dns_records; | ||
|
|
||
| CREATE OR REPLACE VIEW dns_records AS | ||
| SELECT * | ||
| FROM | ||
| dns_records_shortname_combined | ||
| FULL JOIN dns_records_adm_combined USING (q_name, resource_record, q_type, ttl, domain_id) | ||
| FULL JOIN dns_records_bmc_host_id USING (q_name, resource_record, q_type, ttl, domain_id) | ||
| FULL JOIN dns_records_bmc_dpu_id USING (q_name, resource_record, q_type, ttl, domain_id) | ||
| FULL JOIN dns_records_instance USING (q_name, resource_record, q_type, ttl, domain_id); |
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
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.