Skip to content

Conversation

@twoGiants
Copy link
Member

@twoGiants twoGiants commented Sep 30, 2025

Changes

This PR takes the state of PR #8825, starting from commit f817655 (actually 087c5a5 but the first is the big important one) and adds the re-work from the second review of @twoGiants on top of it.

All resolved comments are marked with a 👍 and a "resolved" comment.

What is left to do?

  • add back in InitializeFromConfigMap and implement functionality => maybe in Resolver.Initialize
  • add comment which test case covers cache misses implicitly: pkg/remoteresolution/resolver/cluster/resolver_test.go:TestResolve
  • encapsulate annotated resource => package scope
  • fix e2e tests
  • merge cache, cache/injection, framework/cache packages into => framework/cache/**
  • add/fix unit tests
  • resolve all of your TODO comments
  • implement config watching for cache

Submitter Checklist

As the author of this PR, please check off the items in this checklist:

  • Has Docs if any changes are user facing, including updates to minimum requirements e.g. Kubernetes version bumps
  • Has Tests included if any functionality added or changed
  • pre-commit Passed
  • Follows the commit message standard
  • Meets the Tekton contributor standards (including functionality, content, code)
  • Has a kind label. You can add one by adding a comment on this PR that contains /kind <type>. Valid types are bug, cleanup, design, documentation, feature, flake, misc, question, tep
  • Release notes block below has been updated with any user facing changes (API changes, bug fixes, changes requiring upgrade notices or deprecation warnings). See some examples of good release notes.
  • Release notes contains the string "action required" if the change requires additional action from users switching to the new release

Release Notes

## Resolver Caching for Bundle, Git, and Cluster Resolvers
Support caching for bundle, git, and cluster resolvers, reducing redundant fetches and improving pipeline performance.

**Key Features:**
- **Automatic caching** for immutable references (digest-based bundles, git SHAs)
- **Three cache modes**: `always` (cache everything), `never` (disable caching),`auto` (cache only immutable references - default)
- **Configurable via ConfigMap**: Set cache size and TTL without restarting controllers
- **Per-task override**: Tasks can override global cache settings using the `cache` parameter
- **Observability**: Cache hits/misses and timestamps added to resource annotations

**Configuration:**
Control cache behavior via the `resolver-cache-config` ConfigMap with `max-size` (default: 1000) and `ttl` (default: 5m). Cache mode can be set globally in resolver ConfigMaps or per-task.

apiVersion: v1
kind: ConfigMap
metadata:
  name: resolver-cache-config
data:
  max-size: "1000"  # Maximum cache entries (default: 1000)
  ttl: "5m"         # Cache entry lifetime (default: 5m)

Set cache mode in resolver ConfigMaps (bundleresolver-config, git-resolver-config, cluster-resolver-config):

data:
  cache: "auto"  # Options: always, never, auto (default: auto)

Override cache behavior per-task using the cache parameter:

params:
  - name: cache
    value: "always"  # Force caching for this task

Cache annotations are added to resolved resources for observability.

This helps reduce external API calls, improves pipeline exec speed, and provides better resilience during remote resource resolution.

@tekton-robot tekton-robot added the release-note-none Denotes a PR that doesnt merit a release note. label Sep 30, 2025
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Sep 30, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

@tekton-robot tekton-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Sep 30, 2025
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/remoteresolution/cache/injection/cache.go Do not exist 0.0%
pkg/remoteresolution/resolver/framework/cache.go Do not exist 0.0%
pkg/remoteresolution/resolver/framework/reconciler.go 75.3% 73.8% -1.6
pkg/remoteresolution/resolver/http/resolver.go 88.9% 100.0% 11.1
pkg/resolution/resolver/bundle/bundle.go 71.1% 71.4% 0.4
pkg/resolution/resolver/bundle/params.go 87.9% 86.1% -1.8
pkg/resolution/resolver/cluster/resolver.go 80.4% 79.9% -0.6
pkg/resolution/resolver/git/resolver.go 84.9% 84.3% -0.6

@waveywaves
Copy link
Member

waveywaves commented Sep 30, 2025

@twoGiants I have been updating the original PR

@waveywaves
Copy link
Member

I will contribute here instead

@vdemeester vdemeester added this to the v1.6.0 (LTS) milestone Oct 7, 2025
@waveywaves waveywaves added the kind/feature Categorizes issue or PR as related to a new feature. label Oct 13, 2025
@waveywaves waveywaves force-pushed the brianwcook-resolver-cache branch from 05fe2d2 to 4bc9258 Compare October 14, 2025 04:59
@waveywaves
Copy link
Member

/retest

2 similar comments
@waveywaves
Copy link
Member

/retest

@waveywaves
Copy link
Member

/retest

Copy link
Member

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, still some questions/comments and todos

  • There is still some TODOs (the DEPRECATED functions in pkg/remoteresolution/cache package)
  • I am not a huge fan of loading the configmap when we start and not do anything else. I would prefer if we do the same as we do for the other configmap, we watch it from the controller, and we adapt from changes.
    • As it is today, if you change the configuration for cache, you need to restart the deployment of resolvers
    • If someone wants to enable cache on a running instance, same then, a manual intervention is needed

TTL: r.ttl,
Params: params,
// IsImmutable implements ImmutabilityChecker.IsImmutable
// Returns true if the revision parameter is a commit SHA (40-character hex string)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick note : as of today, a full git SHA is SHA-1, but tomorrow (git v3), it would/could but SHA-256, so we could try to take this case into account today already ? (or create a follow-up issue)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@waveywaves ☝️ 😸

@twoGiants twoGiants changed the title 🚧 👷 Re-work on "Add shared cache for resolvers" 🚧 🏗️ [WIP] 🚧 👷 Re-work on "Add shared cache for resolvers" 🚧 🏗️ [WIP] Oct 17, 2025
@tekton-robot tekton-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 17, 2025
@waveywaves waveywaves force-pushed the brianwcook-resolver-cache branch from 5ee1911 to f06cf00 Compare October 23, 2025 09:39
Copy link
Member

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we are good. There might be a few nits that we can do in a follow-up.
We will also need to stash some commits a bit, there is too much right now 🙃

@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: vdemeester

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 27, 2025
@waveywaves waveywaves force-pushed the brianwcook-resolver-cache branch from 6aa0c9c to 0224721 Compare October 27, 2025 13:07
@waveywaves waveywaves changed the title [WIP] 🚧 👷 Re-work on "Add shared cache for resolvers" 🚧 🏗️ [WIP] feat: add shared cache for resolvers Oct 27, 2025
@tekton-robot tekton-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 27, 2025
@waveywaves waveywaves changed the title feat: add shared cache for resolvers feat: implement resolver caching for bundle, git, and cluster resolvers Oct 27, 2025
@waveywaves waveywaves changed the title feat: implement resolver caching for bundle, git, and cluster resolvers feat: implement shared cache for bundle, git, and cluster resolvers Oct 27, 2025
@waveywaves waveywaves force-pushed the brianwcook-resolver-cache branch from 0224721 to 23cba41 Compare October 27, 2025 18:54
@waveywaves
Copy link
Member

/retest

@waveywaves waveywaves force-pushed the brianwcook-resolver-cache branch 2 times, most recently from 28ea88c to aa83b01 Compare October 29, 2025 09:28
waveywaves and others added 3 commits October 29, 2025 15:22
Implements a shared, thread-safe LRU cache with TTL expiration for Tekton
resolvers (bundle, git, cluster). All resolvers share a single cache instance
configured via ConfigMap with hot-reload support.

Features:
- Shared singleton cache across all resolver types
- ConfigMap-based configuration (max-size, ttl)
- Three cache modes: always, never, auto (immutability detection)
- Thread-safe concurrent access with proper locking
- Content-addressable keys using SHA-256 hashing
- Observability via annotations (cache hit/miss, timestamps)
- Clock interface for testable timestamp generation

Testing:
- Unit tests for cache operations, TTL, LRU eviction
- Race detector tests for concurrent access
- E2E tests for end-to-end cache behavior
- High-load concurrency tests (1000 goroutines)

Implementation uses k8s.io/apimachinery LRUExpireCache with ConfigMap
watching for dynamic reconfiguration without restart.

Co-authored-by: Brian Cook <[email protected]>
Co-authored-by: Stanislav Jakuschevskij <[email protected]>
Co-authored-by: Vibhav Bobade <[email protected]>
Co-authored-by: AI Assistant <[email protected]>
@waveywaves waveywaves force-pushed the brianwcook-resolver-cache branch 2 times, most recently from b6d58c3 to aefb3c1 Compare October 29, 2025 13:41
@waveywaves waveywaves force-pushed the brianwcook-resolver-cache branch from aefb3c1 to 97db47e Compare October 29, 2025 15:48
@waveywaves waveywaves force-pushed the brianwcook-resolver-cache branch from 97db47e to 9396379 Compare October 29, 2025 16:12
@waveywaves waveywaves force-pushed the brianwcook-resolver-cache branch from 08e8c3a to 4b40ad4 Compare October 29, 2025 18:43
@waveywaves waveywaves force-pushed the brianwcook-resolver-cache branch from 4b40ad4 to ded85a8 Compare October 29, 2025 19:02
@waveywaves waveywaves force-pushed the brianwcook-resolver-cache branch from 991f504 to 401f09f Compare October 29, 2025 19:31
@waveywaves
Copy link
Member

/retest

1 similar comment
@waveywaves
Copy link
Member

/retest

@vdemeester
Copy link
Member

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Oct 30, 2025
@tekton-robot tekton-robot merged commit 50999b6 into tektoncd:main Oct 30, 2025
57 of 63 checks passed
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This didn't change anything but make the cacheConfig and its properties public. @waveywaves

@vdemeester vdemeester deleted the brianwcook-resolver-cache branch October 30, 2025 11:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants