Skip to content

fix(cli): show the real (server-capped) ingestor token expiry (#4) - #177

Merged
saadqbal merged 1 commit into
developfrom
fix/4-real-token-expiry
Jul 8, 2026
Merged

fix(cli): show the real (server-capped) ingestor token expiry (#4)#177
saadqbal merged 1 commit into
developfrom
fix/4-real-token-expiry

Conversation

@LukasWodka

Copy link
Copy Markdown
Contributor

Closes#4.

Problem

tracebloc cluster info printed the requested token lifetime — expires in ~10m0s (server may cap shorter) from ExpirationSeconds — even when kube-apiserver's --service-account-max-token-expiration capped the grant shorter. The customer saw a lifetime the token doesn't have.

Fix (not the issue's JWT approach — better)

The TokenRequest response already carries the authoritative expiry (TokenRequestStatus.ExpirationTimestamp, capped by policy). No JWT parsing, no new dependency. Capture it as IngestorToken.ExpiresAt:

  • ExpiresAt set → cluster info shows ~<time.Until(ExpiresAt)> (the real remaining lifetime; ~ hedges client/server clock skew);
  • not set → fall back to the requested value (~10m0s (requested; server may cap shorter));
  • static-secret fallback → ExpiresAt stays zero → still reads never.

Tests (internal/cluster/token_test.go)

Full internal/... suite + go vet + gofmt green.

Low priority per the issue (short-lived tokens = small misleading window), but a cheap correctness win. Touches token.go + the cluster info display; only textual overlap with #7 (also in cluster/token files, different regions).

🤖 Generated with Claude Code

…e requested one (#4)
`cluster info` printed the REQUESTED token lifetime ("expires in ~10m0s
(server may cap shorter)"), computed from ExpirationSeconds — even when
kube-apiserver's --service-account-max-token-expiration capped the grant
shorter. The customer saw a lifetime the token doesn't actually have.
The TokenRequest response already carries the authoritative expiry
(TokenRequestStatus.ExpirationTimestamp, capped by policy) — no JWT
parsing needed, contrary to the issue title. Capture it as
IngestorToken.ExpiresAt; `cluster info` shows the real remaining
lifetime when set, falls back to the requested value when the server
didn't return a timestamp, and still reads "never" for the long-lived
static-secret fallback (ExpiresAt stays zero there).
Tests: token_test.go — CapturesServerExpiry (server caps 3600→300, asserts
ExpiresAt reflects the cap), StaticSecretHasNoExpiresAt (zero → "never").
Full internal suite + vet + gofmt green.
Low priority per the issue (tokens are short-lived, so the misleading
window is small) — but a cheap correctness win now that the API value is
right there.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@LukasWodkaLukasWodka self-assigned this Jul 8, 2026
@LukasWodka
LukasWodka requested a review from saadqbalJuly 8, 2026 04:40
@saadqbal

Copy link
Copy Markdown
Collaborator

Clean fix 👍 — reading ExpirationTimestamp off the TokenRequest response instead of parsing the JWT is the right call. Verified the static-secret path still falls through to "never" (ExpirationSeconds 0 + zero ExpiresAt), and the ~ hedge on time.Until covers clock skew. Built + tested locally, green. LGTM.

@saadqbal
saadqbal merged commit cb646ac into developJul 8, 2026
17 checks passed
@saadqbal

Copy link
Copy Markdown
Collaborator

/fr-pass

Sign up for freeto 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

@LukasWodka@saadqbal