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

Fix filters for probe v2p mappings #5960

Merged
merged 5 commits into from
Jul 3, 2024
Merged

Conversation

internet-diglett
Copy link
Contributor

During the changes made in #5917, we accidentally filtered for instances when querying for probe v2p mappings. This PR fixes that filter, and also updates the v2p mapping RPW to use the SledFilter::V2PMapping enum.

@@ -44,23 +42,19 @@ impl BackgroundTask for V2PManager {

// Get sleds
// we only care about sleds that are active && inservice
let sleds = match self.datastore.sled_list_all_batched(opctx, SledFilter::InService).await
let sleds = match self.datastore.sled_list_all_batched(opctx, SledFilter::V2PMapping).await
Copy link
Contributor

Choose a reason for hiding this comment

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

I've basically cribbed the same logic from this block to select the sleds we talk to in the VPC route background task:

let sleds = match self
.datastore
.sled_list_all_batched(opctx, SledFilter::InService)
.await
{
Ok(v) => v,
Err(e) => {
let msg = format!("failed to enumerate sleds: {:#}", e);
error!(&log, "{msg}");
return json!({"error": msg});
}
}
.into_iter()
.filter(|sled| {
matches!(sled.state(), SledState::Active)
&& matches!(sled.policy(), SledPolicy::InService { .. })
});
// Map sled db records to sled-agent clients
let sled_clients: Vec<(Sled, sled_agent_client::Client)> = sleds
.map(|sled| {
let client = sled_client_from_address(
sled.id(),
sled.address(),
&log,
);
(sled, client)
})
.collect();

Is this fix something we should apply there, too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It could cause issues if we want these sleds to receive updates / be managed even after they are marked as non_provisionable, as in this issue:
#5872

Does that scenario apply here?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it does; my understanding of 'non-provisionable' is that we're not placing new instances on such a sled, but existing ones should still function as intended? In that case we should be making sure that those sleds have up-to-date routing tables for their instances' OPTE ports while they still exist.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, so maybe we need to rename it from SledFilter::V2PMapping to SledFilter::VpcConfig or similar and apply it to both RPWs?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that would work!

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd like to make this less error-prone! The docs on SledFilter have this note:

/// The meaning of a particular filter should not be overloaded -- each time a
/// new use case wants to make a decision based on the zone disposition, a new
/// variant should be added to this enum.

but I imagine it's easy to miss and InService seems general to a fault, given that guidance. I'm inclined to try removing the InService variant altogether and updating all its users with more specific variant names, but am open to other suggestions!

Copy link
Contributor

Choose a reason for hiding this comment

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

Also FWIW, I believe SledFilter::InService actually does do the right thing here - it includes sleds that are not provisionable. #5872 was caused by the raw DB query inspecting the sled policy/state columns directly and not going through the SledFilter machinery at all. That said, I stand by the previous point that I think InService is still too general and will still try the renaming exercise.

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks good, thank you!

@internet-diglett internet-diglett merged commit 30b6713 into main Jul 3, 2024
19 checks passed
@internet-diglett internet-diglett deleted the update-filter-in-v2p-task branch July 3, 2024 21:56
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.

3 participants