DocsFeaturesEnvironment TTL

Environment TTL

Lifecycle automatically cleans up inactive ephemeral environments based on configurable TTL (Time To Live) settings. This helps reduce resource usage while allowing teams to keep environments alive when needed.

Configuration

The TTL cleanup configuration is stored in the global_config table with the key ttl_cleanup:

enabled

Enables or disables automatic cleanup of inactive environments.

Default: false

dryRun

Runs cleanup process without actually tearing down environments. Useful for testing.

Default: true

inactivityDays

Number of days of inactivity before an environment is eligible for cleanup.

Default: 14

checkIntervalMinutes

How frequently the cleanup job runs to check for stale environments.

Default: 240 (4 hours)

commentTemplate

Custom message posted to the PR when cleaning up. Supports {inactivityDays} placeholder and dynamic label replacements.

Default: "Tearing down lifecycle env since no activity in the past {inactivityDays} days."

excludedRepositories

Repository names (format: owner/repo) to exclude from automatic cleanup.

Default: []

⚠️

Changes to TTL configuration require refreshing the global config cache or waiting for the automatic refresh cycle.


How It Works

Lifecycle tracks environment expiration using lfc/ttl-expireAtUnix labels on Kubernetes namespaces. The cleanup service runs periodically to scan for expired environments, validates eligibility (PR is open, not static, not excluded), and tears down environments by removing the deploy label and adding the disabled label.

Preventing Cleanup

Add the keep label to a PR to prevent automatic cleanup. This disables TTL on the namespace and keeps the environment alive indefinitely. See Configurable Labels to customize the keep label.


Summary

PropertyTypePurpose
enabledbooleanEnable/disable automatic cleanup
dryRunbooleanTest mode without actual cleanup
inactivityDaysnumberDays of inactivity before cleanup
checkIntervalMinutesnumberCleanup job frequency in minutes
commentTemplatestringCustom cleanup message for PRs
excludedRepositoriesstring[]Repositories excluded from cleanup