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-14396: Set controller-runtime logger to a null logger for E2E #946

Merged
merged 1 commit into from
Jun 28, 2023

Conversation

gcs278
Copy link
Contributor

@gcs278 gcs278 commented Jun 7, 2023

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 and client.go was not initializing the logger.

test/e2e/operator_test.go: Initialize controller-runtime logger in init() function

@openshift-ci-robot openshift-ci-robot added jira/severity-low Referenced Jira bug's severity is low for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. labels Jun 7, 2023
@openshift-ci-robot
Copy link
Contributor

@gcs278: This pull request references Jira Issue OCPBUGS-14396, which is valid. The bug has been moved to the POST state.

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

Requesting review from QA contact:
/cc @lihongan

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

In response to this:

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 and client.go was not initializing the logger.

pkg/operator/client/client.go: Initialize controller-runtime logger

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.

@alebedev87
Copy link
Contributor

/lgtm

To test the approver's lgtm.

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jun 12, 2023
@alebedev87
Copy link
Contributor

/lgtm cancel

@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Jun 12, 2023
@candita
Copy link
Contributor

candita commented Jun 14, 2023

/assign @alebedev87

@gcs278
Copy link
Contributor Author

gcs278 commented Jun 21, 2023

failures are unrelated or known failures (such as TestAWSELBConnectionIdleTimeout that has been recently fixed)
/retest

@gcs278
Copy link
Contributor Author

gcs278 commented Jun 21, 2023

E2E test logs don't print backtrace error and ingress-operator logs seem unaffected, as they should be.

// This is required because controller-runtime expects its consumers to
// set a logger through log.SetLogger within 30 seconds of the program's
// initalization.
ctrlruntimelog.SetLogger(logr.New(ctrlruntimelog.NullLogSink{}))
Copy link
Contributor

Choose a reason for hiding this comment

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

pkg/operator/client package is used in the operator and e2e test binaries. The e2e binary was missing the logger so this change makes the required migration for it. However the operator binary already sets the controller runtime logger here so this change doesn't cause any conflict (because client's init runs first) but is redundant.
The alternative would be to add SetLogger somewhere in test/e2e.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't see where pkg/operator/client is used by the operator, hence it seemed safe putting here. Am I misunderstanding the usage of pkg/operator/client?

Copy link
Contributor

@alebedev87 alebedev87 Jun 21, 2023

Choose a reason for hiding this comment

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

pkg/operator/client is imported in pkg/operator/operator.go, that is, its init function is invoked.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh whoops, you are right. I didn't give Goland enough time to finish loading all of the references...

Yea, I see, it's not-problematic, but redundant. I'm going to find a different place for it in test/e2e.

@gcs278
Copy link
Contributor Author

gcs278 commented Jun 21, 2023

/hold
updated to add the null logger in all_test.go, I just want to make sure it works as expected.

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 21, 2023
// This is required because controller-runtime expects its consumers to
// set a logger through log.SetLogger within 30 seconds of the program's
// initalization.
ctrlruntimelog.SetLogger(logr.New(ctrlruntimelog.NullLogSink{}))
Copy link
Contributor

Choose a reason for hiding this comment

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

I think that the better place for this is operator_test.go, in a init() function. Because here the logger will be set at the test runtime. Some setup may take longer (TestMain) or some other test can be run before TestAll (I believe it's alphabetically ordered but not guaranteed).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea that's fair, I didn't realize TestAll was really just a test itself, it wasn't as special as I thought. I also goofed up the imports.

Good suggestion, seems reasonable. I put it in an init() function in operator_test.go.

@alebedev87
Copy link
Contributor

/lgtm

Due to controller-runtime v0.15.0 bump, you must set a logger for controller-runtime
and E2E tests were not initializing the logger.

`test/e2e/operator_test.go`: Initialize controller-runtime logger
in init() function
@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jun 28, 2023
@openshift-ci-robot
Copy link
Contributor

@gcs278: This pull request references Jira Issue OCPBUGS-14396, which is valid.

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

Requesting review from QA contact:
/cc @ShudiLi

In response to this:

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 and client.go was not initializing the logger.

test/e2e/operator_test.go: Initialize controller-runtime logger in init() function

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 requested a review from ShudiLi June 28, 2023 14:12
@alebedev87
Copy link
Contributor

LGTM, just the title and the description need an update.

@gcs278 gcs278 changed the title OCPBUGS-14396: Set controller-runtime logger to a null logger in client.go OCPBUGS-14396: Set controller-runtime logger to a null logger for E2E Jun 28, 2023
@gcs278
Copy link
Contributor Author

gcs278 commented Jun 28, 2023

LGTM, just the title and the description need an update.

Done.

@alebedev87
Copy link
Contributor

/approve

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jun 28, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alebedev87

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 Jun 28, 2023
@gcs278
Copy link
Contributor Author

gcs278 commented Jun 28, 2023

@gcs278
Copy link
Contributor Author

gcs278 commented Jun 28, 2023

/unhold

@openshift-ci openshift-ci bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 28, 2023
@openshift-merge-robot openshift-merge-robot merged commit d0be04b into openshift:master Jun 28, 2023
@openshift-ci-robot
Copy link
Contributor

@gcs278: Jira Issue OCPBUGS-14396: All pull requests linked via external trackers have merged:

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

In response to this:

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 and client.go was not initializing the logger.

test/e2e/operator_test.go: Initialize controller-runtime logger in init() function

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
Copy link
Contributor

openshift-ci bot commented Jun 28, 2023

@gcs278: The following test 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-gcp-ovn 8a61255 link false /test e2e-gcp-ovn

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.

frobware added a commit to openshift/cluster-dns-operator that referenced this pull request Sep 21, 2023
Initialise controller-runtime logger in E2E tests for v0.15.0
compliance.

This is the same fix as openshift/cluster-ingress-operator#946.
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/severity-low Referenced Jira bug's severity is low for the branch this PR is targeting. 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants