A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://cloud.google.com/compute/docs/instances/setting-instance-scheduling-options below:

Set the host maintenance policy for a compute instance | Compute Engine Documentation

Skip to main content Set the host maintenance policy for a compute instance

Stay organized with collections Save and categorize content based on your preferences.

Linux Windows

This document explains how to set the host maintenance policy for a Compute Engine instance to determine its behavior during host events. To learn more about host maintenance policies, see Host maintenance policy.

A host maintenance policy determines how your instance responds when the host on which the instance is running requires maintenance or encounters an error. Configuring the host maintenance policy for an instance helps you do the following:

Limitations

For host maintenance policies, the following limitations apply:

Before you begin Required roles

To get the permissions that you need to set the host maintenance policy for a compute instance, ask your administrator to grant you the Compute Instance Admin (v1) (roles/compute.instanceAdmin.v1) IAM role on your project. For more information about granting roles, see Manage access to projects, folders, and organizations.

This predefined role contains the permissions required to set the host maintenance policy for a compute instance. To see the exact permissions that are required, expand the Required permissions section:

Required permissions

The following permissions are required to set the host maintenance policy for a compute instance:

You might also be able to get these permissions with custom roles or other predefined roles.

Available host maintenance properties

You can customize how your compute instance behaves during scheduled maintenance or unexpected host events. Unless you specify otherwise, Compute Engine uses default settings when you create an instance, instances in bulk, or an instance template.

You can configure the following host maintenance properties:

Set the host maintenance policy for an instance

By default, compute instances use the default settings for their host maintenance policy. To customize these settings, use one of the following methods:

Set the policy for an existing instance

Before you change the host maintenance policy of an existing instance, ensure the following:

To change the Local SSD data recovery timeout in an instance that has Local SSD disks attached, use the gcloud CLI or REST API. Otherwise, select any of the following options:

Console
  1. In the Google Cloud console, go to the VM instances page.

    Go to VM instances

  2. In the Name column, click the name of the instance that you want to update. A page that gives the details of the instance appears.

  3. Click edit Edit. A page that lets you edit instance properties appears.

  4. In the Management section, you can do one or more of the following:

  5. Click Save.

gcloud

To change the host maintenance policy in an existing instance, use the gcloud compute instances set-scheduling command with one or more of the following flags:

For example, to change host maintenance behavior, automatically restart the instance after host errors or programmed stops, change the Local SSD data recovery timeout, and change the host error timeout, run the following command:

gcloud compute instances set-scheduling INSTANCE_NAME \
    --host-error-timeout-seconds=ERROR_DETECTION_TIMEOUT \
    --local-ssd-recovery-timeout=LOCAL_SSD_RECOVERY_TIMEOUT \
    --maintenance-policy=MAINTENANCE_POLICY \
    --restart-on-failure \
    --zone=ZONE

Replace the following:

REST

To change the host maintenance policy in an existing instance, make a POST request to the instances.setScheduling method. In the request body, include one or more of the following fields:

For example, to change host maintenance behavior, automatically restart the instance after host errors or programmed stops, change the Local SSD data recovery timeout, and change the host error timeout, make a request as follows:

POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instances/INSTANCE_NAME/setScheduling

{
  "automaticRestart": AUTOMATIC_RESTART,
  "hostErrorTimeoutSeconds": ERROR_DETECTION_TIMEOUT,
  "localSsdRecoveryTimeout": LOCAL_SSD_RECOVERY_TIMEOUT,
  "onHostMaintenance": "MAINTENANCE_POLICY"
}

Replace the following:

Set the policy while creating an instance

You can set the host maintenance policy of a compute instance while creating it.

To set the Local SSD data recovery timeout while creating an instance that has Local SSD disks attached, use the gcloud CLI or REST API. Otherwise, select any of the following options:

Console
  1. In the Google Cloud console, go to the Create an instance page.

    Go to Create an instance

  2. In the Name field, enter a name for the instance.

  3. In the Region and Zone fields, specify in which region and zone to create the instance.

  4. Specify the machine type for the instance.

  5. In the navigation menu, click Advanced.

  6. In the Provisioning model section, expand VM provisioning model advanced settings, and then do one or more of the following:

  7. Click Create.

gcloud

To set the host maintenance policy of an instance while creating it, use the gcloud compute instances create command with one or more of the following flags:

For example, to set the host maintenance behavior, automatically restart the instance after host errors or programmed stops, set a Local SSD data recovery timeout, and set a host error timeout, run the following command:

Important: Spot VMs and preemptible VMs don't support automatic restarts after host errors or programmed stops. If you include the --restart-on-failure flag when you create these types of VMs, then Compute Engine ignores it. This behavior is the same as using the --no-restart-on-failure flag.
gcloud compute instances create INSTANCE_NAME \
    --host-error-timeout-seconds=ERROR_DETECTION_TIMEOUT \
    --local-ssd-recovery-timeout=LOCAL_SSD_RECOVERY_TIMEOUT \
    --machine-type=MACHINE_TYPE \
    --maintenance-policy=MAINTENANCE_POLICY \
    --restart-on-failure \
    --zone=ZONE

Replace the following:

REST

To set the host maintenance policy of an instance while creating it, make a POST request to the instances.insert method. In the request body, include one or more of the following fields in the scheduling field:

For example, to set the host maintenance behavior, automatically restart the instance after host errors or programmed stops, set a Local SSD data recovery timeout, and set a host error timeout, make a request as follows:

POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instances

{
  "name": "INSTANCE_NAME",
  "machineType": "zones/ZONE/machineTypes/MACHINE_TYPE",
  "disks": [
    {
      "boot": true,
      "initializeParams": {
        "sourceImage": "projects/IMAGE_PROJECT/global/images/IMAGE"
      }
    }
  ],
  "networkInterfaces": [
    {
      "network": "global/networks/default"
    }
  ],
  "scheduling": {
    "automaticRestart": AUTOMATIC_RESTART,
    "hostErrorTimeoutSeconds": ERROR_DETECTION_TIMEOUT,
    "localSsdRecoveryTimeout": LOCAL_SSD_RECOVERY_TIMEOUT,
    "onHostMaintenance": "MAINTENANCE_POLICY"
  }
}

Replace the following:

For more information about creating an instance, see Create and start a Compute Engine instance.

Set the policy while creating instances in bulk

To set the host maintenance policy while creating instances in bulk, select one of the following options:

gcloud

To set the host maintenance policy while creating instances in bulk, use the gcloud compute instances bulk create command with one or more of the following flags:

For example, to set the host maintenance behavior, automatically restart the instance after host errors or programmed stops, set a Local SSD data recovery timeout, and set a host error timeout, run the following command. The following example also creates instances in a single zone and specifies a name pattern for the instances:

Important: Spot VMs and preemptible VMs don't support automatic restarts after host errors or programmed stops. If you include the --restart-on-failure flag when you create these types of VMs, then Compute Engine ignores it. This behavior is the same as using the --no-restart-on-failure flag.
gcloud compute instances bulk create \
    --count=COUNT \
    --host-error-timeout-seconds=ERROR_DETECTION_TIMEOUT \
    --local-ssd-recovery-timeout=LOCAL_SSD_RECOVERY_TIMEOUT \
    --machine-type=MACHINE_TYPE \
    --maintenance-policy=MAINTENANCE_POLICY \
    --name-pattern=NAME_PATTERN \
    --restart-on-failure \
    --zone=ZONE

Replace the following:

REST

To set the host maintenance policy while creating instances in bulk, make a POST request to the instances.bulkInsert method. In the request body, include one or more of the following fields in the scheduling field:

For example, to set the host maintenance behavior, automatically restart the instance after host errors or programmed stops, set a Local SSD data recovery timeout, and set a host error timeout, make a request as follows. The following example also creates instances in a single zone and specifies a name pattern for the instances:

POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instances/bulkInsert

{
  "count": COUNT,
  "namePattern": "NAME_PATTERN",
  "instanceProperties": {
    "machineType": "MACHINE_TYPE",
    "disks": [
      {
        "boot": true,
        "initializeParams": {
          "sourceImage": "projects/IMAGE_PROJECT/global/images/IMAGE"
        }
      }
    ],
    "networkInterfaces": [
      {
        "network": "global/networks/default"
      }
    ],
    "scheduling": {
      "automaticRestart": AUTOMATIC_RESTART,
      "hostErrorTimeoutSeconds": ERROR_DETECTION_TIMEOUT,
      "localSsdRecoveryTimeout": LOCAL_SSD_RECOVERY_TIMEOUT,
      "onHostMaintenance": "MAINTENANCE_POLICY"
    }
  }
}

Replace the following:

For more information about creating instances in bulk, see Create VMs in bulk.

Set the policy while creating an instance template

You can set the host maintenance policy while creating an instance template. All compute instances that you create using the template inherit the host maintenance policy specified in the template.

To set the Local SSD data recovery timeout while creating an instance template that specifies Local SSD disks, use the gcloud CLI or REST API. Otherwise, select any of the following options:

Console
  1. In the Google Cloud console, go to the Instance templates page.

    Go to Instance templates

  2. Click Create instance template. The Create instance template page appears.

  3. In the Name field, enter a name for the instance template.

  4. In the Location section, select one of the following options:

  5. In the Machine configuration section, specify the machine type for the instance template.

  6. In the Provisioning model section, expand VM provisioning model advanced settings, and then do one or more of the following:

  7. Click Create.

gcloud

To set the host maintenance policy while creating an instance template, use the gcloud compute instance-templates create command with one or more of the following flags:

