Skip to content

Commit df95650

Browse files
committed
[support bundles] Don't fail already-collected bundles
1 parent 124a672 commit df95650

File tree

3 files changed

+33
-27
lines changed

3 files changed

+33
-27
lines changed

nexus/db-queries/src/db/datastore/support_bundle.rs

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -191,23 +191,34 @@ impl DataStore {
191191
.map_err(|e| public_error_from_diesel(e, ErrorHandler::Server))
192192
}
193193

194-
/// Lists one page of support bundles in a particular state, assigned to
195-
/// a particular Nexus.
194+
/// Lists one page of support bundles in a particular state.
195+
///
196+
/// If `nexus_id` is not None, also filters for bundles assigned to a
197+
/// particular Nexus. Otherwise, lists all bundles in the requested
198+
/// states.
196199
pub async fn support_bundle_list_assigned_to_nexus(
197200
&self,
198201
opctx: &OpContext,
199202
pagparams: &DataPageParams<'_, Uuid>,
200-
nexus_id: OmicronZoneUuid,
203+
nexus_id: Option<OmicronZoneUuid>,
201204
states: Vec<SupportBundleState>,
202205
) -> ListResultVec<SupportBundle> {
203206
opctx.authorize(authz::Action::Read, &authz::FLEET).await?;
204207
use nexus_db_schema::schema::support_bundle::dsl;
205208

206209
let conn = self.pool_connection_authorized(opctx).await?;
207-
paginated(dsl::support_bundle, dsl::id, pagparams)
208-
.filter(dsl::assigned_nexus.eq(nexus_id.into_untyped_uuid()))
210+
let query = paginated(dsl::support_bundle, dsl::id, pagparams)
209211
.filter(dsl::state.eq_any(states))
210-
.order(dsl::time_created.asc())
212+
.order(dsl::time_created.asc());
213+
214+
let query = match nexus_id {
215+
Some(id) => {
216+
query.filter(dsl::assigned_nexus.eq(id.into_untyped_uuid()))
217+
}
218+
None => query,
219+
};
220+
221+
query
211222
.select(SupportBundle::as_select())
212223
.load_async(&*conn)
213224
.await
@@ -324,8 +335,9 @@ impl DataStore {
324335
.execute_async(conn)
325336
.await?;
326337

327-
// Find all bundles on nexuses that no longer exist.
338+
// Find all collecting bundles on nexuses that no longer exist.
328339
let bundles_with_bad_nexuses = dsl::support_bundle
340+
.filter(dsl::state.eq(SupportBundleState::Collecting))
329341
.filter(dsl::assigned_nexus.eq_any(invalid_nexus_zones))
330342
.select(SupportBundle::as_select())
331343
.load_async(conn)
@@ -704,7 +716,7 @@ mod test {
704716
.support_bundle_list_assigned_to_nexus(
705717
&opctx,
706718
&pagparams,
707-
nexus_a,
719+
Some(nexus_a),
708720
vec![SupportBundleState::Collecting]
709721
)
710722
.await
@@ -732,7 +744,7 @@ mod test {
732744
.support_bundle_list_assigned_to_nexus(
733745
&opctx,
734746
&pagparams,
735-
nexus_a,
747+
Some(nexus_a),
736748
vec![SupportBundleState::Collecting]
737749
)
738750
.await
@@ -747,7 +759,7 @@ mod test {
747759
.support_bundle_list_assigned_to_nexus(
748760
&opctx,
749761
&pagparams,
750-
nexus_b,
762+
Some(nexus_b),
751763
vec![SupportBundleState::Collecting]
752764
)
753765
.await
@@ -776,7 +788,7 @@ mod test {
776788
.support_bundle_list_assigned_to_nexus(
777789
&opctx,
778790
&pagparams,
779-
nexus_a,
791+
Some(nexus_a),
780792
vec![SupportBundleState::Collecting]
781793
)
782794
.await
@@ -793,7 +805,7 @@ mod test {
793805
.support_bundle_list_assigned_to_nexus(
794806
&opctx,
795807
&pagparams,
796-
nexus_a,
808+
Some(nexus_a),
797809
vec![
798810
SupportBundleState::Active,
799811
SupportBundleState::Collecting
@@ -1435,15 +1447,16 @@ mod test {
14351447
};
14361448
bp_insert_and_make_target(&opctx, &datastore, &bp2).await;
14371449

1450+
// The bundle still appears active
14381451
let report = datastore
14391452
.support_bundle_fail_expunged(&opctx, &bp2, nexus_ids[1])
14401453
.await
14411454
.expect("Should have been able to mark bundle state as destroying");
14421455

14431456
assert_eq!(
14441457
SupportBundleExpungementReport {
1445-
bundles_failing_missing_nexus: 1,
1446-
bundles_reassigned: 1,
1458+
bundles_failing_missing_nexus: 0,
1459+
bundles_reassigned: 0,
14471460
..Default::default()
14481461
},
14491462
report
@@ -1453,13 +1466,7 @@ mod test {
14531466
.support_bundle_get(&opctx, bundle.id.into())
14541467
.await
14551468
.expect("Should be able to get bundle we just failed");
1456-
assert_eq!(SupportBundleState::Failing, observed_bundle.state);
1457-
assert!(
1458-
observed_bundle
1459-
.reason_for_failure
1460-
.unwrap()
1461-
.contains(FAILURE_REASON_NO_NEXUS)
1462-
);
1469+
assert_eq!(SupportBundleState::Active, observed_bundle.state);
14631470

14641471
db.terminate().await;
14651472
logctx.cleanup_successful();

nexus/src/app/background/tasks/support_bundle_collector.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,8 @@ impl SupportBundleCollector {
278278
}
279279
}
280280

281-
// Monitors all bundles that are "destroying" or "failing" and assigned to
282-
// this Nexus, and attempts to clear their storage from Sled Agents.
281+
// Monitors all bundles that are "destroying" or "failing" and attempts to
282+
// clear their storage from Sled Agents.
283283
async fn cleanup_destroyed_bundles(
284284
&self,
285285
opctx: &OpContext,
@@ -290,7 +290,7 @@ impl SupportBundleCollector {
290290
.support_bundle_list_assigned_to_nexus(
291291
opctx,
292292
&pagparams,
293-
self.nexus_id,
293+
None,
294294
vec![
295295
SupportBundleState::Destroying,
296296
SupportBundleState::Failing,
@@ -390,7 +390,7 @@ impl SupportBundleCollector {
390390
.support_bundle_list_assigned_to_nexus(
391391
opctx,
392392
&pagparams,
393-
self.nexus_id,
393+
Some(self.nexus_id),
394394
vec![SupportBundleState::Collecting],
395395
)
396396
.await;

schema/crdb/dbinit.sql

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2822,8 +2822,7 @@ CREATE TABLE IF NOT EXISTS omicron.public.support_bundle (
28222822
zpool_id UUID NOT NULL,
28232823
dataset_id UUID NOT NULL,
28242824

2825-
-- The Nexus which is in charge of collecting the support bundle,
2826-
-- and later managing its storage.
2825+
-- The Nexus which is in charge of collecting the support bundle.
28272826
assigned_nexus UUID,
28282827

28292828
user_comment TEXT

0 commit comments

Comments
 (0)