Managed VM Lifecycle

When you run kitchen create or kitchen destroy, Kitchen loads the configured driver. For drivers on the existing path, Kitchen calls create(state) or destroy(state) directly. For an opted-in driver, the driver acquires an instance lock before Kitchen reads saved state. Kitchen then runs the managed lifecycle under that lock.

Create a VM

  1. Kitchen saves a recovery locator before asking the driver to create a VM. If create was interrupted, Kitchen asks the driver to look up the original VM first.
  2. The driver finds or creates the VM. Kitchen saves the stable ID as soon as the driver confirms it.
  3. Kitchen waits for the VM to become visible if necessary. The driver then starts the VM and prepares the guest.

Destroy a VM

  1. The driver finds the original VM by its saved ID, or by the recovery locator if create was interrupted before Kitchen saved the ID.
  2. The driver removes the VM if it is present. Kitchen waits for confirmation that it is gone.
  3. The driver finishes cleaning up associated resources. Kitchen clears the saved state after cleanup succeeds.

Handle uncertainty or failure

Kitchen checks again when the driver reports uncertainty about whether the VM exists, or when the VM is still visible after deletion was requested. If the deadline expires, the operator needs to intervene, or cleanup fails, Kitchen keeps the saved progress and reports the instance and the next step. The driver releases the instance lock after state updates and lifecycle hooks, including when an action fails.