@@ -44,7 +44,6 @@ pub(crate) struct Params {
4444 pub create_params : params:: InstanceCreate ,
4545 pub boundary_switches : HashSet < SwitchLocation > ,
4646}
47-
4847// Several nodes in this saga are wrapped in their own subsaga so that they can
4948// have a parameter that denotes which node they are (e.g., which NIC or which
5049// external IP). They also need the outer saga's parameters.
@@ -1077,8 +1076,12 @@ async fn sic_set_boot_disk(
10771076 . await
10781077 . map_err ( ActionError :: action_failed) ?;
10791078
1080- let initial_configuration =
1081- nexus_db_model:: InstanceUpdate { boot_disk_id : Some ( authz_disk. id ( ) ) } ;
1079+ let initial_configuration = nexus_db_model:: InstanceUpdate {
1080+ boot_disk_id : Some ( authz_disk. id ( ) ) ,
1081+ // If this is `None`, whatever previous value was set when creating the
1082+ // instance will be unset and replaced with `NULL`. So don't do that!
1083+ auto_restart_policy : params. auto_restart_policy ( ) ,
1084+ } ;
10821085
10831086 datastore
10841087 . instance_reconfigure ( & opctx, & authz_instance, initial_configuration)
@@ -1109,8 +1112,14 @@ async fn sic_set_boot_disk_undo(
11091112
11101113 // If there was a boot disk, clear it. If there was not a boot disk,
11111114 // this is a no-op.
1112- let undo_configuration =
1113- nexus_db_model:: InstanceUpdate { boot_disk_id : None } ;
1115+ let undo_configuration = nexus_db_model:: InstanceUpdate {
1116+ boot_disk_id : None ,
1117+ // It would probably be fine to leave this as a `None` and clobber
1118+ // whatever's there with a NULL, since we are undoing the instance
1119+ // creation anyway, but it seems more proper to leave it untouched and
1120+ // only undo the boot disk configuration.
1121+ auto_restart_policy : params. auto_restart_policy ( ) ,
1122+ } ;
11141123
11151124 datastore
11161125 . instance_reconfigure ( & opctx, & authz_instance, undo_configuration)
@@ -1157,6 +1166,15 @@ async fn sic_move_to_stopped(
11571166 Ok ( ( ) )
11581167}
11591168
1169+ impl Params {
1170+ /// Returns the desired auto-restart policy for the created instance, or
1171+ /// `None` if one was not specified.
1172+ fn auto_restart_policy (
1173+ & self ,
1174+ ) -> Option < db:: model:: InstanceAutoRestartPolicy > {
1175+ self . create_params . auto_restart_policy . map ( Into :: into)
1176+ }
1177+ }
11601178#[ cfg( test) ]
11611179pub mod test {
11621180 use crate :: {
0 commit comments