Skip to content

fix(kubernetes): consolidate namespace label management to ensure lfc/uuid is always present#131

Merged
vigneshrajsb merged 3 commits intomainfrom
fix/static-env-namespace-ttl-labels
Mar 12, 2026
Merged

fix(kubernetes): consolidate namespace label management to ensure lfc/uuid is always present#131
vigneshrajsb merged 3 commits intomainfrom
fix/static-env-namespace-ttl-labels

Conversation

@vigneshrajsb
Copy link
Contributor

@vigneshrajsb vigneshrajsb commented Mar 12, 2026

Summary

  • Root cause: Two separate namespace creation paths caused label gaps that broke TTL cleanup — ensureNamespaceExists (build phase) created namespaces without lfc/uuid, and the deploy-phase PATCH only updated lfc/ttl-* labels, never adding lfc/uuid. TTL cleanup silently skipped namespaces missing lfc/uuid.
  • Simplified ensureNamespaceExists to use only app.kubernetes.io/managed-by as a minimal identifier; all lifecycle-specific labels are now set exclusively by createOrUpdateNamespace
  • Updated generateTTLLabels to include lfc/uuid, lfc/type, and app.kubernetes.io/managed-by in all new namespace creations
  • Updated generateTTLPatch to prepend base patch ops (lfc/uuid, lfc/type, app.kubernetes.io/managed-by) so re-deploys always upsert these labels onto existing namespaces
  • Consolidated the two PATCH branches in createOrUpdateNamespace (static and non-static) into a single generateTTLPatch call
  • Added UUID fallback in TTL cleanup: pre-existing namespaces missing lfc/uuid derive it from the namespace name (env-<uuid>) instead of being silently skipped forever
  • Renamed all lifecycle.io/* annotations to lfc/* for consistency (dockerfile, ecr-repo, triggered-at)

Test plan

  • Deploy a new ephemeral env — verify namespace has all labels: lfc/uuid, lfc/type: ephemeral, lfc/ttl-enable: true, lfc/ttl-expireAt*, app.kubernetes.io/managed-by: lifecycle
  • Re-deploy to an existing ephemeral namespace — verify lfc/uuid is patched onto it
  • Deploy a static env — verify lfc/type: static and lfc/ttl-enable: false
  • Re-deploy to an existing static namespace — verify lfc/uuid and lfc/ttl-enable: false are patched
  • Confirm TTL cleanup no longer skips namespaces that were created before this fix (uuid fallback path triggers a warning log)

🤖 Generated with Claude Code

…e-deploy

Static environments that were originally created with TTL enabled would
never get their lfc/ttl-enable label corrected on subsequent deploys
because the else branch skipped any namespace update. Now, when a
namespace already exists and staticEnv=true, we explicitly patch
lfc/ttl-enable to 'false' to ensure the label reflects the current
static state regardless of how the namespace was first created.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@vigneshrajsb vigneshrajsb requested a review from a team as a code owner March 12, 2026 17:55
…notations to lfc/*

- Simplify ensureNamespaceExists labels in nativeBuild/utils.ts
- Rename lifecycle.io/* annotations to lfc/* in utils.ts and jobFactory.ts
- Update generateTTLLabels and generateTTLPatch to include lfc/uuid, lfc/type,
  and app.kubernetes.io/managed-by
- Consolidate createOrUpdateNamespace PATCH branches in kubernetes.ts
- Add UUID fallback derivation from namespace name in ttlCleanup.ts
- Update annotation assertions in buildkit.test.ts and utils.test.ts to match lfc/*

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@vigneshrajsb vigneshrajsb changed the title fix(kubernetes): patch ttl-enable label to false for static envs on re-deploy fix(kubernetes): consolidate namespace label management to ensure lfc/uuid is always present Mar 12, 2026
@vigneshrajsb vigneshrajsb merged commit c97bb14 into main Mar 12, 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.

2 participants