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

OCPBUGS-23161: Set logging for controller-runtime #2129

Merged
merged 1 commit into from Dec 7, 2023

Conversation

arghosh93
Copy link
Contributor

Call SetLogger before adding controller-runtime client to prevent controller-runtime complaining about it after 30 seconds of binaries lifetime.
https://github.com/kubernetes-sigs/controller-runtime/blob/main/pkg/log/log.go#L54

JIRA: https://issues.redhat.com/browse/OCPBUGS-23161

@openshift-ci openshift-ci bot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Nov 23, 2023
Copy link
Contributor

openshift-ci bot commented Nov 23, 2023

Hi @arghosh93. Thanks for your PR.

I'm waiting for a openshift member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@kyrtapz
Copy link
Contributor

kyrtapz commented Nov 29, 2023

/ok-to-test

Copy link
Contributor

openshift-ci bot commented Nov 29, 2023

@kyrtapz: The label(s) /label ok-to-test cannot be applied. These labels are supported: acknowledge-critical-fixes-only, platform/aws, platform/azure, platform/baremetal, platform/google, platform/libvirt, platform/openstack, ga, tide/merge-method-merge, tide/merge-method-rebase, tide/merge-method-squash, px-approved, docs-approved, qe-approved, downstream-change-needed, rebase/manual, approved, backport-risk-assessed, bugzilla/valid-bug, cherry-pick-approved, jira/valid-bug, staff-eng-approved. Is this label configured under labels -> additional_labels or labels -> restricted_labels in plugin.yaml?

In response to this:

/label ok-to-test

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-ci openshift-ci bot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Nov 29, 2023
Call SetLogger before adding controller-runtime client to prevent controller-runtime
complaining about it after 30 seconds of binaries lifetime
https://github.com/kubernetes-sigs/controller-runtime/blob/main/pkg/log/log.go#L54

JIRA: https://issues.redhat.com/browse/OCPBUGS-23161

Signed-off-by: Arnab Ghosh <arnabghosh89@gmail.com>
Copy link
Contributor

@tssurya tssurya left a comment

Choose a reason for hiding this comment

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

/lgtm (the fix makes sense based on the stack trace of the panic I did)
thanks @arghosh93 !!
/assign @kyrtapz for a second opinion

Copy link
Contributor

openshift-ci bot commented Dec 4, 2023

@tssurya: GitHub didn't allow me to assign the following users: second, opinion, for, a.

Note that only openshift members with read permissions, repo collaborators and people who have commented on this issue/PR can be assigned. Additionally, issues/PRs can only have 10 assignees at the same time.
For more information please see the contributor guide

In response to this:

/lgtm
thanks @arghosh93 !!
/assign @kyrtapz for a second opinion

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@tssurya
Copy link
Contributor

tssurya commented Dec 4, 2023

/retest

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Dec 4, 2023
@arghosh93 arghosh93 changed the title Set logging for controller-runtime OCPBUGS-23161: Set logging for controller-runtime Dec 4, 2023
@openshift-ci-robot openshift-ci-robot added jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Dec 4, 2023
@openshift-ci-robot
Copy link
Contributor

@arghosh93: This pull request references Jira Issue OCPBUGS-23161, which is invalid:

  • expected the bug to target the "4.15.0" version, but no target version was set

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

The bug has been updated to refer to the pull request using the external bug tracker.

In response to this:

Call SetLogger before adding controller-runtime client to prevent controller-runtime complaining about it after 30 seconds of binaries lifetime.
https://github.com/kubernetes-sigs/controller-runtime/blob/main/pkg/log/log.go#L54

JIRA: https://issues.redhat.com/browse/OCPBUGS-23161

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@tssurya
Copy link
Contributor

tssurya commented Dec 4, 2023

/jira refresh

@openshift-ci-robot openshift-ci-robot added jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. and removed jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Dec 4, 2023
@openshift-ci-robot
Copy link
Contributor

@tssurya: This pull request references Jira Issue OCPBUGS-23161, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (4.15.0) matches configured target version for branch (4.15.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, POST)

Requesting review from QA contact:
/cc @anuragthehatter

In response to this:

/jira refresh

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

// Call SetLogger before adding controller-runtime client to prevent controller-runtime
// complaining about it after 30 seconds of binaries lifetime
// https://github.com/kubernetes-sigs/controller-runtime/blob/main/pkg/log/log.go#L54
ctlog.SetLogger(logger)
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we should be setting the root logger in a function.
This should be done once, somewhere in main.

Copy link
Contributor

Choose a reason for hiding this comment

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

hmm isn't RunOperator only called once from main?

Copy link
Contributor

Choose a reason for hiding this comment

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

do you think

func main() {
	pflag.CommandLine.SetNormalizeFunc(utilflag.WordSepNormalizeFunc)
	pflag.CommandLine.AddGoFlagSet(flag.CommandLine)

	logs.InitLogs()
	defer logs.FlushLogs()

	command := newNetworkOperatorCommand()

	if err := command.Execute(); err != nil {
		fmt.Fprintf(os.Stderr, "%v\n", err)
		os.Exit(1)
	}
}

is a better spot?

Copy link
Contributor

@kyrtapz kyrtapz Dec 5, 2023

Choose a reason for hiding this comment

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

I confused the functions, apologies.
In that case I am fine to keep this in RunOperator as this is the main entry-point of CNO anyway.
Although somewhere around the following would be perfect:

func main() {
	pflag.CommandLine.SetNormalizeFunc(utilflag.WordSepNormalizeFunc)
	pflag.CommandLine.AddGoFlagSet(flag.CommandLine)

	logs.InitLogs()
	defer logs.FlushLogs()
        <HERE>
}

Copy link
Contributor Author

@arghosh93 arghosh93 Dec 5, 2023

Choose a reason for hiding this comment

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

Yes, RunOperator only gets called once from main. I was little bit worried about hard coded condition of initializing SetLogger within 30 second of binary's lifetime and thats why I have put it in RunOperator instead of main.

https://github.com/kubernetes-sigs/controller-runtime/blob/main/pkg/log/log.go#L54

I have also tested by initializing the logger just before command.Execute() in main and that would also resolve the panic.

@tssurya
Copy link
Contributor

tssurya commented Dec 5, 2023

/retest

@kyrtapz
Copy link
Contributor

kyrtapz commented Dec 5, 2023

/lgtm

Copy link
Contributor

@trozet trozet left a comment

Choose a reason for hiding this comment

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

/approve

Copy link
Contributor

openshift-ci bot commented Dec 6, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: arghosh93, kyrtapz, trozet, tssurya

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:

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

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 6, 2023
@openshift-ci-robot
Copy link
Contributor

/retest-required

Remaining retests: 0 against base HEAD 353b474 and 2 for PR HEAD d7e0f33 in total

Copy link
Contributor

openshift-ci bot commented Dec 7, 2023

@arghosh93: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-vsphere-ovn-dualstack-primaryv6 d7e0f33 link false /test e2e-vsphere-ovn-dualstack-primaryv6
ci/prow/e2e-azure-ovn-dualstack d7e0f33 link false /test e2e-azure-ovn-dualstack
ci/prow/e2e-aws-hypershift-ovn-kubevirt d7e0f33 link false /test e2e-aws-hypershift-ovn-kubevirt
ci/prow/e2e-vsphere-ovn-dualstack d7e0f33 link false /test e2e-vsphere-ovn-dualstack

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@openshift-ci-robot
Copy link
Contributor

/retest-required

Remaining retests: 0 against base HEAD aa91af2 and 1 for PR HEAD d7e0f33 in total

@openshift-merge-bot openshift-merge-bot bot merged commit c212e31 into openshift:master Dec 7, 2023
36 of 40 checks passed
@openshift-ci-robot
Copy link
Contributor

@arghosh93: Jira Issue OCPBUGS-23161: All pull requests linked via external trackers have merged:

Jira Issue OCPBUGS-23161 has been moved to the MODIFIED state.

In response to this:

Call SetLogger before adding controller-runtime client to prevent controller-runtime complaining about it after 30 seconds of binaries lifetime.
https://github.com/kubernetes-sigs/controller-runtime/blob/main/pkg/log/log.go#L54

JIRA: https://issues.redhat.com/browse/OCPBUGS-23161

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-bot
Copy link
Contributor

[ART PR BUILD NOTIFIER]

This PR has been included in build cluster-network-operator-container-v4.16.0-202312070751.p0.gc212e31.assembly.stream for distgit cluster-network-operator.
All builds following this will include this PR.

@openshift-merge-robot
Copy link
Contributor

Fix included in accepted release 4.15.0-0.nightly-2023-12-07-225558

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants