1
0
Fork 0
mirror of https://github.com/imjasonh/git-k8s synced 2026-07-18 15:05:45 +00:00

Address PR review comments: fix ref counting, dedup resolveAuth, remove unused CacheStatus

- Fix Release() ref counting bug: avoid calling getRef() which increments
  count, instead look up ref directly and clean up when count reaches zero
- Remove unpopulated CacheStatus struct and fields from types, deepcopy,
  and CRD manifest since nothing writes to them
- Extract duplicated resolveAuth into shared pkg/gitauth package with
  explicit key validation for missing "username"/"password" keys
- Fix GC() race condition by skipping paths with active in-process refs
- Remove misleading WorkspaceCacheMiss metric increment for in-memory
  (non-cache) code paths
- Change push controller from shallow to full clones to avoid silent
  failures when transactions reference historical commits
- Add tests for ref count cleanup, ref leak prevention, GC active ref
  skipping, and gitauth key validation

https://claude.ai/code/session_01WJE6ozYXZMn1CD6d4vy8b6
This commit is contained in:
Claude 2026-03-17 15:45:09 +00:00
parent 6cf845639e
commit 3b8e1bc276
No known key found for this signature in database
13 changed files with 390 additions and 186 deletions

View file

@ -70,25 +70,6 @@ type GitRepositoryStatus struct {
// LastFetchTime is the timestamp of the last successful fetch.
// +optional
LastFetchTime *metav1.Time `json:"lastFetchTime,omitempty"`
// Cache contains cache health information.
// +optional
Cache *CacheStatus `json:"cache,omitempty"`
}
// CacheStatus reports the current state of the on-disk cache for a repository.
type CacheStatus struct {
// LastCloneTime is the timestamp of the initial clone to disk.
// +optional
LastCloneTime *metav1.Time `json:"lastCloneTime,omitempty"`
// LastFetchTime is the timestamp of the last git fetch on the cached repo.
// +optional
LastFetchTime *metav1.Time `json:"lastFetchTime,omitempty"`
// SizeBytes is the approximate size of the cached repo on disk.
// +optional
SizeBytes int64 `json:"sizeBytes,omitempty"`
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

View file

@ -25,29 +25,6 @@ func (in *CacheConfig) DeepCopy() *CacheConfig {
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *CacheStatus) DeepCopyInto(out *CacheStatus) {
*out = *in
if in.LastCloneTime != nil {
in, out := &in.LastCloneTime, &out.LastCloneTime
*out = (*in).DeepCopy()
}
if in.LastFetchTime != nil {
in, out := &in.LastFetchTime, &out.LastFetchTime
*out = (*in).DeepCopy()
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CacheStatus.
func (in *CacheStatus) DeepCopy() *CacheStatus {
if in == nil {
return nil
}
out := new(CacheStatus)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *GitAuth) DeepCopyInto(out *GitAuth) {
*out = *in
@ -148,11 +125,6 @@ func (in *GitRepositoryStatus) DeepCopyInto(out *GitRepositoryStatus) {
in, out := &in.LastFetchTime, &out.LastFetchTime
*out = (*in).DeepCopy()
}
if in.Cache != nil {
in, out := &in.Cache, &out.Cache
*out = new(CacheStatus)
(*in).DeepCopyInto(*out)
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GitRepositoryStatus.