Method: instances.setScheduling

Sets an instance's scheduling options. You can only call this method on a stopped instance, that is, a VM instance that is in a TERMINATED state. See Instance Life Cycle for more information on the possible instance states.

HTTP request

POST https://compute.googleapis.com/compute/beta/projects/{project}/zones/{zone}/instances/{resourceId}/setScheduling

The URL uses gRPC Transcoding syntax.

Path parameters

Parameters
project

string

Project ID for this request.

zone

string

The name of the zone for this request.

resourceId

string

Instance name for this request.

Query parameters

Parameters
requestId

string

An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed.

For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments.

The request ID must be a valid UUID with the exception that zero UUID is not supported (00000000-0000-0000-0000-000000000000).

Request body

The request body contains data with the following structure:

JSON representation
{
  "onHostMaintenance": enum,
  "automaticRestart": boolean,
  "preemptible": boolean,
  "nodeAffinities": [
    {
      "key": string,
      "operator": enum,
      "values": [
        string
      ]
    }
  ],
  "minNodeCpus": integer,
  "locationHint": string,
  "maintenanceFreezeDurationHours": integer,
  "maintenanceInterval": enum,
  "provisioningModel": enum,
  "instanceTerminationAction": enum,
  "hostErrorTimeoutSeconds": integer
}
Fields
onHostMaintenance

enum

Defines the maintenance behavior for this instance. For standard instances, the default behavior is MIGRATE. For preemptible instances, the default and only possible behavior is TERMINATE. For more information, see Setting Instance Scheduling Options.

automaticRestart

boolean

Specifies whether the instance should be automatically restarted if it is terminated by Compute Engine (not terminated by a user). You can only set the automatic restart option for standard instances. Preemptible instances cannot be automatically restarted.

By default, this is set to true so an instance is automatically restarted if it is terminated by Compute Engine.

preemptible

boolean

Defines whether the instance is preemptible. This can only be set during instance creation or while the instance is stopped and therefore, in a TERMINATED state. See Instance Life Cycle for more information on the possible instance states.

nodeAffinities[]

object

A set of node affinity and anti-affinity configurations. Refer to Configuring node affinity for more information. Overrides reservationAffinity.

nodeAffinities[].key

string

Corresponds to the label key of Node resource.

nodeAffinities[].operator

enum

Defines the operation of node selection. Valid operators are IN for affinity and NOT_IN for anti-affinity.

nodeAffinities[].values[]

string

Corresponds to the label values of Node resource.

minNodeCpus

integer

The minimum number of virtual CPUs this instance will consume when running on a sole-tenant node.

locationHint

string

An opaque location hint used to place the instance close to other resources. This field is for use by internal tools that use the public API.