Skip to content
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

Add slog structured logging to main controllers #213

Merged
merged 1 commit into from
Jun 25, 2024

Conversation

vbnrh
Copy link
Member

@vbnrh vbnrh commented Jun 18, 2024

  • Integrated slog logging into the MirrorPeerSecretReconciler, MirrorPeerReconciler, and DRPolicyReconciler controllers.
  • Improved error handling and logging for better observability and debugging.
  • Replaced klog with slog for consistency across the codebase.

Changes include:

  • Added Logger field to controller structs to pass and use slog.Logger.
  • Enhanced logging messages to provide more context, including function names, object names, namespaces, and error details.

Example of the change -

time=2024-06-19T07:57:46.619Z level=INFO msg="No change detected in S3 profile, skipping update" S3ProfileName=s3profile-local-cluster-ocs-storagecluster
time=2024-06-19T07:57:46.619Z level=INFO msg="Reconciliation completed for Secret" RequestNamespace=local-cluster RequestName=10d0befe9022a438cb7216391c32e6eba32f19f
time=2024-06-19T07:59:56.969Z level=INFO msg="Generated reconcile requests from internal secrets" NumberOfRequests=2
time=2024-06-19T07:59:56.969Z level=INFO msg="Starting reconciliation for Secret" RequestNamespace=local-cluster RequestName=10d0befe9022a438cb7216391c32e6eba32f19f
time=2024-06-19T07:59:56.969Z level=INFO msg="Reconciling secret" Request=local-cluster/10d0befe9022a438cb7216391c32e6eba32f19f
time=2024-06-19T07:59:56.969Z level=INFO msg="Validating internal secret" SecretName=10d0befe9022a438cb7216391c32e6eba32f19f Namespace=local-cluster
time=2024-06-19T07:59:56.969Z level=INFO msg="Processing secret based on origin" Origin=S3 SecretName=10d0befe9022a438cb7216391c32e6eba32f19f
time=2024-06-19T07:59:56.969Z level=INFO msg="No updates required for the S3 secret" SecretName=10d0befe9022a438cb7216391c32e6eba32f19f Namespace=openshift-operators
time=2024-06-19T07:59:56.969Z level=INFO msg="Starting to update Ramen Hub Operator config" SecretName=10d0befe9022a438cb7216391c32e6eba32f19f Namespace=local-cluster
time=2024-06-19T07:59:56.969Z level=INFO msg="Generated reconcile requests from internal secrets" NumberOfRequests=2
time=2024-06-19T07:59:56.969Z level=INFO msg="No change detected in S3 profile, skipping update" S3ProfileName=s3profile-local-cluster-ocs-storagecluster
time=2024-06-19T07:59:56.970Z level=INFO msg="Reconciliation completed for Secret" RequestNamespace=local-cluster RequestName=10d0befe9022a438cb7216391c32e6eba32f19f
time=2024-06-19T07:59:56.970Z level=INFO msg="Starting reconciliation for Secret" RequestNamespace=drcluster1-jun-19-24 RequestName=57d587193358f3569c498147479d6fd0418f0a2
time=2024-06-19T07:59:56.970Z level=INFO msg="Reconciling secret" Request=drcluster1-jun-19-24/57d587193358f3569c498147479d6fd0418f0a2
time=2024-06-19T07:59:56.970Z level=INFO msg="Validating internal secret" SecretName=57d587193358f3569c498147479d6fd0418f0a2 Namespace=drcluster1-jun-19-24
time=2024-06-19T07:59:56.970Z level=INFO msg="Processing secret based on origin" Origin=S3 SecretName=57d587193358f3569c498147479d6fd0418f0a2
time=2024-06-19T07:59:56.970Z level=INFO msg="No updates required for the S3 secret" SecretName=57d587193358f3569c498147479d6fd0418f0a2 Namespace=openshift-operators
time=2024-06-19T07:59:56.970Z level=INFO msg="Starting to update Ramen Hub Operator config" SecretName=57d587193358f3569c498147479d6fd0418f0a2 Namespace=drcluster1-jun-19-24
time=2024-06-19T07:59:56.970Z level=INFO msg="No change detected in S3 profile, skipping update" S3ProfileName=s3profile-drcluster1-jun-19-24-ocs-storagecluster
time=2024-06-19T07:59:56.970Z level=INFO msg="Reconciliation completed for Secret" RequestNamespace=drcluster1-jun-19-24 RequestName=57d587193358f3569c498147479d6fd0418f0a2

addons/blue_secret_controller.go Outdated Show resolved Hide resolved
addons/blue_secret_controller.go Outdated Show resolved Hide resolved
addons/blue_secret_controller.go Outdated Show resolved Hide resolved
addons/maintenance_mode_controller.go Outdated Show resolved Hide resolved
addons/maintenance_mode_controller.go Outdated Show resolved Hide resolved
addons/rook_secret_handler.go Outdated Show resolved Hide resolved
controllers/drpolicy_controller.go Outdated Show resolved Hide resolved
controllers/mirrorpeersecret_controller.go Outdated Show resolved Hide resolved
controllers/mirrorpeersecret_controller.go Outdated Show resolved Hide resolved
controllers/mirrorpeersecret_controller.go Outdated Show resolved Hide resolved
Copy link
Contributor

@umangachapagain umangachapagain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's enable sloglint which is available via golangci-lint: https://github.com/go-simpler/sloglint?tab=readme-ov-file#-install

@vbnrh
Copy link
Member Author

vbnrh commented Jun 20, 2024

Let's enable sloglint which is available via golangci-lint: https://github.com/go-simpler/sloglint?tab=readme-ov-file#-install

added slog lint

addons/agent_mirrorpeer_controller.go Outdated Show resolved Hide resolved
addons/agent_mirrorpeer_controller.go Outdated Show resolved Hide resolved
addons/agent_mirrorpeer_controller.go Show resolved Hide resolved
addons/agent_mirrorpeer_controller.go Outdated Show resolved Hide resolved
addons/green_secret_controller.go Outdated Show resolved Hide resolved
controllers/mirrorpeer_controller.go Outdated Show resolved Hide resolved
controllers/mirrorpeer_controller.go Outdated Show resolved Hide resolved
controllers/mirrorpeer_controller.go Outdated Show resolved Hide resolved
controllers/mirrorpeersecret_controller.go Outdated Show resolved Hide resolved
controllers/mirrorpeersecret_controller.go Outdated Show resolved Hide resolved
@vbnrh vbnrh force-pushed the implement-slog branch 3 times, most recently from d1eb224 to 15a271e Compare June 21, 2024 11:30
addons/blue_secret_controller_test.go Show resolved Hide resolved
addons/green_secret_controller_test.go Show resolved Hide resolved
addons/manager.go Outdated Show resolved Hide resolved
controllers/manager.go Outdated Show resolved Hide resolved
controllers/mirrorpeer_controller.go Outdated Show resolved Hide resolved
controllers/mirrorpeer_controller.go Outdated Show resolved Hide resolved
@vbnrh vbnrh force-pushed the implement-slog branch 2 times, most recently from d11da7b to f81bd3f Compare June 24, 2024 08:51
@vbnrh vbnrh requested a review from umangachapagain June 24, 2024 08:52
@vbnrh
Copy link
Member Author

vbnrh commented Jun 24, 2024

/test integration-test

addons/manager.go Outdated Show resolved Hide resolved
controllers/manager.go Outdated Show resolved Hide resolved
@vbnrh vbnrh force-pushed the implement-slog branch 2 times, most recently from 662c1bf to 556f8ff Compare June 25, 2024 07:14
    Integrated slog logging into the MirrorPeerSecretReconciler, MirrorPeerReconciler, and DRPolicyReconciler controllers.
    Improved error handling and logging for better observability and debugging.
    Replaced klog with slog for consistency across the codebase.

Changes include:

    Added Logger field to controller structs to pass and use slog.Logger.
    Enhanced logging messages to provide more context, including function names, object names, namespaces, and error details.

Signed-off-by: vbadrina <[email protected]>
@openshift-ci openshift-ci bot added the lgtm label Jun 25, 2024
Copy link
Contributor

openshift-ci bot commented Jun 25, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: umangachapagain, vbnrh

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [umangachapagain,vbnrh]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-bot openshift-merge-bot bot merged commit b669e51 into red-hat-storage:main Jun 25, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants