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
|
result in a new Artifact. When the field is set to `false` or removed, it will
|
||||||
resume.
|
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
|
#### Proxy support
|
||||||
|
|
||||||
When a proxy is configured in the source-controller Pod through the appropriate
|
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.
|
// Persist the ArtifactSet.
|
||||||
*includes = *artifacts
|
*includes = *artifacts
|
||||||
|
|
||||||
var optimizedClone bool
|
c, err := r.gitCheckout(ctx, obj, authOpts, dir)
|
||||||
if val, ok := r.features[features.OptimizedGitClones]; ok && val {
|
|
||||||
optimizedClone = true
|
|
||||||
}
|
|
||||||
|
|
||||||
c, err := r.gitCheckout(ctx, obj, authOpts, dir, optimizedClone)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return sreconcile.ResultEmpty, err
|
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
|
// If we can't skip the reconciliation, checkout again without any
|
||||||
// optimization.
|
// optimization.
|
||||||
c, err := r.gitCheckout(ctx, obj, authOpts, dir, false)
|
c, err := r.gitCheckout(ctx, obj, authOpts, dir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return sreconcile.ResultEmpty, err
|
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
|
// gitCheckout builds checkout options with the given configurations and
|
||||||
// performs a git checkout.
|
// performs a git checkout.
|
||||||
func (r *GitRepositoryReconciler) gitCheckout(ctx context.Context,
|
func (r *GitRepositoryReconciler) gitCheckout(ctx context.Context,
|
||||||
obj *sourcev1.GitRepository, authOpts *git.AuthOptions, dir string,
|
obj *sourcev1.GitRepository, authOpts *git.AuthOptions, dir string) (*git.Commit, error) {
|
||||||
optimized bool) (*git.Commit, error) {
|
|
||||||
// Configure checkout strategy.
|
// Configure checkout strategy.
|
||||||
cloneOpts := repository.CloneConfig{
|
cloneOpts := repository.CloneConfig{
|
||||||
RecurseSubmodules: obj.Spec.RecurseSubmodules,
|
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
|
// Only if the object has an existing artifact in storage, attempt to
|
||||||
// short-circuit clone operation. reconcileStorage has already verified
|
// short-circuit clone operation. reconcileStorage has already verified
|
||||||
// that the artifact exists.
|
// that the artifact exists.
|
||||||
if optimized && conditions.IsTrue(obj, sourcev1.ArtifactInStorageCondition) {
|
if conditions.IsTrue(obj, sourcev1.ArtifactInStorageCondition) {
|
||||||
if artifact := obj.GetArtifact(); artifact != nil {
|
if artifact := obj.GetArtifact(); artifact != nil {
|
||||||
cloneOpts.LastObservedCommit = artifact.Revision
|
cloneOpts.LastObservedCommit = artifact.Revision
|
||||||
}
|
}
|
||||||
|
|
|
@ -562,9 +562,6 @@ func TestGitRepositoryReconciler_reconcileSource_authStrategy(t *testing.T) {
|
||||||
Client: clientBuilder.Build(),
|
Client: clientBuilder.Build(),
|
||||||
EventRecorder: record.NewFakeRecorder(32),
|
EventRecorder: record.NewFakeRecorder(32),
|
||||||
Storage: testStorage,
|
Storage: testStorage,
|
||||||
features: map[string]bool{
|
|
||||||
features.OptimizedGitClones: true,
|
|
||||||
},
|
|
||||||
patchOptions: getPatchOptions(gitRepositoryReadyCondition.Owned, "sc"),
|
patchOptions: getPatchOptions(gitRepositoryReadyCondition.Owned, "sc"),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -792,9 +789,6 @@ func TestGitRepositoryReconciler_reconcileSource_checkoutStrategy(t *testing.T)
|
||||||
Build(),
|
Build(),
|
||||||
EventRecorder: record.NewFakeRecorder(32),
|
EventRecorder: record.NewFakeRecorder(32),
|
||||||
Storage: testStorage,
|
Storage: testStorage,
|
||||||
features: map[string]bool{
|
|
||||||
features.OptimizedGitClones: true,
|
|
||||||
},
|
|
||||||
patchOptions: getPatchOptions(gitRepositoryReadyCondition.Owned, "sc"),
|
patchOptions: getPatchOptions(gitRepositoryReadyCondition.Owned, "sc"),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,6 @@ import (
|
||||||
sourcev1 "github.com/fluxcd/source-controller/api/v1"
|
sourcev1 "github.com/fluxcd/source-controller/api/v1"
|
||||||
sourcev1beta2 "github.com/fluxcd/source-controller/api/v1beta2"
|
sourcev1beta2 "github.com/fluxcd/source-controller/api/v1beta2"
|
||||||
"github.com/fluxcd/source-controller/internal/cache"
|
"github.com/fluxcd/source-controller/internal/cache"
|
||||||
"github.com/fluxcd/source-controller/internal/features"
|
|
||||||
"github.com/fluxcd/source-controller/internal/helm/registry"
|
"github.com/fluxcd/source-controller/internal/helm/registry"
|
||||||
// +kubebuilder:scaffold:imports
|
// +kubebuilder:scaffold:imports
|
||||||
)
|
)
|
||||||
|
@ -241,9 +240,6 @@ func TestMain(m *testing.M) {
|
||||||
EventRecorder: record.NewFakeRecorder(32),
|
EventRecorder: record.NewFakeRecorder(32),
|
||||||
Metrics: testMetricsH,
|
Metrics: testMetricsH,
|
||||||
Storage: testStorage,
|
Storage: testStorage,
|
||||||
features: map[string]bool{
|
|
||||||
features.OptimizedGitClones: true,
|
|
||||||
},
|
|
||||||
}).SetupWithManagerAndOptions(testEnv, GitRepositoryReconcilerOptions{
|
}).SetupWithManagerAndOptions(testEnv, GitRepositoryReconcilerOptions{
|
||||||
RateLimiter: controller.GetDefaultRateLimiter(),
|
RateLimiter: controller.GetDefaultRateLimiter(),
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
|
|
|
@ -22,13 +22,6 @@ package features
|
||||||
import feathelper "github.com/fluxcd/pkg/runtime/features"
|
import feathelper "github.com/fluxcd/pkg/runtime/features"
|
||||||
|
|
||||||
const (
|
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.
|
// CacheSecretsAndConfigMaps controls whether secrets and configmaps should be cached.
|
||||||
//
|
//
|
||||||
// When enabled, it will cache both object types, resulting in increased memory usage
|
// When enabled, it will cache both object types, resulting in increased memory usage
|
||||||
|
@ -37,9 +30,6 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
var features = map[string]bool{
|
var features = map[string]bool{
|
||||||
// OptimizedGitClones
|
|
||||||
// opt-out from v0.25
|
|
||||||
OptimizedGitClones: true,
|
|
||||||
// CacheSecretsAndConfigMaps
|
// CacheSecretsAndConfigMaps
|
||||||
// opt-in from v0.34
|
// opt-in from v0.34
|
||||||
CacheSecretsAndConfigMaps: false,
|
CacheSecretsAndConfigMaps: false,
|
||||||
|
|
Loading…
Reference in New Issue