Skip to content
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

[3/n] [reconfigurator-cli] drop dependency on reconfigurator-execution #6783

Conversation

sunshowers
Copy link
Contributor

The only functions from reconfigurator-execution currently pulled in are these
helper methods. Move them into nexus-types so that reconfigurator-cli no longer
has to pull in the execution crate and all of its dependencies (particularly
nexus-db-model and nexus-db-queries).

There is one downside, which is that Overridables's #[cfg(test)] methods
are no longer marked that way. However, it does make the overrides available to
places such as the reconfigurator-cli. (It would be interesting to have a
test-related overlay feature in omicron, i.e. a testing feature in many of
our crates, but we don't have that yet.)

I had to move some of the silo fixed data into nexus-types as well -- as part
of that I took the opportunity to switch to const methods for a couple of
UUIDs.

Created using spr 1.3.6-beta.1
Created using spr 1.3.6-beta.1
Created using spr 1.3.6-beta.1
Copy link
Contributor

@andrewjstone andrewjstone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sunshowers this is great! Thanks for speeding up crate builds!

use omicron_common::api::external::Name;

/// The ID of the "default" silo.
pub static DEFAULT_SILO_ID: uuid::Uuid =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it weird that the *-types crate is gaining constants? I don't object to this, but I wonder if this is a gap in our crate organization or naming somehow.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess I view this as roughly in the same ballpark as, say, the CockroachDB version constants:

/// The hardcoded CockroachDB cluster version we want to be on, used in
/// [`Policy`].
///
/// /!\ WARNING: If you change this, there is no going back. /!\
pub const POLICY: CockroachDbClusterVersion =
CockroachDbClusterVersion::V22_1;
/// The CockroachDB cluster version created as part of newly-initialized
/// racks.
///
/// CockroachDB knows how to create a new cluster with the current cluster
/// version, and how to upgrade the cluster version from the previous major
/// release, but it does not have any ability to create a new cluster with
/// the previous major release's cluster version.
///
/// During "tick" releases, newly-initialized racks will be running
/// this cluster version, which will be one major version newer than the
/// version specified by `CockroachDbClusterVersion::POLICY`. During "tock"
/// releases, these versions are the same.
pub const NEWLY_INITIALIZED: CockroachDbClusterVersion =
CockroachDbClusterVersion::V22_1;
. Slightly out of the ordinary but I don't think there's a better place to put them. (You could put them in a crate of their own but that seems excessive, since there aren't any dependencies).

Copy link
Collaborator

@davepacheco davepacheco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Practically this looks like a great change.

As @jgallagher alluded to: there's something a little off about some of the stuff that's moving into nexus-types. Some of these are fixed data constants. silo_dns_name() is super tiny but also semantically pretty significant. The blueprint-to-{internal,external}-DNS-configuration is also semantically pretty load-bearing. The net result seems like a big win! And it's definitely fine as-is. It just remains surprising that the "types" crate would also have implementation for execution behavior and I'm not sure what the takeaway is.

@@ -44,6 +44,7 @@ uuid.workspace = true
api_identity.workspace = true
dns-service-client.workspace = true
gateway-client.workspace = true
internal-dns.workspace = true
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it easy to check if this affects the output of cargo xtask ls-apis? I'm a little worried this is going to make everything that uses nexus-types appear to be a client of the DNS servers. I think that'll be avoided by one of the existing exceptions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cargo xtask ls-apis apis showed no difference before and after.

If we're worried about this dependency, it's probably best to move the types out into a separate internal-dns-types crate.

Copy link
Contributor Author

@sunshowers sunshowers Oct 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see what's going on -- this is because internal-dns (both the types and the resolver) depends on dns-service-client for the types. I guess the way to address that is to define the types in another crate, then use replace -- similar to other places we've broken dependencies from _client to _types.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good. I think that as I hoped, this is being covered by this rule:

[[dependency_filter_rules]]
ancestor = "internal-dns"
client = "dns-service-client"
evaluation = "bogus"
note = """
internal-dns depends on dns-service-client to use its types. They're only used
when configuring DNS, which is only done in a couple of components. But many
other components use internal-dns solely to read DNS. This dependency makes it
look like everything uses the DNS server API, but that's not true. We should
consider splitting this crate in two to eliminate this false positive.
"""

As long as you see no change in the output, there's no (new) problem here.

nexus/types/src/deployment/execution/utils.rs Show resolved Hide resolved
nexus/types/src/deployment/execution/utils.rs Show resolved Hide resolved
@sunshowers
Copy link
Contributor Author

Thanks for the reviews!

The blueprint-to-{internal,external}-DNS-configuration is also semantically pretty load-bearing.

True -- though there's a fair bit of load-bearing implementation code in nexus-types already, e.g.

match self {
SledPolicy::InService {
provision_policy: SledProvisionPolicy::Provisionable,
} => match filter {
SledFilter::All => true,
SledFilter::Commissioned => true,
SledFilter::Decommissioned => false,
SledFilter::Discretionary => true,
SledFilter::InService => true,

Created using spr 1.3.6-beta.1
@sunshowers sunshowers enabled auto-merge (squash) October 8, 2024 01:49
@sunshowers sunshowers merged commit e974959 into main Oct 8, 2024
17 checks passed
@sunshowers sunshowers deleted the sunshowers/spr/3n-reconfigurator-cli-drop-dependency-on-reconfigurator-execution branch October 8, 2024 06:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants