Skip to content

NO-JIRA: Refactor connection checker to fix redundant looping - #3099

Open
tpantelis wants to merge 1 commit into
openshift:masterfrom
tpantelis:conn_checker_run
Open

NO-JIRA: Refactor connection checker to fix redundant looping#3099
tpantelis wants to merge 1 commit into
openshift:masterfrom
tpantelis:conn_checker_run

Conversation

@tpantelis

Copy link
Copy Markdown
Contributor

The previous implementation had two layers of periodic execution - Run() used wait.UntilWithContext() to call checkConnection() periodically, but checkConnection() also had its own ticker and infinite loop. The code was simplified to have checkConnection() execute once per call, relying on wait.UntilWithContext() for periodic execution.

Also, the previous Run() method launched wait.UntilWithContext() in a goroutine and then blocked on <-ctx2.Done(). This is redundant because wait.UntilWithContext() already blocks until the context is cancelled. The new implementation calls wait.UntilWithContext() directly, which properly blocks the Run() method until the context is cancelled or Stop() is called.

Unit tests were added to cover the Run() functionality. To facilitate this, the check period was made configurable by introducing a ConnectionCheckerConfig struct to replace the long parameter list in NewConnectionChecker().

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Pipeline controller notification
This repo is configured to use the pipeline controller. Second-stage tests will be triggered either automatically or after lgtm label is added, depending on the repository configuration. The pipeline controller will automatically detect which contexts are required and will utilize /test Prow commands to trigger the second stage.

For optional jobs, comment /test ? to see a list of all defined jobs. To trigger manually all jobs from second stage use /pipeline required command.

This repository is configured in: LGTM mode

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Aug 3, 2026
@openshift-ci-robot

Copy link
Copy Markdown
Contributor

@tpantelis: This pull request explicitly references no jira issue.

Details

In response to this:

The previous implementation had two layers of periodic execution - Run() used wait.UntilWithContext() to call checkConnection() periodically, but checkConnection() also had its own ticker and infinite loop. The code was simplified to have checkConnection() execute once per call, relying on wait.UntilWithContext() for periodic execution.

Also, the previous Run() method launched wait.UntilWithContext() in a goroutine and then blocked on <-ctx2.Done(). This is redundant because wait.UntilWithContext() already blocks until the context is cancelled. The new implementation calls wait.UntilWithContext() directly, which properly blocks the Run() method until the context is cancelled or Stop() is called.

Unit tests were added to cover the Run() functionality. To facilitate this, the check period was made configurable by introducing a ConnectionCheckerConfig struct to replace the long parameter list in NewConnectionChecker().

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 openshift-eng/jira-lifecycle-plugin repository.

@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Team

Run ID: e604a59b-fe4a-42e3-8eda-80891503f531

📥 Commits

Reviewing files that changed from the base of the PR and between 39cfe66 and 912060b.

📒 Files selected for processing (2)
  • pkg/cmd/checkendpoints/controller/connection_checker.go
  • pkg/cmd/checkendpoints/controller/connection_checker_test.go

Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review.


Summary by CodeRabbit

  • New Features

    • Connection checks now support configurable check intervals and timeouts, with sensible defaults when values aren’t provided.
    • Checkers now shut down cleanly when their operating context is cancelled.
  • Bug Fixes

    • Improved connection-check consistency by running checks synchronously at each configured interval.
  • Tests

    • Added coverage for connection-check execution, shutdown, cancellation, and connection status updates.

Walkthrough

The connection checker now accepts configuration, applies configurable timing, performs synchronous checks, and stops through context cancellation. Controller wiring uses the new configuration. Tests cover repeated checks and shutdown paths.

Changes

Connection checker lifecycle

Layer / File(s) Summary
Configure and execute checks
pkg/cmd/checkendpoints/controller/connection_checker.go
ConnectionCheckerConfig defines checker dependencies and timing. The checker applies default timing when values are unset, performs one check per interval, and exits through a cancellable context.
Wire and validate lifecycle
pkg/cmd/checkendpoints/controller/pod_network_connectivity_check_controller.go, pkg/cmd/checkendpoints/controller/connection_checker_test.go
Sync constructs the checker with ConnectionCheckerConfig. Tests verify repeated checks and shutdown through Stop or context cancellation.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to 91206

The change simplifies connection-check scheduling and makes its check period configurable while adding coverage for Run behavior. No actionable merge-blocking risk remains beyond normal checks and review.

Suggested reviewers: jcaamano, kyrtapz

Sequence Diagram(s)

sequenceDiagram
  participant PodNetworkConnectivityCheckController
  participant ConnectionChecker
  participant EndpointCheck
  PodNetworkConnectivityCheckController->>ConnectionChecker: construct with ConnectionCheckerConfig
  ConnectionChecker->>ConnectionChecker: apply check period and timeout
  ConnectionChecker->>EndpointCheck: execute one check per interval
  EndpointCheck-->>ConnectionChecker: return check result
  PodNetworkConnectivityCheckController->>ConnectionChecker: stop or cancel context
  ConnectionChecker-->>PodNetworkConnectivityCheckController: exit Run
Loading

Caution

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

  • Ignore

❌ Failed checks (4 errors, 1 warning)

Check name Status Explanation Resolution
Pr Quality ❌ Error The change is non-trivial and behavioral, although its scope is small: 3 files and 184 non-vendor changed lines, well below 7000. The description explains the redundant loops and the refactor, and it … Update the PR description with explicit Why, What, and Testing/How to verify it sections. In Testing, name the automated CNO CI jobs or lanes and the platforms they cover. Describe the user-facing impact and upgrade/rollback considerations …
Commit Message Quality ❌ Error The PR has one self-contained, non-merge commit. Its body explains the reason for the refactor, and the subject is descriptive. However, the commit changes only pkg/cmd/checkendpoints/controller, so… Amend the commit subject to include the component prefix, for example: checkendpoints: Refactor connection checker to remove redundant looping. Keep the existing explanatory body.
E2e Tests For Feature Changes ❌ Error The PR changes non-test Go source under pkg/ and fixes the connection-check scheduling bug. The diff changes checkConnection from an internal ticker loop to one check per wait.UntilWithContext c… Add or modify appropriate files under test/e2e/, and add a Testing or How to verify it section that names the running CI lanes or jobs, covered platforms, and test results. If E2E tests are not feasible, document the justification in …
Ai-Generated Code Smell ❌ Error The PR adds two obvious comment-slop comments in connection_checker_test.go: // Call Stop directly above checker.Stop(stopCtx), and // Cancel the context directly above cancel(). Each commen… Remove the // Call Stop and // Cancel the context comments, or replace them with comments that explain test intent rather than restating the operation.
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (10 passed)
Check name Status Explanation
Title check ✅ Passed The title describes the connection checker refactor, uses the imperative mood, and is 61 characters long. It does not use an affected-component prefix, but the requirement applies only when the title …
Description check ✅ Passed The description directly explains the removal of redundant periodic loops, the ConnectionCheckerConfig change, and the added unit tests.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Unit Tests For Go Changes ✅ Passed PASS: The pull request modifies production Go files under pkg/ and also modifies pkg/cmd/checkendpoints/controller/connection_checker_test.go. No bindata/ template changes are present. This satisfies …
Rbac Least Privilege ✅ Passed No RBAC rules changed. The commit changes only three Go files under pkg/cmd/checkendpoints/controller. Git diff shows no added, modified, or deleted YAML files under bindata/ or manifests/.
Docs For Feature And Behavior Changes ✅ Passed PASS. The diff contains only internal check-endpoints implementation and test files; no user-facing CRD, ConfigMap, environment variable, CLI flag, operand, or architecture change. The change fixes …
Stale Project Docs And Config ✅ Passed No project documentation or configuration became stale. The PR changes only Go source and test files. The applicable files have no diff from the parent, and searches found no references to `NewConnect…
Go And Test Code Quality ✅ Passed PASS. The committed diff adds no prohibited logging calls, bare duration values, nested error shadowing, IPv4-only handling, or unprotected new map/slice access. The added tests use Gomega polling and…
Stable And Deterministic Test Names ✅ Passed PASS — The pull request adds standard Go t.Run subtests, not Ginkgo It, Describe, Context, or When titles. Both new titles are static: should stop when Stop is called and `should stop when…
Full details: Title check

Explanation

The title describes the connection checker refactor, uses the imperative mood, and is 61 characters long. It does not use an affected-component prefix, but the requirement applies only when the title is scoped.

Full details: Pr Quality

Explanation

The change is non-trivial and behavioral, although its scope is small: 3 files and 184 non-vendor changed lines, well below 7000. The description explains the redundant loops and the refactor, and it mentions unit tests. However, it does not identify automated CNO CI lanes/jobs or platforms. It also omits user-facing impact and upgrade/rollback considerations for the changed checker behavior and public constructor. The commit title says it fixes redundant looping, but neither the title nor body contains a bug or issue link.

Resolution

Update the PR description with explicit Why, What, and Testing/How to verify it sections. In Testing, name the automated CNO CI jobs or lanes and the platforms they cover. Describe the user-facing impact and upgrade/rollback considerations for this behavioral and public API change. Add a valid bug or issue link in the title or description.

Full details: Commit Message Quality

Explanation

The PR has one self-contained, non-merge commit. Its body explains the reason for the refactor, and the subject is descriptive. However, the commit changes only pkg/cmd/checkendpoints/controller, so it is component-scoped, but the subject lacks an affected-component prefix. This violates criterion 3.

Full details: Unit Tests For Go Changes

Explanation

PASS: The pull request modifies production Go files under pkg/ and also modifies pkg/cmd/checkendpoints/controller/connection_checker_test.go. No bindata/ template changes are present. This satisfies the custom check requirement for accompanying test-file changes.

Full details: E2e Tests For Feature Changes

Explanation

The PR changes non-test Go source under pkg/ and fixes the connection-check scheduling bug. The diff changes checkConnection from an internal ticker loop to one check per wait.UntilWithContext call, and makes the first check occur immediately instead of after the prior ticker delay. This changes observable endpoint-check and status-update behavior. HEAD^..HEAD contains only three modified files under pkg/cmd/checkendpoints/controller; no files under test/e2e/ were added or modified. The contributor description has no Testing or How to verify it section and does not state CI lanes, platform coverage, or test results.

Resolution

Add or modify appropriate files under test/e2e/, and add a Testing or How to verify it section that names the running CI lanes or jobs, covered platforms, and test results. If E2E tests are not feasible, document the justification in that section. After all other pre-merge checks pass, use @coderabbitai ignore pre-merge checks to override this check.

Full details: Docs For Feature And Behavior Changes

Explanation

PASS. The diff contains only internal check-endpoints implementation and test files; no user-facing CRD, ConfigMap, environment variable, CLI flag, operand, or architecture change. The change fixes redundant periodic execution and cancellation control flow while preserving the existing one-minute check interval in production wiring. No docs/ file is required for this internal bug fix/refactor under the custom check.

Full details: Stale Project Docs And Config

Explanation

No project documentation or configuration became stale. The PR changes only Go source and test files. The applicable files have no diff from the parent, and searches found no references to NewConnectionChecker, ConnectionCheckerConfig, or the removed ticker implementation. docs/operands.md only states that the source pod regularly checks targets, which remains accurate. docs/architecture.md contains only a pre-existing TODO for this controller, and .coderabbit.yaml has no affected path or API reference.

Full details: Go And Test Code Quality

Explanation

PASS. The committed diff adds no prohibited logging calls, bare duration values, nested error shadowing, IPv4-only handling, or unprotected new map/slice access. The added tests use Gomega polling and do not use bare t.Fatal/t.Fatalf, time.Sleep, or os.Setenv. The existing return err statements are unchanged, and the new callback contains no bare error return.

Full details: Ai-Generated Code Smell

Explanation

The PR adds two obvious comment-slop comments in connection_checker_test.go: // Call Stop directly above checker.Stop(stopCtx), and // Cancel the context directly above cancel(). Each comment only restates the following statement. The new test is otherwise related and proportional, and no AI-tool references were found.

Full details: Stable And Deterministic Test Names

Explanation

PASS — The pull request adds standard Go t.Run subtests, not Ginkgo It, Describe, Context, or When titles. Both new titles are static: should stop when Stop is called and should stop when the context is cancelled. They contain no pod names, timestamps, UUIDs, node or namespace names, IP addresses, or other run-dependent values.

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@openshift-ci
openshift-ci Bot requested review from jcaamano and kyrtapz August 3, 2026 18:20
@openshift-ci

openshift-ci Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

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

Details 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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pkg/cmd/checkendpoints/controller/connection_checker.go`:
- Around line 105-116: Update the internal goroutine in connectionChecker.Run to
select on both c.stop and ctx2.Done(). Ensure it exits when either Stop() is
called or the parent context is cancelled, while preserving the existing
cancel() behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 5491a332-19f7-434f-b151-d9ec567355fb

📥 Commits

Reviewing files that changed from the base of the PR and between 1dcce83 and 70f509e.

📒 Files selected for processing (3)
  • pkg/cmd/checkendpoints/controller/connection_checker.go
  • pkg/cmd/checkendpoints/controller/connection_checker_test.go
  • pkg/cmd/checkendpoints/controller/pod_network_connectivity_check_controller.go

Comment thread pkg/cmd/checkendpoints/controller/connection_checker.go
The previous implementation had two layers of periodic execution -
Run() used wait.UntilWithContext() to call checkConnection()
periodically, but checkConnection() also had its own ticker and
infinite loop. The code was simplified to have checkConnection()
execute once per call, relying on wait.UntilWithContext() for periodic
execution.

Also, the previous Run() method launched wait.UntilWithContext() in a
goroutine and then blocked on <-ctx2.Done(). This is redundant
because wait.UntilWithContext() already blocks until the context is
cancelled. The new implementation calls wait.UntilWithContext()
directly, which properly blocks the Run() method until the context is
cancelled or Stop() is called.

Unit tests were added to cover the Run() functionality. To facilitate
this, the check period was made configurable by introducing a
ConnectionCheckerConfig struct to replace the long parameter list in
NewConnectionChecker().

Signed-off-by: Tom Pantelis <tompantelis@gmail.com>
@openshift-ci

openshift-ci Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

@tpantelis: 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/5.1-upgrade-from-stable-5.0-e2e-gcp-ovn-upgrade 912060b link false /test 5.1-upgrade-from-stable-5.0-e2e-gcp-ovn-upgrade

Full PR test history. Your PR dashboard.

Details

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants