Repository navigation
[nexus] factor out instance management into free functions - #5622
Merged
Merged
Conversation
hawkw
requested review from
andrewjstone,
bnaecker,
internet-diglett and
smklein
and removed request for
bnaecker
April 25, 2024 18:21
hawkw
force-pushed
the
eliza/instance-refactor
branch
from
April 25, 2024 19:16
356facd to
503ad20
Compare
smklein
approved these changes
Apr 25, 2024
smklein
left a comment
Collaborator
There was a problem hiding this comment.
Thanks for refactoring this into a separate PR! I appreciate this mechanical stuff being easier to look at
hawkw
enabled auto-merge (squash)
April 25, 2024 19:56
sunshowers
added a commit
that referenced
this pull request
Apr 26, 2024
Conflict between #5596 and #5622. * #5596 changed `DataStore::sled_list` to take a `SledFilter` argument -- and `Nexus::sled_list` always uses `InService`. * #5622 made the functions call `DataStore::sled_list` instead of `Nexus::sled_list` Not entirely sure that `InService` is correct, but it seems fine to just have all non-expunged sleds here for now.
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.
Currently, the instance state management code in nexus is implemented as methods on the
Nexustype. This is problematic, as these methods can only be called in HTTP endpoints, and not from background tasks or sagas. For example, as part of #5611, I needed to call theNexus::notify_instance_updatedmethod from a background task, which isn't possible with the current factoring. Therefore, this PR moves that method and its dependencies, as well as all the methods in theinstance_networkmodule into free functions that can be called without aNexusreference.The
Nexusmethods are left in place in order to avoid having to update all the callers as part of this PR, but they now just call into the free functions. The free functions take a few more arguments that are provided by the&selfreference in theNexusmethods, such as the internal DNSResolverandopctx_alloc, so the methods pass these in from&self, making them a bit more convenient to call when aNexusreference is available. For both of those reasons, I thought keeping them around was the right thing to do.I had briefly considered moving this code to a new
nexus-instancescrate, but it seemed a bit iffy to me asnotify_instance_updatedalso unregisters an Oximeter producer, and I didn't love the idea of moving Oximeter-related code to anexus-instancescrate --- perhaps it also ought to go in anexus-oximetercrate, or something, but that felt like a rabbit hole that I was afraid I might just end up going down forever, so I'll save it for later.If there are any functional changes as part of this PR, I've made a very bad mistake; this should be a pure refactor...