Skip to content

[SDCICD-1701] Add golang-osd-operator-precheck boilerplate convention#724

Open
varunraokadaparthi wants to merge 2 commits into
openshift:masterfrom
varunraokadaparthi:feature/SDCICD-1701-operator-precheck-convention
Open

[SDCICD-1701] Add golang-osd-operator-precheck boilerplate convention#724
varunraokadaparthi wants to merge 2 commits into
openshift:masterfrom
varunraokadaparthi:feature/SDCICD-1701-operator-precheck-convention

Conversation

@varunraokadaparthi
Copy link
Copy Markdown
Contributor

Summary

New convention that generates operator pre-check tests into each operator's test/e2e/ directory. Validates operator readiness before e2e tests run via a Ginkgo BeforeSuite:

  • Auto-detects PKO (ClusterPackage) vs OLM (CSV) operator management
  • Validates deployed version matches expected version from image tag
  • Checks operator namespace exists and all deployments are healthy
  • Polls every 5s with 10min timeout; skips version check for latest tag
  • Uses kubernetes dynamic client to avoid API discovery rate limiting
  • Scopes CSV queries to operator namespace for efficiency
  • Reads OperatorName and OperatorNamespace from config/config.go

Files generated by the convention

  • test/e2e/operator_precheck.go (copied, always overwritten)
  • test/e2e/{operator}_precheck_test.go (generated BeforeSuite wrapper)

How to subscribe

Add openshift/golang-osd-operator-precheck to boilerplate/update.cfg (requires openshift/golang-osd-e2e), then run make boilerplate-update and GOFLAGS="-tags=osde2e" go mod tidy.

Test Strategy

Tested on cluster 2q2npckfvdh6fg2sa2d8ac6la936tbin using osde2e ad-hoc image execution.

Setup

  1. Cloned rbac-permissions-operator (OLM) and route-monitor-operator (PKO) into ~/repo/osd-operators/
  2. Added openshift/golang-osd-operator-precheck to each operator's boilerplate/update.cfg
  3. Ran BOILERPLATE_GIT_REPO=<local-boilerplate> make boilerplate-update to generate precheck files
  4. Ran GOFLAGS="-tags=osde2e" go mod tidy to pull in dependencies
  5. Built e2e images with podman build -f test/e2e/Dockerfile and pushed to quay.io/vkadapar_openshift/
  6. Tagged the same image with different version tags for mismatch and health-only scenarios
  7. Ran tests via osde2e VSCode launch configs pointing to the images

Results

Test Operator Path Tag Result
OLM success rbac-permissions-operator CSV match v0.1.494-g951a9ca Passed
OLM mismatch rbac-permissions-operator CSV mismatch v999.0.0-gdeadbeef Passed (10min timeout, tests skipped)
PKO success route-monitor-operator ClusterPackage match 3c23881 Passed
PKO mismatch route-monitor-operator ClusterPackage mismatch v999.0.0-gdeadbeef Passed (10min timeout, tests skipped)
Health-only rbac-permissions-operator Skip version latest Passed (health checks only)

Issues found and fixed during testing

  • In-cluster config: used rest.InClusterConfig() when KUBECONFIG unset
  • API rate limiting: switched to dynamic client with explicit GVRs
  • Namespace mismatch: read OperatorNamespace from config/config.go

Test Images

Available at quay.io for reproducing tests via osde2e ad-hoc images:

OLM (rbac-permissions-operator):

  • quay.io/vkadapar_openshift/rbac-permissions-operator-e2e:v0.1.494-g951a9ca (success)
  • quay.io/vkadapar_openshift/rbac-permissions-operator-e2e:v999.0.0-gdeadbeef (mismatch)
  • quay.io/vkadapar_openshift/rbac-permissions-operator-e2e:latest (health-only)

PKO (route-monitor-operator):

  • quay.io/vkadapar_openshift/route-monitor-operator-e2e:3c23881 (success)
  • quay.io/vkadapar_openshift/route-monitor-operator-e2e:v999.0.0-gdeadbeef (mismatch)

🤖 Generated with Claude Code

New convention that generates operator pre-check tests into each
operator's `test/e2e/` directory. Validates operator readiness before
e2e tests run via a Ginkgo `BeforeSuite`:

- Auto-detects PKO (`ClusterPackage`) vs OLM (`CSV`) operator management
- Validates deployed version matches expected version from image tag
- Checks operator namespace exists and all deployments are healthy
- Polls every 5s with 10min timeout; skips version check for `latest` tag
- Uses kubernetes dynamic client to avoid API discovery rate limiting
- Scopes CSV queries to operator namespace for efficiency
- Reads `OperatorName` and `OperatorNamespace` from `config/config.go`

