44
55//! Support bundle request types and data selection
66
7- use nexus_db_queries:: db:: datastore:: EreportFilters ;
7+ use nexus_types:: fm:: ereport:: EreportFilters ;
8+ use nexus_types:: support_bundle:: {
9+ BundleData , BundleDataCategory , BundleDataSelection , SledSelection ,
10+ } ;
11+
812use omicron_uuid_kinds:: SledUuid ;
9- use std:: collections:: HashMap ;
10- use std:: collections:: HashSet ;
1113use std:: num:: NonZeroU64 ;
1214
1315/// We use "/var/tmp" to use Nexus' filesystem for temporary storage,
@@ -18,121 +20,6 @@ pub const TEMPDIR: &str = "/var/tmp";
1820/// within a single streaming request.
1921pub const CHUNK_SIZE : NonZeroU64 = NonZeroU64 :: new ( 1024 * 1024 * 1024 ) . unwrap ( ) ;
2022
21- /// Describes the category of support bundle data.
22- #[ derive( Debug , Clone , Copy , Hash , Eq , PartialEq ) ]
23- pub enum BundleDataCategory {
24- /// Collects reconfigurator state (some of the latest blueprints,
25- /// information about the target blueprint).
26- Reconfigurator ,
27- /// Collects info from sled agents, running a handful of
28- /// diagnostic commands (e.g., zoneadm, dladm, etc).
29- HostInfo ,
30- /// Collects sled serial numbers, cubby numbers, and UUIDs.
31- SledCubbyInfo ,
32- /// Saves task dumps from SPs.
33- SpDumps ,
34- /// Collects ereports.
35- Ereports ,
36- }
37-
38- /// Specifies what data to collect for a bundle data category.
39- ///
40- /// Each variant corresponds to a BundleDataCategory.
41- /// For categories without additional parameters, the variant is a unit variant.
42- /// For categories that can be filtered or configured, the variant contains
43- /// that configuration data.
44- #[ derive( Debug , Clone , Eq , PartialEq ) ]
45- pub enum BundleData {
46- Reconfigurator ,
47- HostInfo ( HashSet < SledSelection > ) ,
48- SledCubbyInfo ,
49- SpDumps ,
50- Ereports ( EreportFilters ) ,
51- }
52-
53- impl BundleData {
54- fn category ( & self ) -> BundleDataCategory {
55- match self {
56- Self :: Reconfigurator => BundleDataCategory :: Reconfigurator ,
57- Self :: HostInfo ( _) => BundleDataCategory :: HostInfo ,
58- Self :: SledCubbyInfo => BundleDataCategory :: SledCubbyInfo ,
59- Self :: SpDumps => BundleDataCategory :: SpDumps ,
60- Self :: Ereports ( _) => BundleDataCategory :: Ereports ,
61- }
62- }
63- }
64-
65- /// A collection of bundle data specifications.
66- ///
67- /// This wrapper ensures that categories and data always match - you can't
68- /// insert (BundleDataCategory::Reconfigurator, BundleData::SpDumps)
69- /// because each BundleData determines its own category.
70- #[ derive( Debug , Clone ) ]
71- pub struct BundleDataSelection {
72- data : HashMap < BundleDataCategory , BundleData > ,
73- }
74-
75- impl BundleDataSelection {
76- pub fn new ( ) -> Self {
77- Self { data : HashMap :: new ( ) }
78- }
79-
80- /// Inserts BundleData to be queried for a particular category within the
81- /// bundle.
82- ///
83- /// Each category of data can only be specified once (e.g., inserting
84- /// BundleData::HostInfo multiple times will only use the most-recently
85- /// inserted specification)
86- pub fn insert ( & mut self , bundle_data : BundleData ) {
87- self . data . insert ( bundle_data. category ( ) , bundle_data) ;
88- }
89-
90- pub fn contains ( & self , category : BundleDataCategory ) -> bool {
91- self . data . contains_key ( & category)
92- }
93-
94- pub fn get ( & self , category : BundleDataCategory ) -> Option < & BundleData > {
95- self . data . get ( & category)
96- }
97- }
98-
99- impl FromIterator < BundleData > for BundleDataSelection {
100- fn from_iter < T : IntoIterator < Item = BundleData > > ( iter : T ) -> Self {
101- let mut selection = Self :: new ( ) ;
102- for bundle_data in iter {
103- selection. insert ( bundle_data) ;
104- }
105- selection
106- }
107- }
108-
109- impl Default for BundleDataSelection {
110- fn default ( ) -> Self {
111- [
112- BundleData :: Reconfigurator ,
113- BundleData :: HostInfo ( HashSet :: from ( [ SledSelection :: All ] ) ) ,
114- BundleData :: SledCubbyInfo ,
115- BundleData :: SpDumps ,
116- BundleData :: Ereports ( EreportFilters {
117- start_time : Some ( chrono:: Utc :: now ( ) - chrono:: Days :: new ( 7 ) ) ,
118- ..EreportFilters :: default ( )
119- } ) ,
120- ]
121- . into_iter ( )
122- . collect ( )
123- }
124- }
125-
126- /// The set of sleds to include
127- ///
128- /// Multiple values of this enum are joined together into a HashSet.
129- /// Therefore "SledSelection::All" overrides specific sleds.
130- #[ derive( Debug , Clone , Hash , Eq , PartialEq ) ]
131- pub enum SledSelection {
132- All ,
133- Specific ( SledUuid ) ,
134- }
135-
13623/// Specifies the data to be collected within the Support Bundle.
13724#[ derive( Clone ) ]
13825pub struct BundleRequest {
0 commit comments