Skip to content

Commit e5284bc

Browse files
committed
Align controller logs to Kubernetes structured logging
Signed-off-by: Somtochi Onyekwere <[email protected]>
1 parent b4021b1 commit e5284bc

File tree

9 files changed

+19
-78
lines changed

9 files changed

+19
-78
lines changed

api/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ require (
66
github.com/fluxcd/pkg/apis/acl v0.1.0
77
github.com/fluxcd/pkg/apis/meta v0.15.0
88
k8s.io/apimachinery v0.25.0
9-
sigs.k8s.io/controller-runtime v0.11.2
9+
sigs.k8s.io/controller-runtime v0.12.3
1010
)
1111

1212
// Fix CVE-2022-28948

api/go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjY
2929
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
3030
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
3131
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
32-
github.com/onsi/gomega v1.17.0 h1:9Luw4uT5HTjHTN8+aNcSThgH1vdXnmdJ8xIfZ4wyTRE=
32+
github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE=
3333
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
3434
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
3535
github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk=
@@ -79,16 +79,16 @@ gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
7979
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
8080
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
8181
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
82-
k8s.io/api v0.23.5 h1:zno3LUiMubxD/V1Zw3ijyKO3wxrhbUF1Ck+VjBvfaoA=
82+
k8s.io/api v0.24.2 h1:g518dPU/L7VRLxWfcadQn2OnsiGWVOadTLpdnqgY2OI=
8383
k8s.io/apimachinery v0.25.0 h1:MlP0r6+3XbkUG2itd6vp3oxbtdQLQI94fD5gCS+gnoU=
8484
k8s.io/apimachinery v0.25.0/go.mod h1:qMx9eAk0sZQGsXGu86fab8tZdffHbwUfsvzqKn4mfB0=
8585
k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE=
8686
k8s.io/klog/v2 v2.70.1 h1:7aaoSdahviPmR+XkS7FyxlkkXs6tHISSG03RxleQAVQ=
8787
k8s.io/klog/v2 v2.70.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=
8888
k8s.io/utils v0.0.0-20220728103510-ee6ede2d64ed h1:jAne/RjBTyawwAy0utX5eqigAwz/lQhTmy+Hr/Cpue4=
8989
k8s.io/utils v0.0.0-20220728103510-ee6ede2d64ed/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
90-
sigs.k8s.io/controller-runtime v0.11.2 h1:H5GTxQl0Mc9UjRJhORusqfJCIjBO8UtUxGggCwL1rLA=
91-
sigs.k8s.io/controller-runtime v0.11.2/go.mod h1:P6QCzrEjLaZGqHsfd+os7JQ+WFZhvB8MRFsn4dWF7O4=
90+
sigs.k8s.io/controller-runtime v0.12.3 h1:FCM8xeY/FI8hoAfh/V4XbbYMY20gElh9yh+A98usMio=
91+
sigs.k8s.io/controller-runtime v0.12.3/go.mod h1:qKsk4WE6zW2Hfj0G4v10EnNB2jMG1C+NTb8h+DwCoU0=
9292
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 h1:iXTIw73aPyC+oRdyqqvVJuloN1p0AC/kzH07hu3NE+k=
9393
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0=
9494
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 h1:PRbqxJClWWYMNV1dhaG4NsibJbArud9kFxnAMREiWFE=

