Skip to content

Log HTTP errors to provide faster feedback #1028

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
21 changes: 11 additions & 10 deletions internal/controller/kustomization_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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
}
Expand Down