Use partial, sparse clone in the git resolver - #10665
Open
sukkola wants to merge 1 commit into
Open
Conversation
The git resolver clones the whole repository to read one file. For a 300MB repo this costs 601MB of resolver disk and 46s per resolution, and the resolver's /tmp emptyDir is capped at 4Gi, so a handful of concurrent large-repo resolutions risk evicting the resolver pod and stalling every build in the cluster. Since tektoncd#8677 replaced go-git with the native git binary, the resolver can use git's own partial + sparse clone support directly: derive the sparse cone from the existing pathInRepo param rather than adding a new resolver parameter. Sparse checkout alone is not enough - the transfer, not the checkout, is the cost (measured 301MB/44s without --filter, against 1MB/<1s with it, same commit). Falls back to today's exact unfiltered clone sequence whenever the filtered clone or the subsequent filtered fetch fails, without pattern-matching git's error text. Verified this fallback engages for real (not only in a mock): live against Forgejo with partial clone disabled, against a raw git-daemon with direct control over uploadpack.allowFilter/allowAnySHA1InWant, and against a genuine network/auth failure through the patched resolver in a running cluster. A single transient failure retries the same filtered operation once before escalating to the more expensive fallback, so a flaky connection does not by itself force a full clone of what may be a very large repository. Resolves tektoncd#6176. Assisted-by: Claude Sonnet 5
|
|
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 git resolver clones the whole repository to read one file. For a 300MB
repo this costs 601MB of resolver disk and 46s per resolution, and the
resolver's
/tmpemptyDir is capped at 4Gi, so a handful of concurrentlarge-repo resolutions risk evicting the resolver pod and stalling every
build in the cluster.
Since #8677 replaced go-git with the native git binary, the resolver can use
git's own partial + sparse clone support directly (
--filter=blob:none --sparse), deriving the sparse cone from the existingpathInRepoparamrather than adding a new resolver parameter. Sparse checkout alone is not
enough — the transfer, not the checkout, is the cost (measured 301MB/44s
without
--filter, against 1MB/<1s with it, same commit, same repo).Resolves #6176.
Fallback and reliability
Falls back to today's exact unfiltered clone sequence whenever the filtered
clone or the subsequent filtered fetch fails, without pattern-matching git's
error text. Verified this fallback engages for real, not only in a mock:
live against Forgejo with partial clone explicitly disabled
(
DISABLE_PARTIAL_CLONE), against a rawgit daemonwith direct controlover
uploadpack.allowFilter/allowAnySHA1InWant, and against a genuineauth/network failure through the patched resolver in a running cluster.
A single transient failure of the filtered clone or fetch is retried once
before escalating to the more expensive unfiltered fallback, so a flaky
connection does not by itself force a full clone of what may be a very
large repository.
Open question for maintainers: the retry count (currently a fixed 1
retry) and whether it should use the resolver's existing
backoff-*configinstead of an immediate retry are not resolved here — raising this
explicitly rather than assuming an answer. If configurability is wanted,
resolvers-feature-flags/git-resolver-config(used already forenable-git-resolver,backoff-*, etc.) looks like the natural place, asan operator-facing setting rather than a resolver param.
Scope
Applies to both anonymous and
gitToken-authenticated clones — the cost isidentical and it's the same code path. Issue #6176 titles this "for
anonymous git resolutions"; restricting the fix to anonymous clones would
leave private repositories, arguably the case that motivates it most in
practice, paying full price.
Out of scope: the resolver's authenticated API mode (
org/repo+token), which already fetches only the file; the resolver cache contract(cache keys are untouched — this changes only how a file is fetched, never
what's returned); and the stale docs line claiming clone mode "clones the
entire repository in memory" (true of the old go-git implementation, false
since #8677) — worth a separate one-line docs PR.
Submitter Checklist
/kind <type>. Valid types are bug, cleanup, design, documentation, feature, flake, misc, question, tepRelease Notes
This contribution was substantially AI-assisted (Claude Sonnet 5), disclosed per Tekton's AI contribution policy and via the
Assisted-by:commit trailer. I've read and understand the change; happy to answer questions about any part of it.