Environment expiration and cleanup
Understand how Lifecycle cleans up pull-request environments and expires API-created environments.
Lifecycle has two different cleanup models:
| Environment type | Cleanup model |
|---|---|
| Pull-request environment | Deployment inactivity and pull-request state |
| API-created environment | An explicit expiresAt lease |
First, identify the model that created an Environment. Keep labels and inactivity settings do not extend an API Environment lease.
Pull-request environments
Lifecycle records activity when it deploys or redeploys the Environment. Viewing the Environment in the UI does not refresh that activity timestamp.
For an open pull request, Lifecycle can clean up the Environment after the configured inactivity period.
Pull-request cleanup settings have no supported UI, typed API, or Helm value. A deployment owner must use a supported operator procedure for the installed release. The procedure can change the inactivity period or exclude repositories. See Runtime configuration surfaces. If no such procedure exists for the installed release, do not change these settings.
Closing a pull request can tear down the Environment without waiting for the inactivity period.
Activity means deployment activity, not page views or ordinary application traffic. To refresh the inactivity timestamp intentionally, redeploy the Environment.
API-created environments
An API Environment has an expiresAt timestamp. Its lease starts from the
requested lifespan. The administrator’s policy controls lease extensions.
The create form applies the current default and maximum lifespan. API clients
can use GET /api/v2/environments/policy to get these values.
See API-created environments for creation, extension, and teardown.
Keep an environment
For a pull-request Environment, use the keep label defined by your
administrator and repository workflow. For an API-created Environment, use the
supported lease-extension action before expiresAt.
A pull-request label does not change an API lease.
Troubleshooting
- An environment expired while I was viewing it: page views do not refresh pull-request activity or an API lease.
- A keep label had no effect: Check the Environment type and configured label. Then, check when the label was applied.
- An API extension was rejected: The requested result can exceed the maximum lifespan. The administrator can also disable API Environments.
- Cleanup started early: Check whether the pull request closed or a user requested teardown.