Skip to content

Conversation

@vigneshrajsb
Copy link
Contributor

What

Summary

Automatically cleans up inactive PR environments after a configurable TTL period (default: 14 days). Environments can be excluded using the lifecycle-keep! label.

Default: Feature is disabled by default and starts in dry-run mode when enabled.


Namespace Labels

TTL behavior is controlled by namespace labels:

Label Description Example
lfc/ttl-enable Enable/disable TTL "true" or "false"
lfc/ttl-expireAtUnix Expiration timestamp (ms) "1737043200000"
lfc/ttl-expireAt Expiration date (readable) "2025-01-16"

Examples

Static Environment (TTL Disabled)

labels:
  lfc/uuid: static-staging-uuid
  lfc/ttl-enable: "false"

PR Environment (TTL Enabled - Default)

labels:
  lfc/uuid: build-uuid-abc123
  lfc/ttl-enable: "true"
  lfc/ttl-createdAtUnix: "1735843200000"
  lfc/ttl-createdAt: "2025-01-02"
  lfc/ttl-expireAtUnix: "1737043200000"
  lfc/ttl-expireAt: "2025-01-16"

PR with Keep Label (TTL Disabled)

# Add "lifecycle-keep!" label to PR → namespace gets:
labels:
  lfc/uuid: build-uuid-abc123
  lfc/ttl-enable: "false"

Configuration

TTL cleanup is configured in global_config.ttl_cleanup:

{
  "enabled": false,
  "dryRun": true,
  "inactivityDays": 14,
  "checkIntervalMinutes": 240,
  "commentTemplate": "This environment has been inactive for {inactivityDays} days and will be automatically cleaned up.",
  "excludedRepositories": []
}

Fields:

  • enabled - Master switch (default: false)
  • dryRun - Log actions without executing (default: true)
  • inactivityDays - Days before cleanup (default: 14)
  • checkIntervalMinutes - Job frequency (default: 240 = 4 hours)
  • excludedRepositories - Skip these repos (e.g., ["org/repo"])

Using Keep Labels

To prevent cleanup:

  1. Add lifecycle-keep! label to your PR or use your custom labels configured in global_config.labels
  2. Deploy/redeploy → namespace gets lfc/ttl-enable=false

To re-enable TTL:

  1. Remove the keep label
  2. Redeploy → namespace gets lfc/ttl-enable=true with new expiration

Admin API

View config:

GET /api/v1/admin/ttl/cleanup

Trigger cleanup:

# Actual cleanup (default)
POST /api/v1/admin/ttl/cleanup

# Dry-run mode
POST /api/v1/admin/ttl/cleanup \
  -d '{"dryRun": true}'

@vigneshrajsb vigneshrajsb requested a review from a team as a code owner January 5, 2026 22:28
@vigneshrajsb vigneshrajsb merged commit ab01e58 into main Jan 6, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants