@@ -43,6 +43,8 @@ use nexus_db_schema::schema::{
43
43
} ;
44
44
use nexus_sled_agent_shared:: inventory:: BootImageHeader ;
45
45
use nexus_sled_agent_shared:: inventory:: BootPartitionDetails ;
46
+ use nexus_sled_agent_shared:: inventory:: ClearMupdateOverrideBootSuccessInventory ;
47
+ use nexus_sled_agent_shared:: inventory:: ClearMupdateOverrideInventory ;
46
48
use nexus_sled_agent_shared:: inventory:: ConfigReconcilerInventoryStatus ;
47
49
use nexus_sled_agent_shared:: inventory:: HostPhase2DesiredContents ;
48
50
use nexus_sled_agent_shared:: inventory:: HostPhase2DesiredSlots ;
@@ -998,6 +1000,8 @@ pub struct InvSledConfigReconciler {
998
1000
boot_disk_error : Option < String > ,
999
1001
pub boot_partition_a_error : Option < String > ,
1000
1002
pub boot_partition_b_error : Option < String > ,
1003
+ #[ diesel( embed) ]
1004
+ pub clear_mupdate_override : InvClearMupdateOverride ,
1001
1005
}
1002
1006
1003
1007
impl InvSledConfigReconciler {
@@ -1008,6 +1012,7 @@ impl InvSledConfigReconciler {
1008
1012
boot_disk : Result < M2Slot , String > ,
1009
1013
boot_partition_a_error : Option < String > ,
1010
1014
boot_partition_b_error : Option < String > ,
1015
+ clear_mupdate_override : InvClearMupdateOverride ,
1011
1016
) -> Self {
1012
1017
// TODO-cleanup We should use `HwM2Slot` instead of integers for this
1013
1018
// column: https://github.com/oxidecomputer/omicron/issues/8642
@@ -1025,6 +1030,7 @@ impl InvSledConfigReconciler {
1025
1030
boot_disk_error,
1026
1031
boot_partition_a_error,
1027
1032
boot_partition_b_error,
1033
+ clear_mupdate_override,
1028
1034
}
1029
1035
}
1030
1036
@@ -1064,6 +1070,104 @@ impl InvSledConfigReconciler {
1064
1070
}
1065
1071
}
1066
1072
1073
+ // See [`nexus_sled_agent_shared::inventory::DbClearMupdateOverrideBootSuccess`].
1074
+ impl_enum_type ! (
1075
+ ClearMupdateOverrideBootSuccessEnum :
1076
+
1077
+ #[ derive( Copy , Clone , Debug , AsExpression , FromSqlRow , PartialEq ) ]
1078
+ pub enum DbClearMupdateOverrideBootSuccess ;
1079
+
1080
+ // Enum values
1081
+ Cleared => b"cleared"
1082
+ NoOverride => b"no-override"
1083
+ ) ;
1084
+
1085
+ impl From < ClearMupdateOverrideBootSuccessInventory >
1086
+ for DbClearMupdateOverrideBootSuccess
1087
+ {
1088
+ fn from ( value : ClearMupdateOverrideBootSuccessInventory ) -> Self {
1089
+ match value {
1090
+ ClearMupdateOverrideBootSuccessInventory :: Cleared => Self :: Cleared ,
1091
+ ClearMupdateOverrideBootSuccessInventory :: NoOverride => {
1092
+ Self :: NoOverride
1093
+ }
1094
+ }
1095
+ }
1096
+ }
1097
+
1098
+ impl From < DbClearMupdateOverrideBootSuccess >
1099
+ for ClearMupdateOverrideBootSuccessInventory
1100
+ {
1101
+ fn from ( value : DbClearMupdateOverrideBootSuccess ) -> Self {
1102
+ match value {
1103
+ DbClearMupdateOverrideBootSuccess :: Cleared => Self :: Cleared ,
1104
+ DbClearMupdateOverrideBootSuccess :: NoOverride => Self :: NoOverride ,
1105
+ }
1106
+ }
1107
+ }
1108
+
1109
+ /// See [`nexus_sled_agent_shared::inventory::ClearMupdateOverrideInventory`].
1110
+ #[ derive( Queryable , Clone , Debug , Selectable , Insertable ) ]
1111
+ #[ diesel( table_name = inv_sled_config_reconciler) ]
1112
+ pub struct InvClearMupdateOverride {
1113
+ #[ diesel( column_name = clear_mupdate_override_boot_success) ]
1114
+ pub boot_success : Option < DbClearMupdateOverrideBootSuccess > ,
1115
+
1116
+ #[ diesel( column_name = clear_mupdate_override_boot_error) ]
1117
+ pub boot_error : Option < String > ,
1118
+
1119
+ #[ diesel( column_name = clear_mupdate_override_non_boot_message) ]
1120
+ pub non_boot_message : Option < String > ,
1121
+ }
1122
+
1123
+ impl InvClearMupdateOverride {
1124
+ pub fn new (
1125
+ clear_mupdate_override : Option < & ClearMupdateOverrideInventory > ,
1126
+ ) -> Self {
1127
+ let boot_success = clear_mupdate_override. and_then ( |inv| {
1128
+ inv. boot_disk_result . as_ref ( ) . ok ( ) . map ( |v| v. clone ( ) . into ( ) )
1129
+ } ) ;
1130
+ let boot_error = clear_mupdate_override
1131
+ . and_then ( |inv| inv. boot_disk_result . as_ref ( ) . err ( ) . cloned ( ) ) ;
1132
+ let non_boot_message =
1133
+ clear_mupdate_override. map ( |inv| inv. non_boot_message . clone ( ) ) ;
1134
+
1135
+ Self { boot_success, boot_error, non_boot_message }
1136
+ }
1137
+
1138
+ pub fn into_inventory (
1139
+ self ,
1140
+ ) -> anyhow:: Result < Option < ClearMupdateOverrideInventory > > {
1141
+ match self {
1142
+ Self {
1143
+ boot_success : Some ( success) ,
1144
+ boot_error : None ,
1145
+ non_boot_message : Some ( non_boot_message) ,
1146
+ } => Ok ( Some ( ClearMupdateOverrideInventory {
1147
+ boot_disk_result : Ok ( success. into ( ) ) ,
1148
+ non_boot_message,
1149
+ } ) ) ,
1150
+ Self {
1151
+ boot_success : None ,
1152
+ boot_error : Some ( boot_error) ,
1153
+ non_boot_message : Some ( non_boot_message) ,
1154
+ } => Ok ( Some ( ClearMupdateOverrideInventory {
1155
+ boot_disk_result : Err ( boot_error) ,
1156
+ non_boot_message,
1157
+ } ) ) ,
1158
+ Self {
1159
+ boot_success : None ,
1160
+ boot_error : None ,
1161
+ non_boot_message : None ,
1162
+ } => Ok ( None ) ,
1163
+ this => Err ( anyhow ! (
1164
+ "inv_sled_config_reconciler CHECK constraint violated: \
1165
+ clear mupdate override columns are not consistent: {this:?}"
1166
+ ) ) ,
1167
+ }
1168
+ }
1169
+ }
1170
+
1067
1171
/// See [`nexus_sled_agent_shared::inventory::BootPartitionDetails`].
1068
1172
#[ derive( Queryable , Clone , Debug , Selectable , Insertable ) ]
1069
1173
#[ diesel( table_name = inv_sled_boot_partition) ]
0 commit comments