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

fix panic when using controller-runtime: log.SetLogger(...) was never called #5503

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Shelley-BaoYue
Copy link
Collaborator

@Shelley-BaoYue Shelley-BaoYue commented Apr 1, 2024

What type of PR is this?

/kind bug

What this PR does / why we need it:

When enable the requireAuthorization the feature, cloudcore will break with panic:

image

Due to controller-runtime v0.15.0 bump and changes made in kubernetes-sigs/controller-runtime#2317, you must set a logger for controller-runtime. In our situation for cloudcore, we can set controller-runtime's logger to Null.

@kubeedge-bot kubeedge-bot added the kind/bug Categorizes issue or PR as related to a bug. label Apr 1, 2024
@kubeedge-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
To complete the pull request process, please assign shelley-baoyue after the PR has been reviewed.
You can assign the PR to them by writing /assign @shelley-baoyue in a comment when ready.

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

Needs approval from an approver in each of these files:

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

@kubeedge-bot kubeedge-bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Apr 1, 2024
Signed-off-by: Shelley-BaoYue <baoyue2@huawei.com>
@@ -54,6 +56,7 @@ func NewAccessRoleControllerManager(ctx context.Context, kubeCfg *rest.Config) (
}

func setupControllers(ctx context.Context, mgr manager.Manager) error {
ctrlruntimelog.SetLogger(logr.New(ctrlruntimelog.NullLogSink{}))
Copy link
Collaborator

Choose a reason for hiding this comment

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

  1. Would it be better to put it in New() func?
  2. We can use the klog instance to set the logger of the runtime-controller.
  3. Do other runtime-controllers also need to set logger?
func NewAccessRoleControllerManager() {
    ...
    ctrlruntimelog.SetLogger(klog.Background())
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants