cert-manager-operator icon indicating copy to clipboard operation
cert-manager-operator copied to clipboard

context consistency: ensure all context are TODO()

Open sebrandon1 opened this issue 9 months ago • 10 comments

There were 14 instances of context.Background and 20 instances of context.TODO(). Since there were more TODO() references, I'm ensuring all of the references to context are the same.

Similar to:

  • https://github.com/openshift-kni/eco-goinfra/pull/680
  • https://github.com/openshift-kni/eco-goinfra/pull/329
  • https://github.com/redhat-best-practices-for-k8s/certsuite/pull/1216
  • https://github.com/redhat-best-practices-for-k8s/certsuite/pull/681

sebrandon1 avatar Feb 06 '25 18:02 sebrandon1

Hi @sebrandon1. 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-sigs/prow repository.

openshift-ci[bot] avatar Feb 06 '25 18:02 openshift-ci[bot]

/ok-to-test

swghosh avatar Feb 14 '25 20:02 swghosh

/ok-to-test /test all

swghosh avatar Mar 12 '25 17:03 swghosh

/retest

sebrandon1 avatar Apr 24 '25 19:04 sebrandon1

/retest

sebrandon1 avatar Apr 25 '25 18:04 sebrandon1

/test all

swghosh avatar Apr 30 '25 07:04 swghosh

Hi @sebrandon1, you may need to rebase onto the latesr commit. There have been some changes in test/e2e folder since you opened this PR

lunarwhite avatar Apr 30 '25 08:04 lunarwhite

Walkthrough

Replaces many uses of context.Background() with context.TODO() across controllers, tests, and utilities; updates an example comment; and adds a new end-to-end test file introducing multiple cert-related E2E tests and helpers. No exported/public signatures altered.

Changes

Cohort / File(s) Summary
Controller & tests: context switch
pkg/controller/istiocsr/controller.go, pkg/controller/istiocsr/controller_test.go, pkg/controller/istiocsr/test_utils.go, pkg/controller/deployment/deployment_helper_test.go
Replaced context.Background() with context.TODO() in reconciler init, Reconcile calls, test constructors, and related tests.
E2E tests: context adjustments
test/e2e/certificates_test.go, test/e2e/overrides_test.go
Switched test setup/context arguments from context.Background() to context.TODO(); behavior unchanged.
Test utilities: namespace lifecycle
test/library/utils.go
Updated Namespace create/delete and polling calls to use context.TODO() instead of context.Background().
Operator informers: docs example
pkg/operator/informers/externalversions/factory.go
Comment/example updated to show context.TODO() instead of context.Background(); no code changes.
New E2E suite: cert-manager deployment & flows
test/e2e/cert_manager_deployment_test.go
Added new end-to-end test file with constants (PollInterval, TestTimeout) and tests: TestSelfSignedCerts, TestACMECertsIngress, TestCertRenew, TestContainerOverrides, plus helpers for deployment overrides, polling, and TLS/expiry verification.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 7.14% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The pull request title "context consistency: ensure all context are TODO()" directly and specifically describes the main change across the changeset. The raw summary shows that the primary objective is standardizing context usage from context.Background() to context.TODO() across multiple files in the codebase. The title is concise, clear, and specific enough that a teammate scanning the history would immediately understand the primary change being made. Although the changeset includes a new e2e test file, the dominant change throughout the PR is the context standardization.
Description Check ✅ Passed The pull request description is clearly related to the changeset. It explains the concrete rationale for the changes—14 instances of context.Background() versus 20 instances of context.TODO(), with the author choosing to standardize on the more frequently used TODO()—and provides references to similar prior work in related repositories. The description conveys meaningful information about why the changes were made and demonstrates precedent for this type of consistency effort. It is not vague, generic, or off-topic.
✨ Finishing touches
  • [ ] 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • [ ] Create PR with unit tests
  • [ ] Post copyable unit tests in a comment

[!WARNING] There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.5.0)

Error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/docs/product/migration-guide for migration instructions The command is terminated due to an error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/docs/product/migration-guide for migration instructions


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar Sep 15 '25 16:09 coderabbitai[bot]

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: sebrandon1 Once this PR has been reviewed and has the lgtm label, please assign mytreya-rh for approval. For more information see the Code Review Process.

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

openshift-ci[bot] avatar Oct 24 '25 17:10 openshift-ci[bot]

@sebrandon1: 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/verify e8c5effafb864fd55e7021cdc04c59d3e79fe0c4 link true /test verify
ci/prow/e2e-operator-tech-preview e8c5effafb864fd55e7021cdc04c59d3e79fe0c4 link false /test e2e-operator-tech-preview
ci/prow/e2e-operator e8c5effafb864fd55e7021cdc04c59d3e79fe0c4 link true /test e2e-operator

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-sigs/prow repository. I understand the commands that are listed here.

openshift-ci[bot] avatar Oct 24 '25 18:10 openshift-ci[bot]