Skip to content

NO-ISSUE: modernise the codebase using go fix - #3113

Open
skitt wants to merge 8 commits into
openshift:masterfrom
skitt:go-1.26-fix
Open

NO-ISSUE: modernise the codebase using go fix#3113
skitt wants to merge 8 commits into
openshift:masterfrom
skitt:go-1.26-fix

Conversation

@skitt

@skitt skitt commented Aug 7, 2026

Copy link
Copy Markdown
Member

Why

Go now provides a built-in fix-up tool, go fix. It is intended to apply safe fixes which use newer code patterns to improve maintenability and/or performance.

What

This is a one-time go fix run over the project, simplifying more regular maintenance using go fix in future.

See individual commits for details.

Verification

This is a refactor with no behaviour changes, so existing tests don’t need adjusting and should be sufficient to verify correctness.

@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 7, 2026
@openshift-ci-robot

Copy link
Copy Markdown
Contributor

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

Details

In response to this:

This is a one-time go fix run over the project, simplifying more regular maintenance using go fix in future.

See individual commits for details.

This is a refactor with no behaviour changes, so existing tests don’t need adjusting and should be sufficient to verify correctness.

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 7, 2026

Copy link
Copy Markdown

Summary by CodeRabbit

  • Refactor
    • Modernized internal implementation patterns and standard-library usage without changing runtime behavior.
    • Simplified iteration, collection handling, pointer creation, and data conversion throughout the codebase.
    • Updated type usage to current Go conventions.
    • Replaced legacy platform build constraints with modern syntax.
  • Tests
    • Refreshed test utilities and fixtures to match the updated Go conventions while preserving existing coverage and assertions.

Walkthrough

The change modernizes Go syntax across controller, network, HyperShift, rendering, and test code. It replaces interface{} with any, adopts standard-library helpers, updates loops and pointer construction, and converts legacy build constraints.

Changes

Go language modernization

Layer / File(s) Summary
Shared type and API modernization
pkg/cmd/checkendpoints/..., pkg/controller/..., pkg/render/..., pkg/util/k8s/...
Public and internal types use any instead of interface{}.
Network and HyperShift runtime updates
pkg/hypershift/..., pkg/network/*.go, pkg/util/proxyconfig/...
Parsing and network logic use newer Go helpers, and build constraints use //go:build.
Standard-library and loop replacements
cmd/cluster-network-operator/mtu_probe.go, pkg/apply/apply.go, pkg/controller/...
Retry loops, annotation copying, pointer setup, formatting, and iteration use newer Go constructs.
Test fixture and helper updates
pkg/*/*_test.go
Test fixtures and helpers use any, built-in new, range loops, and slice helpers.

Estimated code review effort: 2 (Simple) | ~15 minutes


Caution

Pre-merge checks failed

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

  • Ignore

❌ Failed checks (2 errors, 1 warning)

Check name Status Explanation Resolution
Pr Quality ❌ Error The description is an unsectioned three-paragraph summary and does not provide the required explicit Why and What sections; the 305-line scope is otherwise below the size limit. Rewrite the PR description with explicit Why and What sections, and include automated CI verification details if the non-functional-change exception does not apply.
Commit Message Quality ❌ Error Six of eight PR commits have no explanatory body beyond the Signed-off-by trailer; only the SplitSeq and new commits explain rationale. Add a short rationale body to every commit, or squash the series into logical commits with subjects and bodies that explain the maintenance goal.
Docstring Coverage ⚠️ Warning Docstring coverage is 42.59% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (21 passed)
Check name Status Explanation
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 The PR modifies production Go files and also modifies 10 *_test.go files, including tests in affected packages; no bindata YAML files changed.
E2e Tests For Feature Changes ✅ Passed The complete PR diff contains only mechanical go-fix changes; no user-facing behavior change or bug fix is present, so E2E files and testing-section details are not required.
Rbac Least Privilege ✅ Passed The full PR diff from origin/master contains no YAML changes under bindata/ or manifests/, so no ClusterRole or Role rules changed.
Docs For Feature And Behavior Changes ✅ Passed The exact PR diff contains only Go syntax, standard-library helper, and build-tag refactors; it adds no docs and changes no user-facing behavior or architecture.
Stale Project Docs And Config ✅ Passed The complete PR diff changes no docs, .coderabbit.yaml, AGENTS.md, or ARCHITECTURE.md files; source changes are syntax and equivalent helper refactors, and all config paths still exist.
Go And Test Code Quality ✅ Passed The PR diff contains equivalent Go refactors only; added-line scans found no prohibited logging, bare returns, duration literals, shadowing, IPv4-only logic, unsafe concurrency, or test anti-patterns.
Ai-Generated Code Smell ✅ Passed The diff adds no comment slop or AI references; test edits are mechanical replacements, and code changes simplify loops and helpers without new verbose logic.
Stable And Deterministic Test Names ✅ Passed The PR changes no Ginkgo tests or title declarations; repository scans found no It, Describe, Context, When, Entry, or By calls.
Test Structure And Quality ✅ Passed The PR adds no Ginkgo tests or lifecycle blocks. Changed tests use testing.T, fake clients, and fixed local waits; no Eventually/Consistently calls or new cleanup obligations were introduced.
Microshift Test Compatibility ✅ Passed The PR adds no test files and no added Ginkgo declarations; changed test files contain only refactoring edits, so the MicroShift compatibility check is not applicable.
Single Node Openshift (Sno) Test Compatibility ✅ Passed The PR adds no Ginkgo e2e tests; it only modifies existing unit-test code and non-test code, so SNO compatibility checks are not applicable.
Topology-Aware Scheduling Compatibility ✅ Passed The only scheduling-related edit rewrites the OVN replica cap as min(count, 2), with identical behavior; no scheduling manifests or constraints changed.
Ote Binary Stdout Contract ✅ Passed No OTE test binary or suite setup exists. The Go entrypoints are operator/network-diagnostics services, and check-endpoints errors use os.Stderr; non-OTE stdout is out of scope.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed The PR adds no new Ginkgo e2e tests; changed test hunks only modernize types, loops, and assertions, with no new IPv4 or external-connectivity requirements.
No-Weak-Crypto ✅ Passed The PR adds no MD5, SHA-1, DES, 3DES, RC4, Blowfish, ECB, custom crypto, or secret-comparison code; crypto references remain SHA-256 and TLS only.
Container-Privileges ✅ Passed PR changes no privileged, hostPID, hostNetwork, hostIPC, SYS_ADMIN, root, or allowPrivilegeEscalation:true settings; the changed manifest retains runAsNonRoot:true and allowPrivilegeEscalation:false.
No-Sensitive-Data-In-Logs ✅ Passed The PR adds no logging calls or sensitive log values. Logging-related edits only replace interface{} with any and use equivalent fmt.Appendf formatting.
Title check ✅ Passed The title uses an imperative verb, clearly describes the code modernization, and is 45 characters long.
Description check ✅ Passed The description explains the go fix modernization, its purpose, and the verification approach.
✨ 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 cybertron and danwinship August 7, 2026 08:41

@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/network/ovn_kubernetes_test.go`:
- Line 1300: Replace the informal comment “set geneve port to insanity” with a
concise technical comment describing that the test configures an invalid Geneve
port value.
🪄 Autofix

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: Enterprise

Run ID: d7cfc44a-7442-497f-ba5b-5a57481d0b43

📥 Commits

Reviewing files that changed from the base of the PR and between a0ebeb0 and 2446e09.

📒 Files selected for processing (31)
  • cmd/cluster-network-operator/mtu_probe.go
  • pkg/apply/apply.go
  • pkg/cmd/checkendpoints/controller/backoff_recorder.go
  • pkg/cmd/checkendpoints/controller/backoff_recorder_test.go
  • pkg/cmd/checkendpoints/controller/connection_checker.go
  • pkg/cmd/checkendpoints/controller/connection_checker_test.go
  • pkg/controller/eventrecorder/event_recorder.go
  • pkg/controller/infrastructureconfig/validations.go
  • pkg/controller/observability/observability_controller.go
  • pkg/controller/observability/observability_controller_test.go
  • pkg/controller/proxyconfig/validation.go
  • pkg/controller/statusmanager/kube.go
  • pkg/controller/statusmanager/status_manager.go
  • pkg/hypershift/hypershift.go
  • pkg/hypershift/hypershift_test.go
  • pkg/network/additional_networks.go
  • pkg/network/bootstrap_test.go
  • pkg/network/cloud_network_test.go
  • pkg/network/mtu.go
  • pkg/network/mtu_unsupported.go
  • pkg/network/multus_ipam.go
  • pkg/network/ovn_kubernetes.go
  • pkg/network/ovn_kubernetes_dpu_host_test.go
  • pkg/network/ovn_kubernetes_test.go
  • pkg/network/testutil_test.go
  • pkg/network/tls.go
  • pkg/network/tls_test.go
  • pkg/render/funcs.go
  • pkg/render/render.go
  • pkg/util/k8s/unstructured.go
  • pkg/util/proxyconfig/no_proxy.go
💤 Files with no reviewable changes (2)
  • pkg/network/mtu.go
  • pkg/network/mtu_unsupported.go

Comment thread pkg/network/ovn_kubernetes_test.go
@danwinship

Copy link
Copy Markdown
Contributor

/lgtm
/verified by CI

@openshift-ci-robot openshift-ci-robot added the verified Signifies that the PR passed pre-merge verification criteria label Aug 7, 2026
@openshift-ci-robot

Copy link
Copy Markdown
Contributor

@danwinship: This PR has been marked as verified by CI.

Details

In response to this:

/lgtm
/verified by CI

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.

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Aug 7, 2026
@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Scheduling required tests:
/test e2e-aws-ovn-upgrade-ipsec

Scheduling tests matching the pipeline_run_if_changed or not excluded by pipeline_skip_if_only_changed parameters:
/test e2e-aws-ovn-fdp-qe
/test e2e-aws-ovn-hypershift-conformance
/test e2e-aws-ovn-serial-1of2
/test e2e-aws-ovn-serial-2of2
/test e2e-aws-ovn-upgrade
/test e2e-aws-ovn-windows
/test e2e-azure-ovn-upgrade
/test e2e-gcp-ovn
/test e2e-gcp-ovn-upgrade
/test e2e-metal-ipi-ovn-dualstack-bgp
/test e2e-metal-ipi-ovn-dualstack-bgp-local-gw
/test e2e-metal-ipi-ovn-ipv6
/test e2e-metal-ipi-ovn-ipv6-ipsec
/test e2e-ovn-ipsec-step-registry
/test hypershift-e2e-aks

@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 7, 2026
@openshift-ci-robot

Copy link
Copy Markdown
Contributor

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

Details

In response to this:

Why

Go now provides a built-in fix-up tool, go fix. It is intended to apply safe fixes which use newer code patterns to improve maintenability and/or performance.

What

This is a one-time go fix run over the project, simplifying more regular maintenance using go fix in future.

See individual commits for details.

Verification

This is a refactor with no behaviour changes, so existing tests don’t need adjusting and should be sufficient to verify correctness.

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.

skitt added 8 commits August 7, 2026 16:43
This improves readability and allows removing loop counters in some
cases.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
This is more concise.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
This avoids open-coding and allows the project to benefit from stdlib
improvements in future.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
This is more efficient than strings.Split, it avoids creating a slice.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
This allows a number of functions to be removed.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
This avoids going through a string type conversion.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
There are unnecessary.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
This improves readability.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
@openshift-ci-robot openshift-ci-robot removed the verified Signifies that the PR passed pre-merge verification criteria label Aug 7, 2026
@openshift-ci openshift-ci Bot removed the lgtm Indicates that a PR is ready to be merged. label Aug 7, 2026
@skitt skitt changed the title NO-ISSUE: automated codebase modernisation using go fix NO-ISSUE: modernise the codebase using go fix Aug 7, 2026
@openshift-ci

openshift-ci Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

@skitt: 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 2446e09 link true /test e2e-gcp-ovn

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.

@skitt

skitt commented Aug 10, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
⚠️ Action not completed

No files to review.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@danwinship

Copy link
Copy Markdown
Contributor

/lgtm

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Aug 10, 2026
@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Scheduling required tests:
/test e2e-aws-ovn-upgrade-ipsec

Scheduling tests matching the pipeline_run_if_changed or not excluded by pipeline_skip_if_only_changed parameters:
/test e2e-aws-ovn-fdp-qe
/test e2e-aws-ovn-hypershift-conformance
/test e2e-aws-ovn-serial-1of2
/test e2e-aws-ovn-serial-2of2
/test e2e-aws-ovn-upgrade
/test e2e-aws-ovn-windows
/test e2e-azure-ovn-upgrade
/test e2e-gcp-ovn
/test e2e-gcp-ovn-upgrade
/test e2e-metal-ipi-ovn-dualstack-bgp
/test e2e-metal-ipi-ovn-dualstack-bgp-local-gw
/test e2e-metal-ipi-ovn-ipv6
/test e2e-metal-ipi-ovn-ipv6-ipsec
/test e2e-ovn-ipsec-step-registry
/test hypershift-e2e-aks

@openshift-ci

openshift-ci Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: danwinship, skitt

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

The pull request process is described 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

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-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.

3 participants