controllers/bucket_controller.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ import (
3434
corev1 "k8s.io/api/core/v1"
3535
"k8s.io/apimachinery/pkg/runtime"
3636
"k8s.io/apimachinery/pkg/types"
37-
"k8s.io/apimachinery/pkg/util/uuid"
3837
kuberecorder "k8s.io/client-go/tools/record"
3938
ctrl "sigs.k8s.io/controller-runtime"
4039
"sigs.k8s.io/controller-runtime/pkg/client"
@@ -248,9 +247,7 @@ func (r *BucketReconciler) SetupWithManagerAndOptions(mgr ctrl.Manager, opts Buc
248247

249248
func (r *BucketReconciler) Reconcile(ctx context.Context, req ctrl.Request) (result ctrl.Result, retErr error) {
250249
start := time.Now()
251-
log := ctrl.LoggerFrom(ctx).
252-
// Sets a reconcile ID to correlate logs from all suboperations.
253-
WithValues("reconcileID", uuid.NewUUID())
250+
log := ctrl.LoggerFrom(ctx)
254251

255252
// logger will be associated to the new context that is
256253
// returned from ctrl.LoggerInto.

controllers/gitrepository_controller.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import (
3232
corev1 "k8s.io/api/core/v1"
3333
"k8s.io/apimachinery/pkg/runtime"
3434
"k8s.io/apimachinery/pkg/types"
35-
"k8s.io/apimachinery/pkg/util/uuid"
3635
kuberecorder "k8s.io/client-go/tools/record"
3736
ctrl "sigs.k8s.io/controller-runtime"
3837
"sigs.k8s.io/controller-runtime/pkg/builder"
@@ -163,9 +162,7 @@ func (r *GitRepositoryReconciler) SetupWithManagerAndOptions(mgr ctrl.Manager, o
163162

164163
func (r *GitRepositoryReconciler) Reconcile(ctx context.Context, req ctrl.Request) (result ctrl.Result, retErr error) {
165164
start := time.Now()
166-
log := ctrl.LoggerFrom(ctx).
167-
// Sets a reconcile ID to correlate logs from all suboperations.
168-
WithValues("reconcileID", uuid.NewUUID())
165+
log := ctrl.LoggerFrom(ctx)
169166

170167
// logger will be associated to the new context that is
171168
// returned from ctrl.LoggerInto.

controllers/helmchart_controller.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ import (
3636
"k8s.io/apimachinery/pkg/runtime"
3737
"k8s.io/apimachinery/pkg/types"
3838
kerrors "k8s.io/apimachinery/pkg/util/errors"
39-
"k8s.io/apimachinery/pkg/util/uuid"
4039
kuberecorder "k8s.io/client-go/tools/record"
4140
ctrl "sigs.k8s.io/controller-runtime"
4241
"sigs.k8s.io/controller-runtime/pkg/builder"
@@ -184,9 +183,7 @@ func (r *HelmChartReconciler) SetupWithManagerAndOptions(mgr ctrl.Manager, opts
184183

185184
func (r *HelmChartReconciler) Reconcile(ctx context.Context, req ctrl.Request) (result ctrl.Result, retErr error) {
186185
start := time.Now()
187-
log := ctrl.LoggerFrom(ctx).
188-
// Sets a reconcile ID to correlate logs from all suboperations.
189-
WithValues("reconcileID", uuid.NewUUID())
186+
log := ctrl.LoggerFrom(ctx)
190187

191188
// logger will be associated to the new context that is
192189
// returned from ctrl.LoggerInto.

controllers/helmrepository_controller.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import (
2929
corev1 "k8s.io/api/core/v1"
3030
"k8s.io/apimachinery/pkg/runtime"
3131
"k8s.io/apimachinery/pkg/types"
32-
"k8s.io/apimachinery/pkg/util/uuid"
3332
kuberecorder "k8s.io/client-go/tools/record"
3433
ctrl "sigs.k8s.io/controller-runtime"
3534
"sigs.k8s.io/controller-runtime/pkg/client"
@@ -149,9 +148,7 @@ func (r *HelmRepositoryReconciler) SetupWithManagerAndOptions(mgr ctrl.Manager,
149148

150149
func (r *HelmRepositoryReconciler) Reconcile(ctx context.Context, req ctrl.Request) (result ctrl.Result, retErr error) {
151150
start := time.Now()
152-
log := ctrl.LoggerFrom(ctx).
153-
// Sets a reconcile ID to correlate logs from all suboperations.
154-
WithValues("reconcileID", uuid.NewUUID())
151+
log := ctrl.LoggerFrom(ctx)
155152

156153
// logger will be associated to the new context that is
157154
// returned from ctrl.LoggerInto.

controllers/ocirepository_controller.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ import (
3939
"k8s.io/apimachinery/pkg/runtime"
4040
"k8s.io/apimachinery/pkg/types"
4141
"k8s.io/apimachinery/pkg/util/sets"
42-
"k8s.io/apimachinery/pkg/util/uuid"
4342
kuberecorder "k8s.io/client-go/tools/record"
4443

4544
ctrl "sigs.k8s.io/controller-runtime"
@@ -160,9 +159,7 @@ func (r *OCIRepositoryReconciler) SetupWithManagerAndOptions(mgr ctrl.Manager, o
160159

161160
func (r *OCIRepositoryReconciler) Reconcile(ctx context.Context, req ctrl.Request) (result ctrl.Result, retErr error) {
162161
start := time.Now()
163-
log := ctrl.LoggerFrom(ctx).
164-
// Sets a reconcile ID to correlate logs from all suboperations.
165-
WithValues("reconcileID", uuid.NewUUID())
162+
log := ctrl.LoggerFrom(ctx)
166163

167164
// logger will be associated to the new context that is
168165
// returned from ctrl.LoggerInto.

go.mod

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ require (
3838
github.com/fluxcd/pkg/helmtestserver v0.8.0
3939
github.com/fluxcd/pkg/lockedfile v0.1.0
4040
github.com/fluxcd/pkg/masktoken v0.2.0
41-
github.com/fluxcd/pkg/oci v0.7.0
42-
github.com/fluxcd/pkg/runtime v0.17.0
41+
github.com/fluxcd/pkg/oci v0.8.0
42+
github.com/fluxcd/pkg/runtime v0.18.0
4343
github.com/fluxcd/pkg/sourceignore v0.2.0
4444
github.com/fluxcd/pkg/ssh v0.6.0
4545
github.com/fluxcd/pkg/testserver v0.3.0
@@ -70,11 +70,10 @@ require (
7070
k8s.io/client-go v0.25.0
7171
k8s.io/utils v0.0.0-20220823124924-e9cbc92d1a73
7272
sigs.k8s.io/cli-utils v0.33.0
73-
sigs.k8s.io/controller-runtime v0.11.2
73+
sigs.k8s.io/controller-runtime v0.12.3
7474
sigs.k8s.io/yaml v1.3.0
7575
)
7676

77-
// Fix CVE-2022-1996 (for v2, Go Modules incompatible)
7877
replace github.com/emicklei/go-restful => github.com/emicklei/go-restful v2.16.0+incompatible
7978

8079
require (

0 commit comments

Comments
 (0)