Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 94 additions & 0 deletions .coderabbit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
inheritance: true
language: en-US
early_access: false
reviews:
path_filters:
- "!vendor/**"
- "!go.sum"
profile: chill
request_changes_workflow: false
high_level_summary: true
poem: false
review_status: true
collapse_walkthrough: false
path_instructions:
- path: "install/**prometheusrule*"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify candidate PrometheusRule-related files and inspect current glob entry.
# Expected: output should include all intended files under install/, then confirm
# whether current pattern is precise enough or should be changed to install/**/*prometheusrule*.

set -euo pipefail

echo "Current config line:"
rg -n 'path:\s*"install/\*\*prometheusrule\*"' .coderabbit.yaml -n -C2 || true

echo
echo "Candidate files under install containing prometheusrule (case-insensitive):"
fd -i 'prometheusrule' install || true

echo
echo "All install YAML/YML files for manual spot-check:"
fd -e yaml -e yml . install || true

Repository: openshift/cluster-version-operator

Length of output: 1616


🌐 Web query:

CodeRabbit path_instructions glob pattern syntax documentation

💡 Result:

CodeRabbit's path_instructions feature uses glob patterns to apply custom review instructions to specific file paths or directories in the .coderabbit.yaml configuration file. Paths accept glob patterns following the minimatch library syntax. Configuration example: reviews: path_instructions: - path: "src/controllers/" instructions: | - Focus on authentication, authorization, and input validation. - Flag any direct database queries that bypass the ORM layer. - path: "tests/" instructions: | Review the following unit test code written using the Mocha test library. Ensure that: - The code adheres to best practices associated with Mocha. - Descriptive test names are used to clearly convey the intent of each test. - Edge cases and error paths are covered. - path: "docs/.md" instructions: | Check for clarity, accuracy, and completeness. This can also be configured via the Web UI in Organization Settings → Reviews → Behavior. Glob Pattern Syntax (via minimatch): - Use forward slashes (/) as path separators, even on Windows. - * : matches zero or more characters in a path segment. - : matches any number of path segments (directories), including none. - ? : matches one character. - {a,b} : brace expansion, matches 'a' or 'b'. - [abc] : character class, matches a, b, or c. - [!abc] or [a-z] : negated or range. - Patterns starting with ! are for exclusion in path_filters, but path_instructions uses positive matching. - # at start is a comment. For full minimatch documentation, see https://isaacs.github.io/minimatch/. Examples from docs: - "/.ts" for TypeScript files. - "src/api/" for API directory. - "tests/." for all test files. Instructions max length: 20000 characters per entry.

Citations:


🏁 Script executed:

# Search for CodeRabbit schema or documentation in the repo
find . -name "*.md" -o -name "*.txt" -o -name "schema*" | head -20
rg -i "path_instructions\|glob.*pattern" --type md --type txt -A 2 -B 2 || true
rg -i "path:.*install.*\*\*" . -t yaml || true

Repository: openshift/cluster-version-operator

Length of output: 870


PrometheusRule path glob does not follow minimatch syntax properly.

The pattern install/**prometheusrule* is malformed. Per CodeRabbit's minimatch glob syntax, ** must be followed by / when used to match directory levels. Use an explicit recursive segment form to correctly target files.

Proposed fix
-    - path: "install/**prometheusrule*"
+    - path: "install/**/*prometheusrule*"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- path: "install/**prometheusrule*"
- path: "install/**/*prometheusrule*"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.coderabbit.yaml at line 15, The glob pattern "install/**prometheusrule*" in
.coderabbit.yaml is malformed because "**" must be followed by "/" to match
directories; update the path to use a proper minimatch recursive segment such as
"install/**/prometheusrule*" or a more specific filename pattern (e.g.,
"install/**/prometheusrule*.yaml") so the rule correctly matches PrometheusRule
files; locate and replace the path value for the rule that currently uses
"install/**prometheusrule*" (search for the exact string
"install/**prometheusrule*") with the corrected glob.