Files generated by the convention:
- `test/e2e/operator_precheck.go` (copied, always overwritten)
- `test/e2e/{operator}_precheck_test.go` (generated `BeforeSuite` wrapper)

Operators subscribe by adding `openshift/golang-osd-operator-precheck`
to `boilerplate/update.cfg`. Requires `openshift/golang-osd-e2e`.

## Test Strategy

Tested on cluster `2q2npckfvdh6fg2sa2d8ac6la936tbin` using osde2e
ad-hoc image execution.

### Setup
1. Cloned `rbac-permissions-operator` (OLM) and `route-monitor-operator`
   (PKO) into `~/repo/osd-operators/`
2. Added `openshift/golang-osd-operator-precheck` to each operator's
   `boilerplate/update.cfg`
3. Ran `BOILERPLATE_GIT_REPO=<local-boilerplate> make boilerplate-update`
   to generate precheck files using the local boilerplate convention
4. Ran `GOFLAGS="-tags=osde2e" go mod tidy` to pull in dependencies
5. Built e2e images with `podman build -f test/e2e/Dockerfile` and
   pushed to `quay.io/vkadapar_openshift/`
6. Tagged the same image with different version tags for mismatch
   and health-only scenarios
7. Ran tests via osde2e VSCode launch configs pointing to the images

### Results

| Test | Operator | Path | Tag | Result |
|------|----------|------|-----|--------|
| OLM success | `rbac-permissions-operator` | CSV match | `v0.1.494-g951a9ca` | Passed |
| OLM mismatch | `rbac-permissions-operator` | CSV mismatch | `v999.0.0-gdeadbeef` | Passed (10min timeout, tests skipped) |
| PKO success | `route-monitor-operator` | ClusterPackage match | `3c23881` | Passed |
| PKO mismatch | `route-monitor-operator` | ClusterPackage mismatch | `v999.0.0-gdeadbeef` | Passed (10min timeout, tests skipped) |
| Health-only | `rbac-permissions-operator` | Skip version | `latest` | Passed (health checks only) |

### Issues found and fixed during testing
- **In-cluster config:** used `rest.InClusterConfig()` when `KUBECONFIG` unset
- **API rate limiting:** switched to dynamic client with explicit GVRs
- **Namespace mismatch:** read `OperatorNamespace` from `config/config.go`

### Test Images

Available at quay.io for reproducing tests via osde2e ad-hoc images:

**OLM (`rbac-permissions-operator`):**
- `quay.io/vkadapar_openshift/rbac-permissions-operator-e2e:v0.1.494-g951a9ca` (success)
- `quay.io/vkadapar_openshift/rbac-permissions-operator-e2e:v999.0.0-gdeadbeef` (mismatch)
- `quay.io/vkadapar_openshift/rbac-permissions-operator-e2e:latest` (health-only)

**PKO (`route-monitor-operator`):**
- `quay.io/vkadapar_openshift/route-monitor-operator-e2e:3c23881` (success)
- `quay.io/vkadapar_openshift/route-monitor-operator-e2e:v999.0.0-gdeadbeef` (mismatch)

Co-Authored-By: Claude Code <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 4, 2026

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (4)
  • boilerplate/openshift/golang-osd-operator-precheck/OWNERS is excluded by !boilerplate/**
  • boilerplate/openshift/golang-osd-operator-precheck/README.md is excluded by !boilerplate/**
  • boilerplate/openshift/golang-osd-operator-precheck/operator_precheck.go is excluded by !boilerplate/**
  • boilerplate/openshift/golang-osd-operator-precheck/update is excluded by !boilerplate/**

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 2eabab8d-48ba-4c5f-8e95-17d12df2ce92

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

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

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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

@openshift-ci openshift-ci Bot requested review from AlexSmithGH and eth1030 May 4, 2026 19:46
Copy link
Copy Markdown
Member

@clcollins clcollins left a comment

Choose a reason for hiding this comment

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

A few things to address.


func versionMatches(actual, expected string) bool {
if actual == "" || expected == "" {
return false
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The strings.Contains (and csvMatchesVersion at 230) is loose. E.g., a tag like v0.1 would match v0.10.0-gabcdef0.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

containsVersionBoundary method added to address this issue.
@clcollins can you verify this?

Comment thread boilerplate/openshift/golang-osd-operator-precheck/update
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 4, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: varunraokadaparthi
Once this PR has been reviewed and has the lgtm label, please assign luis-falcon 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

- Guard nil Spec.Replicas before deref in checkDeploymentsReady
- Replace loose strings.Contains version matching with boundary-aware check
- Make BeforeSuite conflict a fatal error (exit 1) instead of a warning

Co-Authored-By: Claude Code <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants