mirror of
https://github.com/imjasonh/git-k8s
synced 2026-07-16 12:33:02 +00:00
Implement PVC-backed Git workspace cache (design-pvc-workspace.md)
Add pkg/workspace.Manager that provides Acquire/Release semantics for Git repos. When GIT_CACHE_DIR is set and a GitRepository has spec.cache.enabled, controllers use on-disk bare clones with incremental fetch; otherwise they fall back to the existing in-memory clone behavior. Key changes: - New pkg/workspace package with Manager, Workspace, GC, Deepen, and context-based injection (WithManager/GetManager) - GitRepository API gains spec.cache (CacheConfig) and status.cache (CacheStatus) with deepcopy and CRD schema updates - Push, sync, and resolver reconcilers now use workspace.Acquire/Release instead of inline memory.NewStorage + git.CloneContext - Shallow clone by default; sync/resolver deepen as needed for merge-base - New Prometheus metrics: workspace_acquire_duration_seconds, workspace_cache_hit_total, workspace_cache_miss_total - Deployment manifests include commented-out PVC configuration - Comprehensive unit tests for workspace package (21 tests) - E2E tests for cache-free and cache-enabled push flows https://claude.ai/code/session_01NULGxaCLPMT1yDVEAsffc5
This commit is contained in:
parent
831132d826
commit
a1a4142976
22 changed files with 1374 additions and 69 deletions
|
|
@ -1,16 +1,26 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"knative.dev/pkg/injection/sharedmain"
|
||||
"knative.dev/pkg/signals"
|
||||
|
||||
"github.com/imjasonh/git-k8s/pkg/health"
|
||||
_ "github.com/imjasonh/git-k8s/pkg/metrics" // register Prometheus metrics
|
||||
"github.com/imjasonh/git-k8s/pkg/reconciler/push"
|
||||
"github.com/imjasonh/git-k8s/pkg/workspace"
|
||||
)
|
||||
|
||||
func main() {
|
||||
ctx := signals.NewContext()
|
||||
go health.ServeMetrics(ctx, ":9090") //nolint:errcheck
|
||||
|
||||
// GIT_CACHE_DIR enables PVC-backed workspace caching when set.
|
||||
// Push controller uses shallow clones since it only needs to push refs.
|
||||
cacheDir := os.Getenv("GIT_CACHE_DIR")
|
||||
wsMgr := workspace.NewManager(cacheDir, true /* shallow */)
|
||||
ctx = workspace.WithManager(ctx, wsMgr)
|
||||
|
||||
sharedmain.MainWithContext(ctx, "push-controller", push.NewController)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue