-
Notifications
You must be signed in to change notification settings - Fork 40
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
[internal-dns] break types-only dependencies to dns-service-client #6807
[internal-dns] break types-only dependencies to dns-service-client #6807
Conversation
Created using spr 1.3.6-beta.1
impl Ord for types::DnsRecord { | ||
fn cmp(&self, other: &Self) -> std::cmp::Ordering { | ||
use types::DnsRecord; | ||
match (self, other) { | ||
// Same kinds: compare the items in them | ||
(DnsRecord::A(addr1), DnsRecord::A(addr2)) => addr1.cmp(addr2), | ||
(DnsRecord::Aaaa(addr1), DnsRecord::Aaaa(addr2)) => { | ||
addr1.cmp(addr2) | ||
} | ||
(DnsRecord::Srv(srv1), DnsRecord::Srv(srv2)) => srv1 | ||
.target | ||
.cmp(&srv2.target) | ||
.then_with(|| srv1.port.cmp(&srv2.port)), | ||
|
||
// Different kinds: define an arbitrary order among the kinds. | ||
// We could use std::mem::discriminant() here but it'd be nice if | ||
// this were stable over time. | ||
// We define (arbitrarily): A < Aaaa < Srv | ||
(DnsRecord::A(_), DnsRecord::Aaaa(_) | DnsRecord::Srv(_)) => { | ||
std::cmp::Ordering::Less | ||
} | ||
(DnsRecord::Aaaa(_), DnsRecord::Srv(_)) => std::cmp::Ordering::Less, | ||
|
||
// Anything else will result in "Greater". But let's be explicit. | ||
(DnsRecord::Aaaa(_), DnsRecord::A(_)) | ||
| (DnsRecord::Srv(_), DnsRecord::A(_)) | ||
| (DnsRecord::Srv(_), DnsRecord::Aaaa(_)) => { | ||
std::cmp::Ordering::Greater | ||
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This Ord
impl should be identical to the automatically-derived one, since that orders stuff from top to bottom (so A
, AAAA
, and then SRV
).
Created using spr 1.3.6-beta.1
); | ||
|
||
pub type DnsError = crate::Error<crate::types::Error>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved DnsError
here because it makes the most sense here.
Past versions of nexus-types that are still referenced in the dependency tree | ||
depended on dns-service-client for defining some types. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So if I remove this rule as well, I get this diff:
DNS Server (client: dns-service-client)
+ consumed by: crucible-downstairs (crucible/downstairs)
+ consumed by: crucible-pantry (crucible/pantry)
+ consumed by: ddmd (maghemite/ddmd)
+ consumed by: dpd (dendrite/dpd)
+ consumed by: mgd (maghemite/mgd)
consumed by: omicron-nexus (omicron/nexus)
consumed by: omicron-sled-agent (omicron/sled-agent)
+ consumed by: propolis-server (propolis/bin/propolis-server)
That's what I based this comment on.
"weight": 0, | ||
"port": 127, | ||
"target": "001de000-c04e-4000-8000-000000000002.host.control-plane.oxide.internal" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reordering here is not important, it happened because we're no longer using progenitor-generated types (which I didn't realize got reordered in alphabetical order!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the mechanical changes LGTM, just a couple tiny nits. Will defer to others for the ls-apis
question.
@@ -3062,7 +3062,6 @@ | |||
] | |||
}, | |||
"DnsConfigParams": { | |||
"description": "DnsConfigParams\n\n<details><summary>JSON schema</summary>\n\n```json { \"type\": \"object\", \"required\": [ \"generation\", \"time_created\", \"zones\" ], \"properties\": { \"generation\": { \"type\": \"integer\", \"format\": \"uint64\", \"minimum\": 0.0 }, \"time_created\": { \"type\": \"string\", \"format\": \"date-time\" }, \"zones\": { \"type\": \"array\", \"items\": { \"$ref\": \"#/components/schemas/DnsConfigZone\" } } } } ``` </details>", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume these descriptions were coming from progenitor - do we care that they aren't being replaced by something else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah these descriptions are what happens when you use a progenitor-generated type in a Dropshot server, effectively doubling up on progenitor. I don't think it's a huge problem.
Currently, a number of crates across Omicron use
dns-service-client
just forthe types, leading tools like
ls-apis
to have to make exceptions to handlethem.
To resolve this, follow the pattern we've used in other places, particularly
while breaking dependency loops between API and client crates:
types
crate, in this caseinternal-dns-types
, and move theshared types (currently in
dns-server-api
) to the crate. This crate is agood place to put config code generally.
internal-dns-types
everywhere viareplace
directives.As a result of this, the only code that was left in
internal-dns
was theresolver -- so rename the crate to
internal-dns-resolver
and move that tointernal-dns/resolver
. Also move theinternal-dns-cli
crate tointernal-dns/cli
, since that is the general pattern we follow in Omicron.As a result of this change, code that just needs the types no longer needs to
depend on
dns-service-client
, allowing us to remove one of the twodns-service-client
-related rules. (I believe the other rule can be removedonce all our dependencies have been bumped.)
There are no changes to the output of
cargo xtask ls-apis apis
.