For example, to set the host maintenance behavior, automatically restart the instance after host errors or programmed stops, set a Local SSD data recovery timeout, and set a host error timeout, run the following command. The following example also creates a regional instance template. To create a global instance template, use the same command without the --instance-template-region flag.

Important: Spot VMs and preemptible VMs don't support automatic restarts after host errors or programmed stops. If you include the --restart-on-failure flag when you create these types of VMs, then Compute Engine ignores it. This behavior is the same as using the --no-restart-on-failure flag.
gcloud compute instance-templates create INSTANCE_TEMPLATE_NAME \
    --host-error-timeout-seconds=ERROR_DETECTION_TIMEOUT \
    --instance-template-region=REGION \
    --local-ssd-recovery-timeout=LOCAL_SSD_RECOVERY_TIMEOUT \
    --machine-type=MACHINE_TYPE \
    --maintenance-policy=MAINTENANCE_POLICY \
    --restart-on-failure

Replace the following:

REST

To set the host maintenance policy while creating an instance template, make a POST request to one of the following methods:

In the request body, include one or more of the following fields in the scheduling field:

For example, to set the host maintenance behavior, automatically restart the instance after host errors or programmed stops, set a Local SSD data recovery timeout, and set a host error timeout, make a request as follows. The following example also creates a regional instance template.

POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/regions/REGION/instanceTemplates

{
  "name": "INSTANCE_TEMPLATE_NAME",
  "properties": {
    "disks": [
      {
        "boot": true,
        "initializeParams": {
          "sourceImage": "projects/IMAGE_PROJECT/global/images/IMAGE"
        }
      }
    ],
    "machineType": "MACHINE_TYPE",
    "networkInterfaces": [
      {
        "network": "global/networks/default"
      }
    ],
    "scheduling": {
      "automaticRestart": AUTOMATIC_RESTART,
      "hostErrorTimeoutSeconds": ERROR_DETECTION_TIMEOUT,
      "localSsdRecoveryTimeout": LOCAL_SSD_RECOVERY_TIMEOUT,
      "onHostMaintenance": "MAINTENANCE_POLICY"
    }
  }
}

Replace the following:

For more information about creating an instance template, see Create instance templates.

View host maintenance policy of an instance

You can view the host maintenance policy of an instance by viewing the instance's details.

When viewing the instance's details using the gcloud CLI or REST API, you can only view the localSsdRecoveryTimeout and hostErrorTimeoutSeconds fields if you specified them while creating or updating the instance.

To view the Local SSD data recovery timeout in an instance that has Local SSD disks attached, use the gcloud CLI or REST API. Otherwise, select any of the following options:

Console
  1. In the Google Cloud console, go to the VM instances page.

    Go to VM instances

  2. In the Name column, click the instance that you want to view. A page that gives the details of the instance appears.

  3. On the Details tab, in the Management section, in the Availability policies section, you can view the following:

gcloud

To view the host maintenance policy for an instance, use the gcloud compute instances describe command with the --flatten flag set to scheduling:

 gcloud compute instances describe INSTANCE_NAME \
    --flatten=scheduling \
    --zone=ZONE

Replace the following:

The output is similar to the following:

---
scheduling:
  automaticRestart: true
  hostErrorTimeoutSeconds: 120
  localSsdRecoveryTimeout:
    nanos: 0
    seconds: '10800'
  onHostMaintenance: MIGRATE
  preemptible: false
  provisioningModel: STANDARD
REST

To view the host maintenance policy for an instance, make a GET request to the instances.get method. In the request URL, include the fields query parameter and set it to scheduling:

  GET https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instances/INSTANCE_NAME?fields=scheduling

Replace the following:

The output is similar to the following:

{
  "scheduling": {
    "onHostMaintenance": "MIGRATE",
    "automaticRestart": true,
    "preemptible": false,
    "provisioningModel": "STANDARD",
    "localSsdRecoveryTimeout": {
      "seconds": "10800",
      "nanos": 0
    }
  }
}
What's next

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-08-07 UTC.

[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[[["This document details how to configure the host maintenance policy for virtual machines (VMs) and bare metal instances to manage their behavior during host events."],["You can choose between `MIGRATE` (live migration) or `TERMINATE` (stop and potentially restart) for maintenance events, with `MIGRATE` being the default for most VMs and `TERMINATE` for specific instance types like Z3 and bare metal."],["The `automaticRestart` property determines if an instance restarts after crashing or being stopped, with the default being `true`."],["`localSsdRecoveryTimeout` is used to specify the time Compute Engine waits to recover Local SSD data, up to 168 hours (7 days), while `hostErrorTimeoutSeconds` determines the wait time before an unresponsive instance restarts or terminates, ranging from 90 to 330 seconds."],["Host maintenance policies, including `onHostMaintenance`, `automaticRestart`, `localSsdRecoveryTimeout`, and `hostErrorTimeoutSeconds`, can be set during instance creation or updated on existing instances using the Google Cloud console, gcloud CLI, or REST API."]]],[]]


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4