diff --git a/nexus/db-model/src/instance.rs b/nexus/db-model/src/instance.rs index 52cee475f2a..966be5e75f8 100644 --- a/nexus/db-model/src/instance.rs +++ b/nexus/db-model/src/instance.rs @@ -110,7 +110,10 @@ impl Instance { ncpus: params.ncpus.into(), memory: params.memory.into(), hostname: params.hostname.to_string(), - auto_restart_policy: params.auto_restart_policy.clone().into(), + auto_restart_policy: params + .auto_restart_policy + .clone() + .map(Into::into), runtime_state, updater_gen: Generation::new(), @@ -124,7 +127,11 @@ impl Instance { /// Returns `true` if this instance can be automatically restarted. pub fn can_reincarnate(&self) -> bool { - self.runtime_state.can_reincarnate(self.auto_restart_policy) + self.auto_restart_policy + .map(|policy| self.runtime_state.can_reincarnate(policy)) + // If the instance does not have a specified auto-restart policy, + // assume it cannot be restarted. + .unwrap_or(false) } } diff --git a/nexus/types/src/external_api/params.rs b/nexus/types/src/external_api/params.rs index 6c8c029a355..d57c2a60b41 100644 --- a/nexus/types/src/external_api/params.rs +++ b/nexus/types/src/external_api/params.rs @@ -1061,11 +1061,8 @@ pub struct InstanceCreate { /// A policy that indicates whether the control plane should automatically /// restart this instance if it fails. - /// - /// If this is not provided, it defaults to the "sled_failures_only" - /// auto-restart policy. #[serde(default)] - pub auto_restart_policy: InstanceAutoRestart, + pub auto_restart_policy: Option, } #[inline] diff --git a/openapi/nexus.json b/openapi/nexus.json index 84aab15134e..1574f85efad 100644 --- a/openapi/nexus.json +++ b/openapi/nexus.json @@ -15227,10 +15227,9 @@ "type": "object", "properties": { "auto_restart_policy": { - "description": "A policy that indicates whether the control plane should automatically restart this instance if it fails.\n\nIf this is not provided, it defaults to the \"sled_failures_only\" auto-restart policy.", - "default": { - "type": "sled_failures_only" - }, + "nullable": true, + "description": "A policy that indicates whether the control plane should automatically restart this instance if it fails.", + "default": null, "allOf": [ { "$ref": "#/components/schemas/InstanceAutoRestart"