instructions: |
PrometheusRule alert expressions should:
- Use `last_over_time(metric{...}[5m])` to prevent failed scrapes from
resetting alerts
- Prefer `!= 0` for alert expressions where 0 is the happy case
- Use singular metric names (e.g., `_condition` not `_conditions`) per
kube-state-metrics conventions
- Ensure the `for` duration is appropriate for the alert severity
- Verify runbook URLs point to the correct component (not another operator)
- Include a meaningful description and summary annotation
- path: "install/**"
instructions: |
Manifest file and resource naming conventions:
- Resource names should use the full component name (e.g.,
`cluster-version-operator`) not acronyms (e.g., `cvo`) and should not
echo the Kind (e.g., no `-sa` suffix for ServiceAccounts)
- File numbering should leave gaps for future additions; avoid `ZZ` or
letter suffixes for ordering — renumber sibling files instead
- All manifests must have appropriate cluster-profile annotations
(include.release.openshift.io/self-managed-high-availability, etc.)
- Use kubernetes.io/description annotations to explain the resource's purpose
- When adding new manifests, ensure the run-level ordering is correct
(e.g., ServiceAccounts before RoleBindings that reference them)
- path: "pkg/**/*.go"
instructions: |
In reconciliation and controller code, state mutations (struct field
assignments, status updates) should happen as close as possible to where
the value is consumed. Avoid setting fields early in a function when they
are used much later — this creates risk of inconsistency if future code
adds early returns or error paths between the mutation and use.

When sorting or deduplicating collections, ensure stable ordering by
including a tiebreaker field (e.g., sort by version then by name).

When the same boolean condition is used for both logging and a
return/branch decision, extract it to a named variable to keep logic
coupled and avoid divergence if one usage is updated but not the other.

When modifying code, check that nearby comments,
kubernetes.io/description annotations, and doc strings still accurately
describe the new behavior. Outdated documentation is worse than no
documentation.
- path: "pkg/cvo/updatepayload.go"
instructions: |
When modifying container security contexts, ensure init containers are
also reviewed. All containers should have `readOnlyRootFilesystem: true`
unless they explicitly need to write to the filesystem. If an init
container needs write access, document why in the commit message and
consider using `cp` instead of `mv` to keep the source read-only.
- path: "**/*_test.go"
instructions: |
Test code conventions:
- Prefer table-driven tests over multiple similar test functions. If two
test functions differ only in setup values, collapse them into one
function with test-case tuples
- Don't re-fetch resources already obtained in BeforeEach/setup
- Don't introduce single-use variables just to name an intermediate
value; use the expression directly unless it aids readability
- When adding new e2e tests, run `make update` to regenerate
.openshift-tests-extension metadata — CI verify-update will fail
otherwise
- path: "test/**/*.go"
instructions: |
E2E test conventions:
- Add comments explaining non-obvious test URLs or external endpoints
- Use Ginkgo Labels to mark test categories (e.g., TechPreview, serial)
- When skipping tests for certain environments, document the reason
- Ensure test names follow the
`[Jira:"Cluster Version Operator"] description` format
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Jira test-name format does not match the PR objective.

This says [Jira:"Cluster Version Operator"] description, but the objective specifies [Jira:"CVO"] description. Please align to avoid enforcing the wrong convention.

Proposed fix
-        - Ensure test names follow the
-          `[Jira:"Cluster Version Operator"] description` format
+        - Ensure test names follow the
+          `[Jira:"CVO"] description` format
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.coderabbit.yaml at line 84, Update the Jira test-name format in the rule
that currently uses `[Jira:"Cluster Version Operator"] description` to match the
PR objective by replacing the long name with the acronym, i.e. change instances
of `Cluster Version Operator` to `CVO` so the pattern becomes `[Jira:"CVO"]
description`; locate the entry in .coderabbit.yaml (the rule emitting the
`[Jira:"Cluster Version Operator"]` token) and update the string or regex there
so the enforced convention matches the PR objective.

tools:
shellcheck:
enabled: true
markdownlint:
enabled: true
auto_review:
enabled: true
drafts: true
chat:
auto_reply: true
6 changes: 6 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ The format can be described more formally as follows:
The first line is the subject and should be no longer than 70 characters, the second line is always blank, and other lines should be wrapped at 80 characters.
This allows the message to be easier to read on GitHub as well as in various Git tools.

## Automated Code Review

Review rules are defined in [`.coderabbit.yaml`](.coderabbit.yaml) and encode
expected patterns for new submissions. Please review these rules when
contributing to understand the standards enforced during automated review.

[golang-style]: https://github.com/golang/go/wiki/CodeReviewComments
[new-issue]: https://github.com/openshift/cluster-version-operator/issues/new
[prow-review]: https://github.com/kubernetes/community/blob/master/contributors/guide/owners.md#the-code-review-process
Expand Down