gitrepo: remove `OptimizedGitClones` as a feature gate
Remove the `OptimizedGitClones` feature gate, making optimized Git clones when using a branch or tag to checkout, the default behavior. Signed-off-by: Sanskar Jaiswal <jaiswalsanskar078@gmail.com>
This commit is contained in:
parent
589bbc2fc9
commit
69f567bdc7
|
@ -433,24 +433,6 @@ GitRepository, and changes to the resource or in the Git repository will not
|
|||
result in a new Artifact. When the field is set to `false` or removed, it will
|
||||
resume.
|
||||
|
||||
#### Optimized Git clones
|
||||
|
||||
Optimized Git clones decreases resource utilization for GitRepository
|
||||
reconciliations.
|
||||
|
||||
When enabled, it avoids full Git clone operations by first checking whether
|
||||
the revision of the last stored artifact is still the head of the remote
|
||||
repository and none of the other factors that contribute to a change in the
|
||||
artifact, like ignore rules and included repositories, have changed. If that is
|
||||
so, the reconciliation is skipped. Else, a full reconciliation is performed as
|
||||
usual.
|
||||
|
||||
This feature is enabled by default. It can be disabled by starting the
|
||||
controller with the argument `--feature-gates=OptimizedGitClones=false`.
|
||||
|
||||
NB: GitRepository objects configured for SemVer or Commit clones are
|
||||
not affected by this functionality.
|
||||
|
||||
#### Proxy support
|
||||
|
||||
When a proxy is configured in the source-controller Pod through the appropriate
|
||||
|
|
|
@ -536,12 +536,7 @@ func (r *GitRepositoryReconciler) reconcileSource(ctx context.Context, sp *patch
|
|||
// Persist the ArtifactSet.
|
||||
*includes = *artifacts
|
||||
|
||||
var optimizedClone bool
|
||||
if val, ok := r.features[features.OptimizedGitClones]; ok && val {
|
||||
optimizedClone = true
|
||||
}
|
||||
|
||||
c, err := r.gitCheckout(ctx, obj, authOpts, dir, optimizedClone)
|
||||
c, err := r.gitCheckout(ctx, obj, authOpts, dir)
|
||||
if err != nil {
|
||||
return sreconcile.ResultEmpty, err
|
||||
}
|
||||
|
@ -583,7 +578,7 @@ func (r *GitRepositoryReconciler) reconcileSource(ctx context.Context, sp *patch
|
|||
|
||||
// If we can't skip the reconciliation, checkout again without any
|
||||
// optimization.
|
||||
c, err := r.gitCheckout(ctx, obj, authOpts, dir, false)
|
||||
c, err := r.gitCheckout(ctx, obj, authOpts, dir)
|
||||
if err != nil {
|
||||
return sreconcile.ResultEmpty, err
|
||||
}
|
||||
|
@ -782,8 +777,7 @@ func (r *GitRepositoryReconciler) reconcileInclude(ctx context.Context, sp *patc
|
|||
// gitCheckout builds checkout options with the given configurations and
|
||||
// performs a git checkout.
|
||||
func (r *GitRepositoryReconciler) gitCheckout(ctx context.Context,
|
||||
obj *sourcev1.GitRepository, authOpts *git.AuthOptions, dir string,
|
||||
optimized bool) (*git.Commit, error) {
|
||||
obj *sourcev1.GitRepository, authOpts *git.AuthOptions, dir string) (*git.Commit, error) {
|
||||
// Configure checkout strategy.
|
||||
cloneOpts := repository.CloneConfig{
|
||||
RecurseSubmodules: obj.Spec.RecurseSubmodules,
|
||||
|
@ -800,7 +794,7 @@ func (r *GitRepositoryReconciler) gitCheckout(ctx context.Context,
|
|||
// Only if the object has an existing artifact in storage, attempt to
|
||||
// short-circuit clone operation. reconcileStorage has already verified
|
||||
// that the artifact exists.
|
||||
if optimized && conditions.IsTrue(obj, sourcev1.ArtifactInStorageCondition) {
|
||||
if conditions.IsTrue(obj, sourcev1.ArtifactInStorageCondition) {
|
||||
if artifact := obj.GetArtifact(); artifact != nil {
|
||||
cloneOpts.LastObservedCommit = artifact.Revision
|
||||
}
|
||||
|
|
|
@ -562,10 +562,7 @@ func TestGitRepositoryReconciler_reconcileSource_authStrategy(t *testing.T) {
|
|||
Client: clientBuilder.Build(),
|
||||
EventRecorder: record.NewFakeRecorder(32),
|
||||
Storage: testStorage,
|
||||
features: map[string]bool{
|
||||
features.OptimizedGitClones: true,
|
||||
},
|
||||
patchOptions: getPatchOptions(gitRepositoryReadyCondition.Owned, "sc"),
|
||||
patchOptions: getPatchOptions(gitRepositoryReadyCondition.Owned, "sc"),
|
||||
}
|
||||
|
||||
tmpDir := t.TempDir()
|
||||
|
@ -792,10 +789,7 @@ func TestGitRepositoryReconciler_reconcileSource_checkoutStrategy(t *testing.T)
|
|||
Build(),
|
||||
EventRecorder: record.NewFakeRecorder(32),
|
||||
Storage: testStorage,
|
||||
features: map[string]bool{
|
||||
features.OptimizedGitClones: true,
|
||||
},
|
||||
patchOptions: getPatchOptions(gitRepositoryReadyCondition.Owned, "sc"),
|
||||
patchOptions: getPatchOptions(gitRepositoryReadyCondition.Owned, "sc"),
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
|
|
|
@ -50,7 +50,6 @@ import (
|
|||
sourcev1 "github.com/fluxcd/source-controller/api/v1"
|
||||
sourcev1beta2 "github.com/fluxcd/source-controller/api/v1beta2"
|
||||
"github.com/fluxcd/source-controller/internal/cache"
|
||||
"github.com/fluxcd/source-controller/internal/features"
|
||||
"github.com/fluxcd/source-controller/internal/helm/registry"
|
||||
// +kubebuilder:scaffold:imports
|
||||
)
|
||||
|
@ -241,9 +240,6 @@ func TestMain(m *testing.M) {
|
|||
EventRecorder: record.NewFakeRecorder(32),
|
||||
Metrics: testMetricsH,
|
||||
Storage: testStorage,
|
||||
features: map[string]bool{
|
||||
features.OptimizedGitClones: true,
|
||||
},
|
||||
}).SetupWithManagerAndOptions(testEnv, GitRepositoryReconcilerOptions{
|
||||
RateLimiter: controller.GetDefaultRateLimiter(),
|
||||
}); err != nil {
|
||||
|
|
|
@ -22,13 +22,6 @@ package features
|
|||
import feathelper "github.com/fluxcd/pkg/runtime/features"
|
||||
|
||||
const (
|
||||
// OptimizedGitClones decreases resource utilization for GitRepository
|
||||
// reconciliations.
|
||||
//
|
||||
// When enabled, avoids full clone operations by first checking whether
|
||||
// the last revision is still the same at the target repository,
|
||||
// and if that is so, skips the reconciliation.
|
||||
OptimizedGitClones = "OptimizedGitClones"
|
||||
// CacheSecretsAndConfigMaps controls whether secrets and configmaps should be cached.
|
||||
//
|
||||
// When enabled, it will cache both object types, resulting in increased memory usage
|
||||
|
@ -37,9 +30,6 @@ const (
|
|||
)
|
||||
|
||||
var features = map[string]bool{
|
||||
// OptimizedGitClones
|
||||
// opt-out from v0.25
|
||||
OptimizedGitClones: true,
|
||||
// CacheSecretsAndConfigMaps
|
||||
// opt-in from v0.34
|
||||
CacheSecretsAndConfigMaps: false,
|
||||
|
|
Loading…
Reference in New Issue