Add reconcileID to all reconcilers
GitRepository introduced correlation ID to improve transport level logging. This change aligns the other reconcilers to the same approach. Signed-off-by: Paulo Gomes <paulo.gomes@weave.works>
This commit is contained in:
parent
cea9ea9142
commit
42dcb87345
|
|
@ -34,6 +34,7 @@ import (
|
|||
corev1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/apimachinery/pkg/util/uuid"
|
||||
kuberecorder "k8s.io/client-go/tools/record"
|
||||
ctrl "sigs.k8s.io/controller-runtime"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
|
|
@ -246,7 +247,13 @@ func (r *BucketReconciler) SetupWithManagerAndOptions(mgr ctrl.Manager, opts Buc
|
|||
|
||||
func (r *BucketReconciler) Reconcile(ctx context.Context, req ctrl.Request) (result ctrl.Result, retErr error) {
|
||||
start := time.Now()
|
||||
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)
|
||||
|
||||
// Fetch the Bucket
|
||||
obj := &sourcev1.Bucket{}
|
||||
|
|
|
|||
|
|
@ -29,10 +29,10 @@ import (
|
|||
|
||||
securejoin "github.com/cyphar/filepath-securejoin"
|
||||
"github.com/fluxcd/pkg/runtime/logger"
|
||||
"github.com/google/uuid"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/apimachinery/pkg/util/uuid"
|
||||
kuberecorder "k8s.io/client-go/tools/record"
|
||||
ctrl "sigs.k8s.io/controller-runtime"
|
||||
"sigs.k8s.io/controller-runtime/pkg/builder"
|
||||
|
|
@ -161,8 +161,8 @@ func (r *GitRepositoryReconciler) SetupWithManagerAndOptions(mgr ctrl.Manager, o
|
|||
func (r *GitRepositoryReconciler) Reconcile(ctx context.Context, req ctrl.Request) (result ctrl.Result, retErr error) {
|
||||
start := time.Now()
|
||||
log := ctrl.LoggerFrom(ctx).
|
||||
// Sets a correlation ID for all transport level logs.
|
||||
WithValues("cid", uuid.New())
|
||||
// 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.
|
||||
|
|
|
|||
|
|
@ -35,6 +35,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"
|
||||
ctrl "sigs.k8s.io/controller-runtime"
|
||||
"sigs.k8s.io/controller-runtime/pkg/builder"
|
||||
|
|
@ -180,7 +181,13 @@ func (r *HelmChartReconciler) SetupWithManagerAndOptions(mgr ctrl.Manager, opts
|
|||
|
||||
func (r *HelmChartReconciler) Reconcile(ctx context.Context, req ctrl.Request) (result ctrl.Result, retErr error) {
|
||||
start := time.Now()
|
||||
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)
|
||||
|
||||
// Fetch the HelmChart
|
||||
obj := &sourcev1.HelmChart{}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ import (
|
|||
corev1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/apimachinery/pkg/util/uuid"
|
||||
kuberecorder "k8s.io/client-go/tools/record"
|
||||
ctrl "sigs.k8s.io/controller-runtime"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
|
|
@ -142,7 +143,13 @@ func (r *HelmRepositoryReconciler) SetupWithManagerAndOptions(mgr ctrl.Manager,
|
|||
|
||||
func (r *HelmRepositoryReconciler) Reconcile(ctx context.Context, req ctrl.Request) (result ctrl.Result, retErr error) {
|
||||
start := time.Now()
|
||||
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)
|
||||
|
||||
// Fetch the HelmRepository
|
||||
obj := &sourcev1.HelmRepository{}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ import (
|
|||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
kerrors "k8s.io/apimachinery/pkg/util/errors"
|
||||
"k8s.io/apimachinery/pkg/util/uuid"
|
||||
kuberecorder "k8s.io/client-go/tools/record"
|
||||
ctrl "sigs.k8s.io/controller-runtime"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
|
|
@ -107,7 +108,13 @@ func (r *HelmRepositoryOCIReconciler) SetupWithManagerAndOptions(mgr ctrl.Manage
|
|||
|
||||
func (r *HelmRepositoryOCIReconciler) Reconcile(ctx context.Context, req ctrl.Request) (result ctrl.Result, retErr error) {
|
||||
start := time.Now()
|
||||
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)
|
||||
|
||||
// Fetch the HelmRepository
|
||||
obj := &sourcev1.HelmRepository{}
|
||||
|
|
|
|||
Loading…
Reference in New Issue