diff --git a/controllers/bucket_controller.go b/controllers/bucket_controller.go index 8c20255..f6a88bd 100644 --- a/controllers/bucket_controller.go +++ b/controllers/bucket_controller.go @@ -58,7 +58,7 @@ const bucketFinalizer = "s3.onyxia.sh/finalizer" // For more details, check Reconcile and its Result here: // - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.14.1/pkg/reconcile func (r *BucketReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { - logger := log.FromContext(ctx).WithName("bcktCtrl") + logger := log.FromContext(ctx) // Checking for bucket resource existence bucketResource := &s3v1alpha1.Bucket{} @@ -244,7 +244,7 @@ func (r *BucketReconciler) finalizeBucket(bucketResource *s3v1alpha1.Bucket) err } func (r *BucketReconciler) SetBucketStatusConditionAndUpdate(ctx context.Context, bucketResource *s3v1alpha1.Bucket, conditionType string, status metav1.ConditionStatus, reason string, message string, srcError error) (ctrl.Result, error) { - logger := log.FromContext(ctx).WithName("bcktCtrl") + logger := log.FromContext(ctx) // We moved away from meta.SetStatusCondition, as the implementation did not allow for updating // lastTransitionTime if a Condition (as identified by Reason instead of Type) was previously diff --git a/controllers/path_controller.go b/controllers/path_controller.go index ce601b8..d789d5b 100644 --- a/controllers/path_controller.go +++ b/controllers/path_controller.go @@ -58,7 +58,7 @@ const pathFinalizer = "s3.onyxia.sh/finalizer" // For more details, check Reconcile and its Result here: // - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.14.1/pkg/reconcile func (r *PathReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { - logger := log.FromContext(ctx).WithName("pathCtrl") + logger := log.FromContext(ctx) // Checking for path resource existence pathResource := &s3v1alpha1.Path{} @@ -184,7 +184,7 @@ func (r *PathReconciler) SetupWithManager(mgr ctrl.Manager) error { } func (r *PathReconciler) finalizePath(pathResource *s3v1alpha1.Path) error { - logger := log.Log.WithName("finalize") + logger := log.Log.WithValues("controller", "path") if r.PathDeletion { var failedPaths []string = make([]string, 0) for _, path := range pathResource.Spec.Paths { @@ -210,7 +210,7 @@ func (r *PathReconciler) finalizePath(pathResource *s3v1alpha1.Path) error { } func (r *PathReconciler) SetPathStatusConditionAndUpdate(ctx context.Context, pathResource *s3v1alpha1.Path, conditionType string, status metav1.ConditionStatus, reason string, message string, srcError error) (ctrl.Result, error) { - logger := log.FromContext(ctx).WithName("pathCtrl") + logger := log.FromContext(ctx) // We moved away from meta.SetStatusCondition, as the implementation did not allow for updating // lastTransitionTime if a Condition (as identified by Reason instead of Type) was previously diff --git a/controllers/policy_controller.go b/controllers/policy_controller.go index b9b6e59..1dd597a 100644 --- a/controllers/policy_controller.go +++ b/controllers/policy_controller.go @@ -61,7 +61,7 @@ const policyFinalizer = "s3.onyxia.sh/finalizer" // For more details, check Reconcile and its Result here: // - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.14.1/pkg/reconcile func (r *PolicyReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { - logger := log.FromContext(ctx).WithName("plcyCtrl") + logger := log.FromContext(ctx) // Checking for policy resource existence policyResource := &s3v1alpha1.Policy{} @@ -218,7 +218,7 @@ func (r *PolicyReconciler) finalizePolicy(policyResource *s3v1alpha1.Policy) err } func (r *PolicyReconciler) SetPolicyStatusConditionAndUpdate(ctx context.Context, policyResource *s3v1alpha1.Policy, conditionType string, status metav1.ConditionStatus, reason string, message string, srcError error) (ctrl.Result, error) { - logger := log.FromContext(ctx).WithName("plcyCtrl") + logger := log.FromContext(ctx) // We moved away from meta.SetStatusCondition, as the implementation did not allow for updating // lastTransitionTime if a Condition (as identified by Reason instead of Type) was previously diff --git a/controllers/s3/factory/interface.go b/controllers/s3/factory/interface.go index 1dba2cb..e8bf10f 100644 --- a/controllers/s3/factory/interface.go +++ b/controllers/s3/factory/interface.go @@ -9,7 +9,7 @@ import ( ) var ( - s3Logger = ctrl.Log.WithName("s3Client") + s3Logger = ctrl.Log.WithValues("logger", "s3client") ) type S3Client interface { diff --git a/controllers/user_controller.go b/controllers/user_controller.go index 41b52c7..1989a46 100644 --- a/controllers/user_controller.go +++ b/controllers/user_controller.go @@ -67,7 +67,7 @@ const ( // For more details, check Reconcile and its Result here: // - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.14.1/pkg/reconcile func (r *S3UserReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { - logger := log.FromContext(ctx).WithName("userCtrl") + logger := log.FromContext(ctx) // Checking for userResource existence userResource := &s3v1alpha1.S3User{} @@ -120,7 +120,7 @@ func (r *S3UserReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr } func (r *S3UserReconciler) handleS3ExistingUser(ctx context.Context, userResource *s3v1alpha1.S3User) (reconcile.Result, error) { - logger := log.FromContext(ctx).WithName("userCtrl") + logger := log.FromContext(ctx) // --- Begin Secret management section @@ -239,7 +239,7 @@ func (r *S3UserReconciler) handleS3ExistingUser(ctx context.Context, userResourc } func (r *S3UserReconciler) handleS3NewUser(ctx context.Context, userResource *s3v1alpha1.S3User) (reconcile.Result, error) { - logger := log.FromContext(ctx).WithName("userCtrl") + logger := log.FromContext(ctx) // Generating a random secret key secretKey, err := password.Generate(20, true, false, true) @@ -357,7 +357,7 @@ func (r *S3UserReconciler) handleS3NewUser(ctx context.Context, userResource *s3 } func (r *S3UserReconciler) addPoliciesToUser(ctx context.Context, userResource *s3v1alpha1.S3User) error { - logger := log.FromContext(ctx).WithName("userCtrl") + logger := log.FromContext(ctx) policies := userResource.Spec.Policies if policies != nil { err := r.S3Client.AddPoliciesToUser(userResource.Spec.AccessKey, policies) @@ -370,7 +370,7 @@ func (r *S3UserReconciler) addPoliciesToUser(ctx context.Context, userResource * } func (r *S3UserReconciler) handleS3UserDeletion(ctx context.Context, userResource *s3v1alpha1.S3User) (reconcile.Result, error) { - logger := log.FromContext(ctx).WithName("userCtrl") + logger := log.FromContext(ctx) if controllerutil.ContainsFinalizer(userResource, userFinalizer) { // Run finalization logic for S3UserFinalizer. If the finalization logic fails, don't remove the finalizer so that we can retry during the next reconciliation. @@ -397,7 +397,7 @@ func (r *S3UserReconciler) handleS3UserDeletion(ctx context.Context, userResourc } func (r *S3UserReconciler) getUserSecret(ctx context.Context, userResource *s3v1alpha1.S3User) (corev1.Secret, error) { - logger := log.FromContext(ctx).WithName("userCtrl") + logger := log.FromContext(ctx) // Listing every secrets in the S3User's namespace, as a first step // to get the actual secret matching the S3User proper. @@ -443,7 +443,7 @@ func (r *S3UserReconciler) getUserSecret(ctx context.Context, userResource *s3v1 } func (r *S3UserReconciler) deleteSecret(ctx context.Context, secret *corev1.Secret) { - logger := log.FromContext(ctx).WithName("userCtrl") + logger := log.FromContext(ctx) err := r.Delete(ctx, secret) if err != nil { logger.Error(err, "an error occurred while deleting a secret") @@ -492,7 +492,7 @@ func (r *S3UserReconciler) SetupWithManager(mgr ctrl.Manager) error { } func (r *S3UserReconciler) setS3UserStatusConditionAndUpdate(ctx context.Context, userResource *s3v1alpha1.S3User, conditionType string, status metav1.ConditionStatus, reason string, message string, srcError error) (ctrl.Result, error) { - logger := log.FromContext(ctx).WithName("userCtrl") + logger := log.FromContext(ctx) // We moved away from meta.SetStatusCondition, as the implementation did not allow for updating // lastTransitionTime if a Condition (as identified by Reason instead of Type) was previously @@ -524,7 +524,7 @@ func (r *S3UserReconciler) finalizeS3User(userResource *s3v1alpha1.S3User) error // newSecretForCR returns a secret with the same name/namespace as the CR. // The secret will include all labels and annotations from the CR. func (r *S3UserReconciler) newSecretForCR(ctx context.Context, userResource *s3v1alpha1.S3User, data map[string][]byte) (*corev1.Secret, error) { - logger := log.FromContext(ctx).WithName("userCtrl") + logger := log.FromContext(ctx) labels := map[string]string{} for k, v := range userResource.ObjectMeta.Labels {