diff --git a/go.mod b/go.mod index f49d341b..9041d64f 100644 --- a/go.mod +++ b/go.mod @@ -22,7 +22,7 @@ require ( github.com/fluxcd/pkg/apis/event v0.6.0 github.com/fluxcd/pkg/apis/kustomize v1.2.0 github.com/fluxcd/pkg/apis/meta v1.2.0 - github.com/fluxcd/pkg/http/fetch v0.7.0 + github.com/fluxcd/pkg/http/fetch v0.8.0 github.com/fluxcd/pkg/kustomize v1.5.0 github.com/fluxcd/pkg/runtime v0.43.2 github.com/fluxcd/pkg/ssa v0.35.0 diff --git a/go.sum b/go.sum index 51cdf21c..c0da7f19 100644 --- a/go.sum +++ b/go.sum @@ -142,8 +142,8 @@ github.com/fluxcd/pkg/apis/kustomize v1.2.0 h1:vkVs+OumxaWso0jNCqdgFFfMHdh+qtZhy github.com/fluxcd/pkg/apis/kustomize v1.2.0/go.mod h1:VF7tR/WuVFeum+HaMTHwp+eCtsHiiQlY6ihgqtAnW/M= github.com/fluxcd/pkg/apis/meta v1.2.0 h1:O766PzGAdMdQKybSflGL8oV0+GgCNIkdsxfalRyzeO8= github.com/fluxcd/pkg/apis/meta v1.2.0/go.mod h1:fU/Az9AoVyIxC0oI4ihG0NVMNnvrcCzdEym3wxjIQsc= -github.com/fluxcd/pkg/http/fetch v0.7.0 h1:mfp3+UE8gsELRtcv5jYAu/LjOqHXWvm/HbgxdcGlcW4= -github.com/fluxcd/pkg/http/fetch v0.7.0/go.mod h1:Us49hjAQ1br8iTPNufAgQgtReAaQZbBzNpbRY/8ryWI= +github.com/fluxcd/pkg/http/fetch v0.8.0 h1:GWiX93y6JaoS0Bm2qy0fo2OeY3xTXP8dME/Ce1iEt8A= +github.com/fluxcd/pkg/http/fetch v0.8.0/go.mod h1:Rj2b8OVDgbPzeLxt+goa9+qDJDAwC7+jNdgyXsaBglQ= github.com/fluxcd/pkg/kustomize v1.5.0 h1:Q2kynQzF4coKlOJq/XaLM+gVmVloaInkoa+vsor6Hho= github.com/fluxcd/pkg/kustomize v1.5.0/go.mod h1:QgFwpteTedb7oio5+yN+h+rhSgm253OIjmtoTow+a5c= github.com/fluxcd/pkg/runtime v0.43.2 h1:xH2BvttUqJ7wS0zjuBETr2pLXG62QY6f0mdxg5UQKio= diff --git a/internal/controller/kustomization_controller.go b/internal/controller/kustomization_controller.go index 82625f99..2e6f76d5 100644 --- a/internal/controller/kustomization_controller.go +++ b/internal/controller/kustomization_controller.go @@ -83,8 +83,9 @@ type KustomizationReconciler struct { kuberecorder.EventRecorder runtimeCtrl.Metrics - artifactFetcher *fetch.ArchiveFetcher - requeueDependency time.Duration + artifactFetchRetries int + requeueDependency time.Duration + StatusPoller *polling.StatusPoller PollingOpts polling.Options ControllerName string @@ -132,12 +133,7 @@ func (r *KustomizationReconciler) SetupWithManager(ctx context.Context, mgr ctrl r.requeueDependency = opts.DependencyRequeueInterval r.statusManager = fmt.Sprintf("gotk-%s", r.ControllerName) - r.artifactFetcher = fetch.NewArchiveFetcher( - opts.HTTPRetry, - tar.UnlimitedUntarSize, - tar.UnlimitedUntarSize, - os.Getenv("SOURCE_CONTROLLER_LOCALHOST"), - ) + r.artifactFetchRetries = opts.HTTPRetry return ctrl.NewControllerManagedBy(mgr). For(&kustomizev1.Kustomization{}, builder.WithPredicates( @@ -322,8 +318,13 @@ func (r *KustomizationReconciler) reconcile( defer os.RemoveAll(tmpDir) // Download artifact and extract files to the tmp dir. - err = r.artifactFetcher.Fetch(src.GetArtifact().URL, src.GetArtifact().Digest, tmpDir) - if err != nil { + if err = fetch.NewArchiveFetcherWithLogger( + r.artifactFetchRetries, + tar.UnlimitedUntarSize, + tar.UnlimitedUntarSize, + os.Getenv("SOURCE_CONTROLLER_LOCALHOST"), + ctrl.LoggerFrom(ctx), + ).Fetch(src.GetArtifact().URL, src.GetArtifact().Digest, tmpDir); err != nil { conditions.MarkFalse(obj, meta.ReadyCondition, kustomizev1.ArtifactFailedReason, err.Error()) return err }