Skip to content

mecak8s: bound and garbage-collect session Lease objects safely #1517

Description

@ChrisJBurns

Problem

The Kubernetes Lease backend creates a distinct Lease object for every session. Release writes a tombstone instead of deleting the object so leaseTransitions remains monotonic. Consequently, session and recurring-schedule activity grows the namespace's Lease population without bound.

This creates a long-term API-server/etcd capacity and operability risk.

Evidence

  • internal/adapter/k8slease/k8slease.go:createLease creates one object per session ID.
  • Release deliberately retains the object and fencing token.
  • There is no Lease GC, cardinality bound, ownership label, or alerting surface.

Proposed direction

Design GC that preserves fencing monotonicity, potentially by durably retaining the generation outside the Kubernetes object before deletion. Add ownership metadata, cardinality metrics, alerts, and an explicit supported bound.

Acceptance criteria

  • Lease object growth is bounded under unbounded historical session creation.
  • A deleted/collected Lease can never reset or reuse a stale fencing generation.
  • GC is safe under concurrent acquire, renew, release, restart, and takeover.
  • Operators can observe current cardinality and GC failures.

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

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions