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

enable logging from operator-lib #608

Merged
merged 3 commits into from
Mar 19, 2024
Merged

Conversation

tvoran
Copy link
Member

@tvoran tvoran commented Mar 16, 2024

Uses a logging type from consul to wrap an hclog logger in logr's LogSink type. This also turned up a missing ClusterRole permission for getting Nodes from k8s.

Fixes #605

ClusterRole permissions also added to the chart in hashicorp/vault-helm#1005

Related to hashicorp/vault-helm#980 and hashicorp/vault-helm#725

Log samples:

[ERROR] handler.operator-lib.leader: Failed to get Node: error="nodes \"kind-control-plane\" is forbidden: User \"system:serviceaccount:vault:vault-agent-injector\" cannot get resource \"nodes\" in API group \"\" at the cluster scope" Node.Name=kind-control-plane
[DEBUG] handler.operator-lib.leader: Not the leader. Waiting.

Uses a logging type from consul to convert from hclog to logr's
LogSink type. This also turned up a missing CluterRole permission for
getting Nodes from k8s.
@tvoran tvoran marked this pull request as ready for review March 16, 2024 06:30
@tvoran tvoran requested a review from a team March 18, 2024 18:40
Copy link
Contributor

@tomhjp tomhjp left a comment

Choose a reason for hiding this comment

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

Nice fix! What does the library actually need the nodes information for? i.e. this is just informational, the leader elections aren't broken without it right?

Copy link
Contributor

@benashz benashz left a comment

Choose a reason for hiding this comment

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

LGTM!

@tvoran
Copy link
Member Author

tvoran commented Mar 18, 2024

What does the library actually need the nodes information for? i.e. this is just informational, the leader elections aren't broken without it right?

@tomhjp It's used to check for the case where the leader is stuck on a notReady k8s Node as I understand it: https://github.com/operator-framework/operator-lib/blob/b51f67c33ce55e3a148187047f7de70dd4f87d9d/leader/leader.go#L189-L196

So in general it was working for us, but would have trouble with that specific case.

@tvoran tvoran added this to the 1.5.0 milestone Mar 18, 2024
@tvoran tvoran merged commit 43b6866 into main Mar 19, 2024
7 checks passed
@tvoran tvoran deleted the VAULT-24506/add-hclog-to-logr branch March 19, 2024 04:54
@tomhjp
Copy link
Contributor

tomhjp commented Mar 19, 2024

Awesome, thanks for the context - that's a great bit of extra resilience to have 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[controller-runtime] log.SetLogger(...) was never called; logs will not be displayed.
3 participants