33// file, You can obtain one at https://mozilla.org/MPL/2.0/.
44
55//! Fault management types.
6+ //!
7+ //! Of particular importance is the [`Sitrep`], which is the top-level data
8+ //! structure containing fault management state.
69
710use chrono:: { DateTime , Utc } ;
811use omicron_uuid_kinds:: { CollectionUuid , OmicronZoneUuid , SitrepUuid } ;
912use schemars:: JsonSchema ;
1013use serde:: { Deserialize , Serialize } ;
1114
15+ /// A fault management situation report, or _sitrep_.
16+ ///
17+ /// The sitrep is a data structure that represents a snapshot of the state of
18+ /// the system as understood by the control plane's fault management subsystem.
19+ /// At any point in time, a single sitrep is considered the "current" sitrep.
20+ /// Each sitrep records a _parent sitrep ID_, which indicates the sitrep that
21+ /// was current at the time that the sitrep was created.
22+ /// A sitrep may only be made current if its parent is the current sitrep.
23+ /// This ensures that there is a sequentially consistent history of sitreps.
24+ /// The fault management subsystem only considers data from the current sitrep
25+ /// when making decisions and diagnoses.
26+ ///
27+ /// The sitrep, how it is represented in the database, and how the fault
28+ /// management subsystem creates and interacts with sitreps, is described in
29+ /// detail in [RFD 603](https://rfd.shared.oxide.computer/rfd/0603).
1230#[ derive( Clone , Debug , Eq , PartialEq , JsonSchema , Deserialize , Serialize ) ]
1331pub struct Sitrep {
32+ /// Metadata describing this sitrep, when it was created, its parent sitrep
33+ /// ID, and which Nexus produced it.
1434 pub metadata : SitrepMetadata ,
1535 // TODO(eliza): draw the rest of the sitrep
1636}
@@ -25,19 +45,52 @@ impl Sitrep {
2545 }
2646}
2747
28- #[ derive( Clone , Debug , Eq , PartialEq , JsonSchema , Deserialize , Serialize ) ]
29- pub struct SitrepVersion {
30- pub id : SitrepUuid ,
31- pub version : u32 ,
32- pub time_made_current : DateTime < Utc > ,
33- }
34-
48+ /// Metadata describing a sitrep.
49+ ///
50+ /// This corresponds to the records stored in the `fm_sitrep` database table.
3551#[ derive( Clone , Debug , Eq , PartialEq , JsonSchema , Deserialize , Serialize ) ]
3652pub struct SitrepMetadata {
53+ /// The ID of this sitrep.
3754 pub id : SitrepUuid ,
55+
56+ /// The ID of the parent sitrep.
57+ ///
58+ /// A sitrep's _parent_ is the sitrep that was current when the planning
59+ /// phase that produced that sitrep ran. The parent sitrep is a planning
60+ /// input that produced this sitrep.
61+ ///
62+ /// The parent sitrep ID is optional, because this sitrep _may_ be the first
63+ /// sitrep ever generated by the system. However, once a current sitrep has
64+ /// been set, no subsequent sitrep should be created without a parent.
3865 pub parent_sitrep_id : Option < SitrepUuid > ,
66+
67+ /// The ID of the inventory collection that was used as planning input to
68+ /// this sitrep.
69+ ///
70+ /// When generating a new sitrep, the fault manager should ensure that the
71+ /// inventory collection it uses as input is at least as new as the parent
72+ /// sitrep's inventory collection.
3973 pub inv_collection_id : CollectionUuid ,
74+
75+ /// The Omicron zone UUID of the Nexus that generated this sitrep.
76+ ///
77+ /// This is intended for debugging purposes.
4078 pub creator_id : OmicronZoneUuid ,
79+
80+ /// A human-readable (but mechanically generated) string describing the
81+ /// reason(s) this sitrep was created.
82+ ///
83+ /// This is intended for debugging purposes.
4184 pub comment : String ,
85+
86+ /// The time at which this sitrep was created.
4287 pub time_created : DateTime < Utc > ,
4388}
89+
90+ /// An entry in the sitrep version history.
91+ #[ derive( Clone , Debug , Eq , PartialEq , JsonSchema , Deserialize , Serialize ) ]
92+ pub struct SitrepVersion {
93+ pub id : SitrepUuid ,
94+ pub version : u32 ,
95+ pub time_made_current : DateTime < Utc > ,
96+ }
0 commit comments