Compute Engine instance lifecycle (original) (raw)

A Compute Engine instance transitions through different states from the time you create it until you delete it. This document explains the compute instance lifecycle to help you troubleshoot issues, manage resources, plan migrations, and understand costs.

To check the current state of your compute instances, see instead the following:

Compute instance states

When you create a compute instance, it starts in the PROVISIONING state, moves to STAGING, and then enters the RUNNING state. Flex-start virtual machine (VM) instances with a wait time (requestValidForDuration) and TPU instances start instead in the PENDING state. From the RUNNING state, you can move a compute instance to the SUSPENDED or TERMINATED states, or you can delete it.

The following diagram shows the different states that Compute Engine can set a compute instance to:

A flowchart of the different states for a compute instance.

The states shown in the preceding diagram are described in the following sections:

PENDING state

After you create a compute instance, it enters the PENDING state if it's one of the following. Otherwise, the compute instance directly transitions to thePROVISIONING state.

In the PENDING state, Compute Engine attempts to acquire the necessary resources to start your compute instance until its wait time ends. If Compute Engine acquires the resources within this time and you have sufficient quota for those resources, then the compute instance state changes toPROVISIONING. Otherwise, you encounter an error and Compute Engine deletes the compute instance. You can optionally delete the compute instance before the wait time ends if you no longer need it.

PROVISIONING state

After you create, restart, or resume a compute instance, Compute Engine starts allocating resources for the compute instance and sets its state toPROVISIONING. When Compute Engine finishes allocating resources, the compute instance transitions to the STAGING state.

STAGING state

In the STAGING state, Compute Engine prepares the compute instance for first boot due to one of the following reasons:

In this state, the compute instance isn't running yet. When it does start running or starts booting up, the compute instance enters the RUNNING state.

RUNNING state

In the RUNNING state, Compute Engine is booting up the compute instance or the compute instance is running. From the RUNNING state, a compute instance can transition to PENDING_STOP, STOPPING, SUSPENDING, orREPAIRING depending on the action taken, system events, or compute instance configuration.

PENDING_STOP state

In the PENDING_STOP state, the compute instance starts to gracefully shut down. This shutdown process happens only if you've enabledgraceful shutdown. The compute instance enters this state if you stop or delete the compute instance, or Compute Engine is doing so automatically for a scheduled stop or deletion. The compute instance state changes to STOPPING when one of the following happens:

STOPPING state

In the STOPPING state, the compute instance is shutting down its guest OS. This process happens in the following scenarios:

Unless you configure the compute instance toskip the guest OS shutdown, the shutdown time depends on thecompute instance type. However, if the compute instance stops due to a host error, the shutdown time might differ from the expected length. After the guest OS shuts down, the ongoing stop or delete operation ends as follows:

TERMINATED state

When a compute instance enters the TERMINATED state, Compute Engine completes the stop operation. The compute instance remains in the TERMINATEDstate until you, or a scheduled operation, restart or delete it. If you request to restart the compute instance, but Compute Engine can't allocate your requested resources, then the restart request fails and the compute instance remains in the TERMINATED state. Otherwise, the restart request succeeds and the compute instance state changes to PROVISIONING.

REPAIRING state

In the REPAIRING state, Compute Engine starts arepair operation on the compute instance. Compute Engine repairs a compute instance if it encounters an internal error or the compute instance's host server is unavailable due to maintenance. While a compute instance is in repair, the following happens:

If Compute Engine successfully repairs the compute instance, then it returns the compute instance state to its original state before the repair operation began. This state can be STAGING, RUNNING, SUSPENDING, orSTOPPING. If your compute instance is configured to automatically restart (automaticRestart) after the repair operation completes, then you can optionally stop the compute instance during the repair process. This action prevents the compute instance from automatically restarting after the repair completes, leaving the compute instance in the TERMINATED state.

SUSPENDING state

In the SUSPENDING state, Compute Engine starts the suspend operation for the compute instance. You can only suspendspecific compute instances. When the suspend operation completes, the compute instance state changes toSUSPENDED.

SUSPENDED state

In the SUSPENDED state, Compute Engine completes the suspend operation. You can resume or delete the compute instance. If you request to resume the compute instance, but Compute Engine can't allocate your requested resources, then the resume request fails and the compute instance remains in the SUSPENDED state. Otherwise, the resume request succeeds and the compute instance state changes to PROVISIONING.

A compute instance can remain in the SUSPENDED state for up to 60 days. After that time, Compute Engine changes the compute instance state toTERMINATED.

Compute instance pricing

During a compute instance lifecycle, you incur charges for the compute instance as follows:

For more information, see thepricing for compute instances.

What's next