# Deletion and delete deadlines

> For the complete documentation index, see [llms.txt](https://docs-stg.ringleader.dev/llms.txt).


> Deleting a workstation removes it for good, with its virtual machine, its disk and everything on it, apart from one node-bound case.


Deleting a workstation removes it for good, with its virtual machine, its disk and everything
on it, apart from one node-bound case. Anything you didn't push elsewhere can't be recovered.
Ringleader can also delete a workstation at a deadline, with no client running.

## Resources removed by deletion

A deletion removes the workstation, its virtual machine and its disk. The exception is a
node-bound workstation that someone other than its owner deletes, which
[Node-bound workstation deletion](#node-bound-workstation-deletion) describes.

To stop paying for a workstation while you keep its disk, stop it instead, as
[Starts, stops and restarts](https://docs-stg.ringleader.dev/workstations/lifecycle/starts-stops-restarts/)
describes. To have Ringleader delete a workstation at a deadline, see
[Deletion deadline](#deletion-deadline).

## Deletion deadline

`lifecycle.ttl` deletes a workstation at a deadline measured from when it was created,
unless `ttlAction: stop` is set. [Maximum run time](https://docs-stg.ringleader.dev/workstations/lifecycle/starts-stops-restarts/#maximum-run-time)
describes that older spelling. The delete removes the workstation and destroys its virtual machine and disk, exactly as
`rl workstation delete` does. A stop, a start or a restart doesn't move the deadline.
Editing `ttl` is the one thing that moves it, and the new deadline applies at once.
Ringleader checks deadlines periodically, so a delete can come shortly after the deadline, as
[Deadline enforcement](https://docs-stg.ringleader.dev/workstations/lifecycle/starts-stops-restarts/#deadline-enforcement)
describes.

## Deletion deadlines on a WorkstationConfig

`rl apply` rejects `ttl` on a WorkstationConfig. [Lifetimes on a WorkstationConfig](https://docs-stg.ringleader.dev/workstations/lifecycle/starts-stops-restarts/#lifetimes-on-a-workstationconfig)
gives the reason. Set `ttl` on each workstation that needs one.

## Workstations in the Terminating phase

A workstation that's being deleted is in the `Terminating` phase. Ringleader deletes its
virtual machine first, and keeps the workstation's record until it can confirm the virtual
machine is gone.

If Ringleader can't confirm, it keeps the record and tries again. That happens when the
provider can't be reached, a cloud credential was revoked, or the configuration Ringleader
needed was already deleted. The workstation's `Ready` condition then has reason
`TerminatingFailed`, and its message names the step that failed. This way, Ringleader never
loses track of a virtual machine without telling you.

## Node-bound workstation deletion

A [node-bound workstation](https://docs-stg.ringleader.dev/workstations/basics/#node-bound-workstations)
runs on its owner's computer, and Ringleader keeps its record. Who deletes the workstation
decides what happens to its virtual machine:

- When its owner deletes it, the workstation stays in `Terminating` until the computer that runs
  it deletes the virtual machine. If that computer isn't active, `rl workstation delete` says so,
  and names the way out in
  [Delete a computer that isn't coming back](https://docs-stg.ringleader.dev/workstations/lifecycle/orphaned-workstations-recovery/#delete-a-computer-that-isnt-coming-back).
- When anyone else who may delete it deletes it, such as a namespace administrator, the record
  goes at once. The virtual machine stays on the owner's computer as an
  [orphaned workstation](https://docs-stg.ringleader.dev/workstations/lifecycle/orphaned-workstations-recovery/#orphaned-workstations).

If the workstation is already in `Terminating`, Ringleader refuses anyone else's delete, because
the owner's computer may still be deleting the virtual machine. The refusal names
[`rl workstation release-finalizer`](https://docs-stg.ringleader.dev/reference/cli/commands/workstation-access/#rl-workstation-release-finalizer-name),
which an administrator runs to remove the record anyway. The Ringleader application's Delete
dialog says which of the two a delete does.

## Delete a workstation

To delete a workstation in the application, open its card and click **Delete**. The dialog
says what the deletion does and asks you to type the workstation's name.

To delete it from the command line, run:

```bash
rl workstation delete my-box -n local
```

`rl` asks you to confirm before it deletes, as
[`rl <kind> delete`](https://docs-stg.ringleader.dev/reference/cli/commands/resource-verbs/#rl-kind-delete-name) describes.

The command prints `workstation/my-box is being deleted` while the virtual machine
is still being removed. To wait until it's gone, run:

```bash
rl workstation wait my-box --for Deleted -n local
```

In the terminal UI, press `d` on the workstation, as
[Resource management](https://docs-stg.ringleader.dev/reference/tui/resource-management/) shows.

## Delete everything a file declares

To delete a workstation together with the configuration layers and other resources you
applied with it, pass the file to `rl workstation delete`:

```bash
rl workstation delete -f my-box.yaml
```

The command deletes every resource the file declares, whatever its kind, including
WorkstationConfigs and Secrets.

## Delete a workstation at a deadline

To delete a workstation, disk included, a week after you create it, set `ttl`:

```yaml
spec:
  lifecycle:
    ttl: 7d
```

Push anything you want to keep before the deadline. To give the workstation longer, edit
`ttl` and apply the file again.

## Check when a workstation is deleted

The **EXPIRES** column of `rl workstation get` shows the next deadline. So does the
**Deadline** line of an open card.
[Check when a workstation stops](https://docs-stg.ringleader.dev/workstations/lifecycle/starts-stops-restarts/#check-when-a-workstation-stops)
describes both.

## Release a workstation stuck in Terminating

If a workstation stays in `Terminating` because Ringleader can't confirm its virtual machine
is gone, a namespace administrator can remove its record anyway.

<div class="callout callout-warning">
  <p class="callout-title">The virtual machine can keep running</p>
  <div class="callout-body">
    Releasing a workstation doesn&rsquo;t delete its virtual machine. If the virtual machine is still
running, it keeps running and costing money, and nothing tracks it afterward.
  </div>
</div>


To release the workstation, follow these steps:

1. Run `rl workstation release-finalizer` with the workstation's name:

   ```bash
   rl workstation release-finalizer my-box -n local
   ```

   Ringleader refuses, and the refusal names the virtual machine you may leave behind.

2. Delete that virtual machine in your provider's console, if you can reach it.

3. Run the command again, naming that virtual machine:

   ```bash
   rl workstation release-finalizer my-box -n local \
       --acknowledge-orphaned-machine my-box-7f3a91
   ```

   Ringleader removes the workstation's record.

## Next steps

- [Starts, stops and restarts](https://docs-stg.ringleader.dev/workstations/lifecycle/starts-stops-restarts/)
  stops a workstation and keeps its disk, or stops one automatically.
- [`rl <kind> delete`](https://docs-stg.ringleader.dev/reference/cli/commands/resource-verbs/#rl-kind-delete-name) lists every
  flag of the delete command.
- [`rl workstation release-finalizer`](https://docs-stg.ringleader.dev/reference/cli/commands/workstation-access/#rl-workstation-release-finalizer-name)
  lists the flags of the release command.
- [Orphaned workstations and recovery](https://docs-stg.ringleader.dev/workstations/lifecycle/orphaned-workstations-recovery/)
  covers a virtual machine your computer keeps after its record is gone.

