-
Notifications
You must be signed in to change notification settings - Fork 59
[support bundle] Refactor into tasks #9253
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
base: main
Are you sure you want to change the base?
Conversation
} | ||
|
||
type CollectionStepFn = Box< | ||
dyn for<'b> FnOnce( |
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 signature looks a little nasty, but it's basically just saying:
- Every "step" acts on a BundleCollection,
- ... has an output directory
- ... and can emit a CollectionStepOutput object (which either updates the report, or makes more steps)
let mut tasks = | ||
ParallelTaskSet::new_with_parallelism(MAX_CONCURRENT_STEPS); |
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.
Previously, we had some ParallelTaskSets embedded within the collection of sub-pieces of the bundle.
This new "step-based" infrastructure shares that more broadly - everything should be using this one ParallelTaskSet (which is good? that prevents a task that spawns a bunch of other task set, that spawns more task sets - everything is just a unit of work that can get added to this one set).
|
||
let ereport_collection = if let Some(ref ereport_filters) = | ||
self.request.ereport_query | ||
async fn collect_host_ereports( |
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 prior mechanism of collecting ereports from {host, sp} did a bit of manual task management, and stored atomics within the bundle itself.
I've just made each part of the ereport collection a distinct step: no more atomics, no more manual tokio tasks - each one is just "one step" with output.
async fn get_or_initialize_mgs_client<'a>( | ||
&self, | ||
mgs_client: &'a OnceCell<Arc<Option<MgsClient>>>, | ||
) -> &'a Arc<Option<MgsClient>> { | ||
mgs_client | ||
.get_or_init(|| async { | ||
Arc::new(self.create_mgs_client().await.ok()) | ||
}) | ||
.await | ||
} | ||
|
||
const MAX_CONCURRENT_SLED_REQUESTS: usize = 16; | ||
const FAILURE_MESSAGE: &str = | ||
"Failed to fully collect support bundle info from sled"; | ||
let mut set = ParallelTaskSet::new_with_parallelism( | ||
MAX_CONCURRENT_SLED_REQUESTS, | ||
async fn get_or_initialize_all_sleds<'a>( | ||
&self, | ||
all_sleds: &'a OnceCell<Arc<Option<Vec<Sled>>>>, | ||
) -> &'a Arc<Option<Vec<Sled>>> { | ||
all_sleds | ||
.get_or_init(|| async { | ||
Arc::new( | ||
self.datastore | ||
.sled_list_all_batched( | ||
&self.opctx, | ||
SledFilter::InService, | ||
) | ||
.await | ||
.ok(), | ||
) | ||
}) | ||
.await |
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'm using lazily-initialized variables for "data/clients that might get created as a part of bundle collection, but might not".
This becomes more relevant with #9254, when we may or may not need these values to get initialized at all.
|
||
let mut extra_steps: Vec<(&'static str, CollectionStepFn)> = vec![]; | ||
for sp in get_available_sps(&mgs_client).await? { | ||
extra_steps.push(( |
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.
Rather than collecting all SP reports via new tokio tasks, these are creating new "steps" that get kicked back to the top-level ParallelTaskSet
I mentioned earlier.
Re-structures support bundle collection into tasks.
This centralizes step dispatching, and makes it slightly more clear that tasks are independent (where they can be).