Skip to content

Commit bc41f54

Browse files
authored
[api] Improve instance auto_restart_policy docs (#6959)
Currently, the documentation for the `auto_restart_policy` field in the `params::InstanceCreate` and `params::InstanceUpdate` types doesn't really explain the meaning of a `null` auto-restart policy. The comment on the `AutoRestartStatus` type in the instance *view* API does explain that `null` means "use whatever the default currently is", but this isn't obvious on the APIs where a user would actually *set* the policy to `null`. This was an oversight on my part, and this commit corrects it. Thanks @david-crespo for noticing! Fixes #6957
1 parent 60c9775 commit bc41f54

File tree

5 files changed

+41
-16
lines changed

5 files changed

+41
-16
lines changed

common/src/api/external/mod.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,13 +1225,16 @@ pub struct InstanceAutoRestartStatus {
12251225
#[serde(rename = "auto_restart_enabled")]
12261226
pub enabled: bool,
12271227

1228-
/// The auto-restart policy configured for this instance, or `None` if no
1229-
/// explicit policy is configured.
1228+
/// The auto-restart policy configured for this instance, or `null` if no
1229+
/// explicit policy has been configured.
12301230
///
1231-
/// If this is not present, then this instance uses the default auto-restart
1232-
/// policy, which may or may not allow it to be restarted. The
1233-
/// `auto_restart_enabled` field indicates whether the instance will be
1234-
/// automatically restarted.
1231+
/// This policy determines whether the instance should be automatically
1232+
/// restarted by the control plane on failure. If this is `null`, the
1233+
/// control plane will use the default policy when determining whether or
1234+
/// not to automatically restart this instance, which may or may not allow
1235+
/// it to be restarted. The value of the `auto_restart_enabled` field
1236+
/// indicates whether the instance will be auto-restarted, based on its
1237+
/// current policy or the default if it has no configured policy.
12351238
//
12361239
// Rename this field, as the struct is `#[serde(flatten)]`ed into the
12371240
// `Instance` type, and we would like the field to be prefixed with

nexus/db-model/src/instance.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,9 @@ pub struct InstanceAutoRestart {
259259
///
260260
/// This indicates whether the instance should be automatically restarted by
261261
/// the control plane on failure. If this is `NULL`, no auto-restart policy
262-
/// has been configured for this instance by the user.
262+
/// has been configured for this instance by the user. In that case, the
263+
/// control plane will use the default policy when determining whether
264+
/// this instance can be automatically restarted.
263265
#[diesel(column_name = auto_restart_policy)]
264266
#[serde(default)]
265267
pub policy: Option<InstanceAutoRestartPolicy>,

nexus/types/src/external_api/params.rs

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,9 +1137,18 @@ pub struct InstanceCreate {
11371137

11381138
/// The auto-restart policy for this instance.
11391139
///
1140-
/// This indicates whether the instance should be automatically restarted by
1141-
/// the control plane on failure. If this is `null`, no auto-restart policy
1142-
/// has been configured for this instance by the user.
1140+
/// This policy determines whether the instance should be automatically
1141+
/// restarted by the control plane on failure. If this is `null`, no
1142+
/// auto-restart policy will be explicitly configured for this instance, and
1143+
/// the control plane will select the default policy when determining
1144+
/// whether the instance can be automatically restarted.
1145+
///
1146+
/// Currently, the global default auto-restart policy is "best-effort", so
1147+
/// instances with `null` auto-restart policies will be automatically
1148+
/// restarted. However, in the future, the default policy may be
1149+
/// configurable through other mechanisms, such as on a per-project basis.
1150+
/// In that case, any configured default policy will be used if this is
1151+
/// `null`.
11431152
#[serde(default)]
11441153
pub auto_restart_policy: Option<InstanceAutoRestartPolicy>,
11451154
}
@@ -1152,9 +1161,20 @@ pub struct InstanceUpdate {
11521161
/// If not provided, unset the instance's boot disk.
11531162
pub boot_disk: Option<NameOrId>,
11541163

1155-
/// The auto-restart policy for this instance.
1164+
/// Sets the auto-restart policy for this instance.
1165+
///
1166+
/// This policy determines whether the instance should be automatically
1167+
/// restarted by the control plane on failure. If this is `null`, any
1168+
/// explicitly configured auto-restart policy will be unset, and
1169+
/// the control plane will select the default policy when determining
1170+
/// whether the instance can be automatically restarted.
11561171
///
1157-
/// If not provided, unset the instance's auto-restart policy.
1172+
/// Currently, the global default auto-restart policy is "best-effort", so
1173+
/// instances with `null` auto-restart policies will be automatically
1174+
/// restarted. However, in the future, the default policy may be
1175+
/// configurable through other mechanisms, such as on a per-project basis.
1176+
/// In that case, any configured default policy will be used if this is
1177+
/// `null`.
11581178
pub auto_restart_policy: Option<InstanceAutoRestartPolicy>,
11591179
}
11601180

openapi/nexus-internal.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3532,7 +3532,7 @@
35323532
},
35333533
"auto_restart_policy": {
35343534
"nullable": true,
3535-
"description": "The auto-restart policy configured for this instance, or `None` if no explicit policy is configured.\n\nIf this is not present, then this instance uses the default auto-restart policy, which may or may not allow it to be restarted. The `auto_restart_enabled` field indicates whether the instance will be automatically restarted.",
3535+
"description": "The auto-restart policy configured for this instance, or `null` if no explicit policy has been configured.\n\nThis policy determines whether the instance should be automatically restarted by the control plane on failure. If this is `null`, the control plane will use the default policy when determining whether or not to automatically restart this instance, which may or may not allow it to be restarted. The value of the `auto_restart_enabled` field indicates whether the instance will be auto-restarted, based on its current policy or the default if it has no configured policy.",
35363536
"allOf": [
35373537
{
35383538
"$ref": "#/components/schemas/InstanceAutoRestartPolicy"

openapi/nexus.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15816,7 +15816,7 @@
1581615816
},
1581715817
"auto_restart_policy": {
1581815818
"nullable": true,
15819-
"description": "The auto-restart policy configured for this instance, or `None` if no explicit policy is configured.\n\nIf this is not present, then this instance uses the default auto-restart policy, which may or may not allow it to be restarted. The `auto_restart_enabled` field indicates whether the instance will be automatically restarted.",
15819+
"description": "The auto-restart policy configured for this instance, or `null` if no explicit policy has been configured.\n\nThis policy determines whether the instance should be automatically restarted by the control plane on failure. If this is `null`, the control plane will use the default policy when determining whether or not to automatically restart this instance, which may or may not allow it to be restarted. The value of the `auto_restart_enabled` field indicates whether the instance will be auto-restarted, based on its current policy or the default if it has no configured policy.",
1582015820
"allOf": [
1582115821
{
1582215822
"$ref": "#/components/schemas/InstanceAutoRestartPolicy"
@@ -15941,7 +15941,7 @@
1594115941
"properties": {
1594215942
"auto_restart_policy": {
1594315943
"nullable": true,
15944-
"description": "The auto-restart policy for this instance.\n\nThis indicates whether the instance should be automatically restarted by the control plane on failure. If this is `null`, no auto-restart policy has been configured for this instance by the user.",
15944+
"description": "The auto-restart policy for this instance.\n\nThis policy determines whether the instance should be automatically restarted by the control plane on failure. If this is `null`, no auto-restart policy will be explicitly configured for this instance, and the control plane will select the default policy when determining whether the instance can be automatically restarted.\n\nCurrently, the global default auto-restart policy is \"best-effort\", so instances with `null` auto-restart policies will be automatically restarted. However, in the future, the default policy may be configurable through other mechanisms, such as on a per-project basis. In that case, any configured default policy will be used if this is `null`.",
1594515945
"default": null,
1594615946
"allOf": [
1594715947
{
@@ -16476,7 +16476,7 @@
1647616476
"properties": {
1647716477
"auto_restart_policy": {
1647816478
"nullable": true,
16479-
"description": "The auto-restart policy for this instance.\n\nIf not provided, unset the instance's auto-restart policy.",
16479+
"description": "Sets the auto-restart policy for this instance.\n\nThis policy determines whether the instance should be automatically restarted by the control plane on failure. If this is `null`, any explicitly configured auto-restart policy will be unset, and the control plane will select the default policy when determining whether the instance can be automatically restarted.\n\nCurrently, the global default auto-restart policy is \"best-effort\", so instances with `null` auto-restart policies will be automatically restarted. However, in the future, the default policy may be configurable through other mechanisms, such as on a per-project basis. In that case, any configured default policy will be used if this is `null`.",
1648016480
"allOf": [
1648116481
{
1648216482
"$ref": "#/components/schemas/InstanceAutoRestartPolicy"

0 commit comments

Comments
 (0)