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

[sled-agent][sim] Use a shared support bundle implementation #7264

Open
wants to merge 3 commits into
base: support-bundles-crdb
Choose a base branch
from

Conversation

smklein
Copy link
Collaborator

@smklein smklein commented Dec 17, 2024

PR 3 / ???

This PR aims to re-use the support bundle management logic in sled-agent/src/support_bundle/storage.rs for both the real and simulated sled agent.

It accomplishes this goal with the following:

  1. It creates a trait, LocalStorage, that abstracts access to storage. The "real" sled agent accesses real storage, the simulated sled agent can access the simulated storage APIs.
  2. Reduce the usage of unnecessary async mutexes to make lifetimes slightly more manageable. This happens to align with our guidance in RFD 400 (https://rfd.shared.oxide.computer/rfd/400#no_mutex), but has a fall-out impact in replacing .await calls throughout Omicron.

As an end result of this PR, tests in subsequent PRs (e.g. #7063) can rely on the simulated sled agent to respond realistically to support bundle requests, rather than using a stub implementation.

@smklein smklein changed the title [sled-agent][sim] Use a shared support bundle implementation for the simulated sled agent [sled-agent][sim] Use a shared support bundle implementation Dec 17, 2024
Copy link
Contributor

@wfchandler wfchandler left a comment

Choose a reason for hiding this comment

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

Thanks @smklein, this wrapper trait seems reasonable to me. Two related questions around how we're walking the path of nested datasets.

Comment on lines +1218 to +1227
// Final component of path -- remove it if it exists.
if !path_component.contains('/') {
if nested_dataset.children.remove(path_component).is_none() {
return Err(HttpError::for_not_found(
None,
"Nested Dataset not found".to_string(),
));
};
return Ok(());
}
Copy link
Contributor

Choose a reason for hiding this comment

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

As above, no component will contain /, so we'll always exit early and fail to iterate past the first component.

Comment on lines +1165 to +1183
// Final component of path -- insert it here if it doesn't exist
// already.
if !path_component.contains('/') {
let entry =
nested_dataset.children.entry(path_component.to_string());
entry
.and_modify(|storage| {
storage.config = config.clone();
})
.or_insert_with(|| {
NestedDatasetStorage::new(
&zpool_root,
config.name.root,
nested_path,
config.inner,
)
});
return Ok(());
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This condition will always evaluate to true since we're splitting path_component on /, so we'll never walk the full path.

https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=530576a88d3a03606274a9d488462528

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.

2 participants