Skip to content

Commit c758e66

Browse files
authored
Merge pull request #1124 from fluxcd/rm-optimized-clone-feat
gitrepo: remove `OptimizedGitClones` as a feature gate
2 parents 589bbc2 + 69f567b commit c758e66

File tree

5 files changed

+6
-50
lines changed

5 files changed

+6
-50
lines changed

docs/spec/v1/gitrepositories.md

-18
Original file line numberDiff line numberDiff line change
@@ -433,24 +433,6 @@ GitRepository, and changes to the resource or in the Git repository will not
433433
result in a new Artifact. When the field is set to `false` or removed, it will
434434
resume.
435435

436-
#### Optimized Git clones
437-
438-
Optimized Git clones decreases resource utilization for GitRepository
439-
reconciliations.
440-
441-
When enabled, it avoids full Git clone operations by first checking whether
442-
the revision of the last stored artifact is still the head of the remote
443-
repository and none of the other factors that contribute to a change in the
444-
artifact, like ignore rules and included repositories, have changed. If that is
445-
so, the reconciliation is skipped. Else, a full reconciliation is performed as
446-
usual.
447-
448-
This feature is enabled by default. It can be disabled by starting the
449-
controller with the argument `--feature-gates=OptimizedGitClones=false`.
450-
451-
NB: GitRepository objects configured for SemVer or Commit clones are
452-
not affected by this functionality.
453-
454436
#### Proxy support
455437

456438
When a proxy is configured in the source-controller Pod through the appropriate

internal/controller/gitrepository_controller.go

+4-10
Original file line numberDiff line numberDiff line change
@@ -536,12 +536,7 @@ func (r *GitRepositoryReconciler) reconcileSource(ctx context.Context, sp *patch
536536
// Persist the ArtifactSet.
537537
*includes = *artifacts
538538

539-
var optimizedClone bool
540-
if val, ok := r.features[features.OptimizedGitClones]; ok && val {
541-
optimizedClone = true
542-
}
543-
544-
c, err := r.gitCheckout(ctx, obj, authOpts, dir, optimizedClone)
539+
c, err := r.gitCheckout(ctx, obj, authOpts, dir)
545540
if err != nil {
546541
return sreconcile.ResultEmpty, err
547542
}
@@ -583,7 +578,7 @@ func (r *GitRepositoryReconciler) reconcileSource(ctx context.Context, sp *patch
583578

584579
// If we can't skip the reconciliation, checkout again without any
585580
// optimization.
586-
c, err := r.gitCheckout(ctx, obj, authOpts, dir, false)
581+
c, err := r.gitCheckout(ctx, obj, authOpts, dir)
587582
if err != nil {
588583
return sreconcile.ResultEmpty, err
589584
}
@@ -782,8 +777,7 @@ func (r *GitRepositoryReconciler) reconcileInclude(ctx context.Context, sp *patc
782777
// gitCheckout builds checkout options with the given configurations and
783778
// performs a git checkout.
784779
func (r *GitRepositoryReconciler) gitCheckout(ctx context.Context,
785-
obj *sourcev1.GitRepository, authOpts *git.AuthOptions, dir string,
786-
optimized bool) (*git.Commit, error) {
780+
obj *sourcev1.GitRepository, authOpts *git.AuthOptions, dir string) (*git.Commit, error) {
787781
// Configure checkout strategy.
788782
cloneOpts := repository.CloneConfig{
789783
RecurseSubmodules: obj.Spec.RecurseSubmodules,
@@ -800,7 +794,7 @@ func (r *GitRepositoryReconciler) gitCheckout(ctx context.Context,
800794
// Only if the object has an existing artifact in storage, attempt to
801795
// short-circuit clone operation. reconcileStorage has already verified
802796
// that the artifact exists.
803-
if optimized && conditions.IsTrue(obj, sourcev1.ArtifactInStorageCondition) {
797+
if conditions.IsTrue(obj, sourcev1.ArtifactInStorageCondition) {
804798
if artifact := obj.GetArtifact(); artifact != nil {
805799
cloneOpts.LastObservedCommit = artifact.Revision
806800
}

internal/controller/gitrepository_controller_test.go

+2-8
Original file line numberDiff line numberDiff line change
@@ -562,10 +562,7 @@ func TestGitRepositoryReconciler_reconcileSource_authStrategy(t *testing.T) {
562562
Client: clientBuilder.Build(),
563563
EventRecorder: record.NewFakeRecorder(32),
564564
Storage: testStorage,
565-
features: map[string]bool{
566-
features.OptimizedGitClones: true,
567-
},
568-
patchOptions: getPatchOptions(gitRepositoryReadyCondition.Owned, "sc"),
565+
patchOptions: getPatchOptions(gitRepositoryReadyCondition.Owned, "sc"),
569566
}
570567

571568
tmpDir := t.TempDir()
@@ -792,10 +789,7 @@ func TestGitRepositoryReconciler_reconcileSource_checkoutStrategy(t *testing.T)
792789
Build(),
793790
EventRecorder: record.NewFakeRecorder(32),
794791
Storage: testStorage,
795-
features: map[string]bool{
796-
features.OptimizedGitClones: true,
797-
},
798-
patchOptions: getPatchOptions(gitRepositoryReadyCondition.Owned, "sc"),
792+
patchOptions: getPatchOptions(gitRepositoryReadyCondition.Owned, "sc"),
799793
}
800794

801795
for _, tt := range tests {

internal/controller/suite_test.go

-4
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ import (
5050
sourcev1 "github.com/fluxcd/source-controller/api/v1"
5151
sourcev1beta2 "github.com/fluxcd/source-controller/api/v1beta2"
5252
"github.com/fluxcd/source-controller/internal/cache"
53-
"github.com/fluxcd/source-controller/internal/features"
5453
"github.com/fluxcd/source-controller/internal/helm/registry"
5554
// +kubebuilder:scaffold:imports
5655
)
@@ -241,9 +240,6 @@ func TestMain(m *testing.M) {
241240
EventRecorder: record.NewFakeRecorder(32),
242241
Metrics: testMetricsH,
243242
Storage: testStorage,
244-
features: map[string]bool{
245-
features.OptimizedGitClones: true,
246-
},
247243
}).SetupWithManagerAndOptions(testEnv, GitRepositoryReconcilerOptions{
248244
RateLimiter: controller.GetDefaultRateLimiter(),
249245
}); err != nil {

internal/features/features.go

-10
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,6 @@ package features
2222
import feathelper "github.com/fluxcd/pkg/runtime/features"
2323

2424
const (
25-
// OptimizedGitClones decreases resource utilization for GitRepository
26-
// reconciliations.
27-
//
28-
// When enabled, avoids full clone operations by first checking whether
29-
// the last revision is still the same at the target repository,
30-
// and if that is so, skips the reconciliation.
31-
OptimizedGitClones = "OptimizedGitClones"
3225
// CacheSecretsAndConfigMaps controls whether secrets and configmaps should be cached.
3326
//
3427
// When enabled, it will cache both object types, resulting in increased memory usage
@@ -37,9 +30,6 @@ const (
3730
)
3831

3932
var features = map[string]bool{
40-
// OptimizedGitClones
41-
// opt-out from v0.25
42-
OptimizedGitClones: true,
4333
// CacheSecretsAndConfigMaps
4434
// opt-in from v0.34
4535
CacheSecretsAndConfigMaps: false,

0 commit comments

Comments
 (0)