From 2bbf14e499bb7692176b4ae1ad49e5fa0b2cf5d2 Mon Sep 17 00:00:00 2001 From: Paulo Gomes Date: Thu, 16 Jun 2022 14:10:05 +0100 Subject: [PATCH] WIP - Update source-controller to v0.25.6 This version of source-controller introduces a fix for the SSH connections leak issue reported at: https://github.com/fluxcd/image-automation-controller/issues/334 Signed-off-by: Paulo Gomes --- api/go.mod | 2 +- api/go.sum | 4 ++-- controllers/imageupdateautomation_controller.go | 10 +++++++++- controllers/suite_test.go | 3 +-- go.mod | 6 ++++-- go.sum | 8 ++++---- 6 files changed, 21 insertions(+), 12 deletions(-) diff --git a/api/go.mod b/api/go.mod index bf60c046..062e9648 100644 --- a/api/go.mod +++ b/api/go.mod @@ -4,7 +4,7 @@ go 1.17 require ( github.com/fluxcd/pkg/apis/meta v0.14.2 - github.com/fluxcd/source-controller/api v0.25.5 + github.com/fluxcd/source-controller/api v0.25.6 k8s.io/apimachinery v0.24.1 sigs.k8s.io/controller-runtime v0.11.2 ) diff --git a/api/go.sum b/api/go.sum index 97ac5ef8..c8e4abe0 100644 --- a/api/go.sum +++ b/api/go.sum @@ -21,8 +21,8 @@ github.com/fluxcd/pkg/apis/acl v0.0.3 h1:Lw0ZHdpnO4G7Zy9KjrzwwBmDZQuy4qEjaU/RvA6 github.com/fluxcd/pkg/apis/acl v0.0.3/go.mod h1:XPts6lRJ9C9fIF9xVWofmQwftvhY25n1ps7W9xw0XLU= github.com/fluxcd/pkg/apis/meta v0.14.2 h1:/Hf7I/Vz01vv3m7Qx7DtQvrzAL1oVt0MJcLb/I1Y1HE= github.com/fluxcd/pkg/apis/meta v0.14.2/go.mod h1:ijZ61VG/8T3U17gj0aFL3fdtZL+mulD6V8VrLLUCAgM= -github.com/fluxcd/source-controller/api v0.25.5 h1:64rLb5cuHhZ3LcRIxkp+/oAVCyVtjOhQ9kbphdFfR/s= -github.com/fluxcd/source-controller/api v0.25.5/go.mod h1:/e7YRDOqb8z8I3N8ifbDF1mknf8zFsoADtS/Q93iWPs= +github.com/fluxcd/source-controller/api v0.25.6 h1:+wdA6SfOrUFW0sWNSHS5X4i4tgWZgySatJ+OT0Gxt6I= +github.com/fluxcd/source-controller/api v0.25.6/go.mod h1:/e7YRDOqb8z8I3N8ifbDF1mknf8zFsoADtS/Q93iWPs= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/fsnotify/fsnotify v1.5.1 h1:mZcQUHVQUQWoPXXtuf9yuEXKudkV2sx1E06UadKWpgI= diff --git a/controllers/imageupdateautomation_controller.go b/controllers/imageupdateautomation_controller.go index 3399107d..18044bdd 100644 --- a/controllers/imageupdateautomation_controller.go +++ b/controllers/imageupdateautomation_controller.go @@ -40,6 +40,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" + "k8s.io/apimachinery/pkg/util/uuid" kuberecorder "k8s.io/client-go/tools/record" "k8s.io/client-go/tools/reference" ctrl "sigs.k8s.io/controller-runtime" @@ -104,7 +105,14 @@ type ImageUpdateAutomationReconcilerOptions struct { // +kubebuilder:rbac:groups=source.toolkit.fluxcd.io,resources=gitrepositories,verbs=get;list;watch func (r *ImageUpdateAutomationReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { - log := ctrl.LoggerFrom(ctx) + log := ctrl.LoggerFrom(ctx). + // Sets a reconcile ID to correlate logs from all suboperations. + WithValues("reconcileID", uuid.NewUUID()) + + // logger will be associated to the new context that is + // returned from ctrl.LoggerInto. + ctx = ctrl.LoggerInto(ctx, log) + debuglog := log.V(logger.DebugLevel) tracelog := log.V(logger.TraceLevel) now := time.Now() diff --git a/controllers/suite_test.go b/controllers/suite_test.go index 7d6a2817..f28695e8 100644 --- a/controllers/suite_test.go +++ b/controllers/suite_test.go @@ -24,7 +24,6 @@ import ( "testing" "time" - "github.com/go-logr/logr" utilruntime "k8s.io/apimachinery/pkg/util/runtime" "k8s.io/client-go/kubernetes/scheme" ctrl "sigs.k8s.io/controller-runtime" @@ -63,7 +62,7 @@ func TestMain(m *testing.M) { filepath.Join("testdata", "crds"), )) - managed.InitManagedTransport(logr.Discard()) + managed.InitManagedTransport() controllerName := "image-automation-controller" if err := (&ImageUpdateAutomationReconciler{ diff --git a/go.mod b/go.mod index 72b61b0c..f1246384 100644 --- a/go.mod +++ b/go.mod @@ -4,6 +4,8 @@ go 1.17 replace github.com/fluxcd/image-automation-controller/api => ./api +replace github.com/fluxcd/source-controller => github.com/fluxcd/source-controller v0.0.0-20220616125438-09fae634df1f + require ( github.com/Masterminds/sprig/v3 v3.2.2 github.com/ProtonMail/go-crypto v0.0.0-20220517143526-88bb52951d5b @@ -15,8 +17,8 @@ require ( github.com/fluxcd/pkg/gittestserver v0.5.4 github.com/fluxcd/pkg/runtime v0.16.2 github.com/fluxcd/pkg/ssh v0.5.0 - github.com/fluxcd/source-controller v0.25.5 - github.com/fluxcd/source-controller/api v0.25.5 + github.com/fluxcd/source-controller v0.25.6 + github.com/fluxcd/source-controller/api v0.25.6 github.com/go-logr/logr v1.2.3 github.com/google/go-containerregistry v0.9.0 github.com/libgit2/git2go/v33 v33.0.9 diff --git a/go.sum b/go.sum index 9eda0bc4..2d46f102 100644 --- a/go.sum +++ b/go.sum @@ -198,10 +198,10 @@ github.com/fluxcd/pkg/ssh v0.5.0 h1:jE9F2XvUXC2mgseeXMATvO014fLqdB30/VzlPLKsk20= github.com/fluxcd/pkg/ssh v0.5.0/go.mod h1:KGgOUOy1uI6RC6+qxIBLvP1AeOOs/nLB25Ca6TZMIXE= github.com/fluxcd/pkg/version v0.1.0 h1:v+SmCanmCB5Tj2Cx9TXlj+kNRfPGbAvirkeqsp7ZEAQ= github.com/fluxcd/pkg/version v0.1.0/go.mod h1:V7Z/w8dxLQzv0FHqa5ox5TeyOd2zOd49EeuWFgnwyj4= -github.com/fluxcd/source-controller v0.25.5 h1:a96qa3/PQPXZ7OcfLTaDmMKee/Qhxr9G8C21+/MnqhM= -github.com/fluxcd/source-controller v0.25.5/go.mod h1:401D+j+jFZcy9iuH7RrOMbkXJazsQK4Ce5q8pgKaXBI= -github.com/fluxcd/source-controller/api v0.25.5 h1:64rLb5cuHhZ3LcRIxkp+/oAVCyVtjOhQ9kbphdFfR/s= -github.com/fluxcd/source-controller/api v0.25.5/go.mod h1:/e7YRDOqb8z8I3N8ifbDF1mknf8zFsoADtS/Q93iWPs= +github.com/fluxcd/source-controller v0.0.0-20220616125438-09fae634df1f h1:gugS8VSW5mLAWLzPHiieS2iKa0NwYIv8YSmMtVUc8eI= +github.com/fluxcd/source-controller v0.0.0-20220616125438-09fae634df1f/go.mod h1:7TPzAFfWFPg2VUYdyoWEmotnonCpIgnz4RIyKOkJ+IY= +github.com/fluxcd/source-controller/api v0.25.6 h1:+wdA6SfOrUFW0sWNSHS5X4i4tgWZgySatJ+OT0Gxt6I= +github.com/fluxcd/source-controller/api v0.25.6/go.mod h1:/e7YRDOqb8z8I3N8ifbDF1mknf8zFsoADtS/Q93iWPs= github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k= github.com/form3tech-oss/jwt-go v3.2.3+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=