Skip to content

Ephemeral environments: add a way to read provisioning status and to delete an ephemeral environment #753

Open

Description

@justin-newman

Use case

We use the CLI in CI to clean up a PR's ephemeral environment when the PR closes. If provisioning failed, the deprovision runbook can't run, so we:

  1. Check the environment's provisioning status for the project.
  2. If it is ProvisioningFailed, delete the environment directly instead of deprovisioning it.

The CLI can't do either of these today, so this step still uses raw REST calls.

What is missing

1. No way to read provisioning status.
The ephemeral-environment group has create, deprovision-environment and deprovision-project, but no list or view. We call the API directly:
GET /api/{space}/projects/{projectId}/environments/ephemeral/{environmentId}/status, then read .Status.
The status is per project, so a command for it needs a project as well as an environment name. We also have to resolve the space ID, project ID and environment ID by hand, since octopus api is GET-only and does no lookups.

2. octopus environment delete cannot delete an ephemeral environment.
It looks the target up with the classic environments endpoint (pkg/cmd/environment/delete/delete.go), which does not return ephemeral environments. On our space the classic list returns 9 environments and none of the 31 ephemeral ones. octopus task list --environment already handles this by falling back to the ephemeral lookup when no classic environment matches, so the same approach would work here. Also, an ID argument is treated as a name (there is a TODO about this in the code), so octopus environment delete Environments-1001 would not work either.

Suggested solutions

Any of these would cover our case:

  • octopus ephemeral-environment view --name <name> --project <project> showing the provisioning status, with --output-format json. This matches other view commands, for example target view, which includes health status. An ephemeral-environment list that includes the same status column would also help.
  • octopus ephemeral-environment delete --name <name>, or an ephemeral fallback in octopus environment delete like the one in task list.
  • Make environment delete accept an environment ID.

Happy to help test or contribute if that is useful.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions