Skip to content

Add CodeRabbit instruction to prefer k8s sets over bespoke maps#31234

Open
stbenjam wants to merge 2 commits into
openshift:mainfrom
stbenjam:coderabbit-sets-review
Open

Add CodeRabbit instruction to prefer k8s sets over bespoke maps#31234
stbenjam wants to merge 2 commits into
openshift:mainfrom
stbenjam:coderabbit-sets-review

Conversation

@stbenjam
Copy link
Copy Markdown
Member

@stbenjam stbenjam commented May 29, 2026

Summary

  • Adds a CodeRabbit path instruction for **/*.go that flags new usage of map[string]bool or map[string]struct{} as ad-hoc sets and recommends k8s.io/apimachinery/pkg/util/sets instead.

Existing bespoke map-set usage

There are ~50 non-vendor files currently using this pattern that could be migrated over time:

Files using map[string]bool or map[string]struct{} as sets

pkg/

  • pkg/e2eanalysis/e2e_analysis.go
  • pkg/monitortestlibrary/allowedalerts/matches_test.go
  • pkg/monitortestlibrary/allowedbackenddisruption/matches_test.go
  • pkg/monitortestlibrary/historicaldata/next_best_guess.go
  • pkg/monitortestlibrary/historicaldata/next_best_guess_test.go
  • pkg/monitortests/cli/adm_upgrade/status/controlplane.go
  • pkg/monitortests/clusterversionoperator/terminationmessagepolicy/monitortest.go
  • pkg/monitortests/etcd/etcdloganalyzer/etcd_recorder_test.go
  • pkg/monitortests/kubeapiserver/auditloganalyzer/handle_audit_latency.go
  • pkg/monitortests/kubeapiserver/crdversionchecker/monitortest.go
  • pkg/monitortests/kubeapiserver/faultyloadbalancer/monitortest.go
  • pkg/monitortests/network/legacynetworkmonitortests/networking.go
  • pkg/monitortests/node/legacynodemonitortests/kubelet.go
  • pkg/monitortests/testframework/highcputestanalyzer/monitortest.go
  • pkg/monitortests/testframework/operatorloganalyzer/operator_lease_check.go
  • pkg/resourcewatch/observe/observe.go
  • pkg/test/ginkgo/cmd_runsuite.go
  • pkg/test/ginkgo/podanalysis.go
  • pkg/test/ginkgo/queue_test.go
  • pkg/test/ginkgo/retries.go
  • pkg/test/ginkgo/retries_test.go
  • pkg/test/ginkgo/sharder_test.go
  • pkg/testsuites/suites_test.go

test/extended/

  • test/extended/builds/run_policy.go
  • test/extended/cluster/cm.go
  • test/extended/dr/common.go
  • test/extended/edge_topologies/arbiter_topology.go
  • test/extended/edge_topologies/tnf_node_replacement_flow.go
  • test/extended/edge_topologies/tnf_node_replacement_ovn_vm.go
  • test/extended/edge_topologies/tnf_node_replacement_types.go
  • test/extended/edge_topologies/utils/services/pacemaker.go
  • test/extended/images/imagechange_buildtrigger.go
  • test/extended/machine_config/helpers.go
  • test/extended/machines/cluster.go
  • test/extended/networking/egressip.go
  • test/extended/networking/egressip_helpers.go
  • test/extended/networking/network_segmentation.go
  • test/extended/networking/route_advertisements.go
  • test/extended/operators/cluster.go
  • test/extended/prometheus/prometheus.go
  • test/extended/prometheus/prometheus_builds.go
  • test/extended/prometheus/storage.go
  • test/extended/router/h2spec.go
  • test/extended/router/metrics.go
  • test/extended/router/stress.go
  • test/extended/tls/tls_observed_config.go
  • test/extended/util/compat_otp/clusters.go
  • test/extended/util/compat_otp/rosacli/kubelet_config_service.go
  • test/extended/util/configv1shim.go
  • test/extended/util/prometheus/helpers.go

tools/

  • tools/changelog/changelog.go

Test plan

  • Verify CodeRabbit picks up the new instruction on future PRs that introduce map[string]bool/map[string]struct{} set patterns

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores
    • Updated development guidelines to prefer the standardized Go set implementation for set-like data.
  • Internal / Reliability
    • Retry allowlist handling now uses the standardized set type internally (behavior unchanged).
  • Tests
    • Updated unit tests to reflect the new internal set usage.

Instruct CodeRabbit to flag new Go code that uses map[string]bool or
map[string]struct{} as ad-hoc sets, and recommend k8s.io/apimachinery/pkg/util/sets
instead.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@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: automatic mode

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 29, 2026

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

Run ID: 9147d40a-bbcb-4c78-a0a2-acb06179fbfa

📥 Commits

Reviewing files that changed from the base of the PR and between 47de102 and 16dc7f2.

📒 Files selected for processing (2)
  • pkg/test/ginkgo/retries.go
  • pkg/test/ginkgo/retries_test.go

Walkthrough

Convert the once-retry allowlist from a map to k8s sets: import and use sets.Set[string] in loader and strategy, update membership checks, adjust tests to use sets.New(...), and add .coderabbit.yaml guidance to prefer k8s.io/apimachinery/pkg/util/sets in Go files.

Changes

Retry allowlist refactor and contributor guidance

Layer / File(s) Summary
Path instructions for Go files
.coderabbit.yaml
Path instructions scoped to **/*.go direct contributors to use k8s.io/apimachinery/pkg/util/sets instead of custom map-backed set implementations.
Retry allowlist implementation
pkg/test/ginkgo/retries.go
Import k8s.io/apimachinery/pkg/util/sets; loadRetryAllowedTests() now returns sets.Set[string]; RetryOnceStrategy.AllowedRetryTests changed to sets.Set[string]; shouldRetryTest uses AllowedRetryTests.Has(...).
Tests updated to use sets
pkg/test/ginkgo/retries_test.go
Tests switch allowlist fixtures from map[string]bool to sets.Set[string] using sets.New(...) and update assertion message text for set initialization.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 14 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (14 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main objective of the pull request: adding a CodeRabbit instruction to recommend k8s sets over custom map-based implementations, which is demonstrated by both the .coderabbit.yaml configuration change and the refactoring of the retry allowlist.
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.
Stable And Deterministic Test Names ✅ Passed No Ginkgo tests with dynamic names introduced. The PR only modifies Go standard test functions with static, stable test names in t.Run() calls.
Test Structure And Quality ✅ Passed Check targets Ginkgo BDD tests; PR modifies standard Go unit tests without cluster interactions, making the check not applicable.
Microshift Test Compatibility ✅ Passed PR adds no new Ginkgo e2e tests (no It/Describe/Context calls). Only refactors retry infrastructure from map[string]bool to sets.Set[string]. MicroShift check applies only to new e2e tests.
Single Node Openshift (Sno) Test Compatibility ✅ Passed No new Ginkgo e2e tests are added. Changes refactor retries.go to use sets.Set[string] and update unit tests. The SNO compatibility check doesn't apply.
Topology-Aware Scheduling Compatibility ✅ Passed PR modifies test utilities and CodeRabbit configuration only; contains no deployment manifests, operator code, or scheduling constraints that would trigger the topology-aware scheduling check.
Ote Binary Stdout Contract ✅ Passed PR refactors test framework code from map[string]bool to sets.Set[string] with no fmt.Print/Println/Printf to stdout, no os.Stdout writes, and only logrus logging to stderr.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed PR does not add any new Ginkgo e2e tests (It(), Describe(), Context(), When()). Changes are configuration, implementation refactoring, and standard Go unit tests only.
No-Weak-Crypto ✅ Passed PR contains no cryptographic code. Changes only involve replacing map-based sets with k8s.io/apimachinery/pkg/util/sets in test retry logic, unrelated to weak crypto check.
Container-Privileges ✅ Passed PR contains no K8s container manifests or security configuration changes; check for container privilege escalation is not applicable to Go code and configuration refactoring.
No-Sensitive-Data-In-Logs ✅ Passed No sensitive data exposure in logs. All logging statements contain only test names, numeric counters, durations, and file paths—no passwords, tokens, keys, PII, session IDs, or credentials.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@openshift-ci openshift-ci Bot requested review from deads2k and sjenning May 29, 2026 12:38
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 29, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: stbenjam

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

@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 29, 2026
Replace the bespoke map[string]bool with k8s.io/apimachinery/pkg/util/sets
for the retry allowlist, which provides type-safe set operations.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@stbenjam
Copy link
Copy Markdown
Member Author

@coderabbitai Why are these checks failing on this PR? It has no tests in it...

  • Multiple Ginkgo test names use dynamic loop variables in test titles (e.g., fmt.Sprintf with description, gvr, kubeconfig parameters), violating stable/deterministic naming requirements.
  • Ginkgo tests in config_admission_test.go and groups_default_rules.go use unavailable MicroShift APIs without proper [apigroup:...] labels or IsMicroShiftCluster() checks.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 29, 2026

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Get PR details and check status
gh pr view 31234 --repo openshift/origin --json statusCheckRollup,title,files 2>/dev/null | jq '.'

# Also look at the PR checks
gh pr checks 31234 --repo openshift/origin 2>/dev/null | head -60

Length of output: 8812


🏁 Script executed:

#!/bin/bash
# Look at any comments on the PR that might explain the failures
gh pr view 31234 --repo openshift/origin --json comments 2>/dev/null | jq '.comments[] | {author: .author.login, body: .body[:500]}' 2>/dev/null | head -100

# Also check the PR reviews
gh pr view 31234 --repo openshift/origin --json reviews 2>/dev/null | jq '.reviews[] | {author: .author.login, state: .state, body: .body[:500]}' 2>/dev/null | head -100

Length of output: 2642



@stbenjam A couple of things to clarify:

  1. The PR isn't test-free — it actually modifies three files, not just .coderabbit.yaml:

    • .coderabbit.yaml
    • pkg/test/ginkgo/retries.go
    • pkg/test/ginkgo/retries_test.go

    The Ginkgo-related observations likely stem from those two files.

  2. Those aren't CI check failures — looking at the actual CI status, all Prow jobs are currently pending (not failed), and ci/prow/lint has already passed. The two bullet points you listed sound like they came from a CodeRabbit review comment, not from a broken CI check.

In short: no CI checks are actually failing right now. If you're seeing CodeRabbit flagging issues in the retries.go/retries_test.go changes (dynamic loop variables in Ginkgo test names, MicroShift API labels), those are review suggestions on the code changes in this PR, not pipeline failures.

@openshift-ci openshift-ci Bot added the ready-for-human-review Indicates a PR has been reviewed by automated tools and is ready for human review label May 29, 2026
@openshift-merge-bot
Copy link
Copy Markdown
Contributor

Scheduling required tests:
/test e2e-aws-csi
/test e2e-aws-ovn-fips
/test e2e-aws-ovn-microshift
/test e2e-aws-ovn-microshift-serial
/test e2e-aws-ovn-serial-1of2
/test e2e-aws-ovn-serial-2of2
/test e2e-gcp-csi
/test e2e-gcp-ovn
/test e2e-gcp-ovn-upgrade
/test e2e-metal-ipi-ovn-ipv6
/test e2e-vsphere-ovn
/test e2e-vsphere-ovn-upi

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 29, 2026

@stbenjam: 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-aws-csi 16dc7f2 link true /test e2e-aws-csi
ci/prow/e2e-aws-ovn-microshift-serial 16dc7f2 link true /test e2e-aws-ovn-microshift-serial
ci/prow/e2e-aws-ovn-serial-2of2 16dc7f2 link true /test e2e-aws-ovn-serial-2of2
ci/prow/e2e-aws-ovn-microshift 16dc7f2 link true /test e2e-aws-ovn-microshift

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

approved Indicates a PR has been approved by an approver from all required OWNERS files. ready-for-human-review Indicates a PR has been reviewed by automated tools and is ready for human review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant