fix(pod): scope entrypoint cache by namespace and service account - #10685
Open
pujitha24 wants to merge 1 commit into
Open
fix(pod): scope entrypoint cache by namespace and service account#10685pujitha24 wants to merge 1 commit into
pujitha24 wants to merge 1 commit into
Conversation
Motivation: The entrypointCache in pkg/pod/entrypoint_lookup_impl.go is a global LRU cache keyed only by image digest. Once an image's Entrypoint/Cmd is resolved and cached using one namespace's pull credentials, any TaskRun in a different namespace that references the same digest is served the cached result without re-authenticating to the registry. A tenant that knows the digest of another tenant's private image can learn its Entrypoint/Cmd this way, without ever having pull credentials for that image. Only Entrypoint/Cmd metadata is exposed; image layers, env vars, and filesystem content are not affected. Approach: Scope the cache key to the namespace and service account name used to resolve the image, in addition to the digest, so a cache entry is only served to lookups made with the same credential context. This matches the fix proposed in the issue. The trade-off is a lower cache hit rate in single-tenant deployments (the same image may be resolved once per namespace instead of once globally), which is acceptable given the small cache size (1024 entries) and the correctness improvement. Validation: - go build ./... - go test ./pkg/pod/... - Added TestGetImageCacheScopedByNamespace, which populates the cache via an authenticated lookup in one namespace, then performs a lookup for the same digest from a second namespace with no pull credentials. Confirmed this test fails on the pre-fix code (the second lookup succeeds by reusing the first namespace's cached result) and passes after the fix (the second lookup fails with an authentication error, since it no longer hits the cache). - golangci-lint run ./pkg/pod/...: no new findings in the changed files (pre-existing goconst/contextcheck findings in unrelated files in the package are untouched by this change). - go vet ./pkg/pod/... and gofmt -l on the changed files: clean. Report: tektoncd#10633 Signed-off-by: Pujitha Paladugu <10557236+pujitha24@users.noreply.github.com> Assisted-by: claude-sonnet-5 (via Claude Code)
Collaborator
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
The
entrypointCacheinpkg/pod/entrypoint_lookup_impl.gois a global LRUcache keyed only by image digest. Once an image's Entrypoint/Cmd is resolved
and cached using one namespace's pull credentials, any TaskRun in a
different namespace that references the same digest is served the cached
result without re-authenticating to the registry. A tenant that knows the
digest of another tenant's private image can learn its Entrypoint/Cmd this
way, without ever having pull credentials for that image. Only
Entrypoint/Cmd metadata is exposed; image layers, env vars, and filesystem
content are not affected.
This scopes the cache key to the namespace and service account name used to
resolve the image, in addition to the digest, so a cache entry is only
served to lookups made with the same credential context. This matches the
fix proposed in the linked issue. The trade-off is a lower cache hit rate in
single-tenant deployments (the same image may be resolved once per
namespace instead of once globally), which is acceptable given the small
cache size (1024 entries) and the correctness improvement.
Validation
go build ./...go test ./pkg/pod/...TestGetImageCacheScopedByNamespace, which populates the cache viaan authenticated lookup in one namespace, then performs a lookup for the
same digest from a second namespace with no pull credentials. Confirmed
this test fails on the pre-fix code (the second lookup succeeds by
reusing the first namespace's cached result) and passes after the fix
(the second lookup fails with an authentication error, since it no
longer hits the cache).
golangci-lint run ./pkg/pod/...: no new findings in the changed files.go vet ./pkg/pod/...andgofmt -lon the changed files: clean.Note: this repo's PR CI is gated behind Prow (
ok-to-test) fornon-collaborators — happy to address anything it surfaces once triggered.
Fixes #10633
Submitter Checklist
As the author of this PR, please check off the items in this checklist:
/kind <type>. Valid types are bug, cleanup, design, documentation, feature, flake, misc, question, tepRelease Notes