Skip to content

Support Claw CR idling#1281

Merged
alexeykazakov merged 7 commits into
codeready-toolchain:masterfrom
alexeykazakov:idler
May 22, 2026
Merged

Support Claw CR idling#1281
alexeykazakov merged 7 commits into
codeready-toolchain:masterfrom
alexeykazakov:idler

Conversation

@alexeykazakov
Copy link
Copy Markdown
Contributor

@alexeykazakov alexeykazakov commented May 21, 2026

Paired with codeready-toolchain/member-operator#745

Summary by CodeRabbit

  • New Features

    • Added a new namespaced Claw custom resource with an idle flag and status subresource.
  • Documentation

    • Clarified CRD HOW‑TO with explicit subsections for fetching serving and claw CRDs from their sources.
  • Tests

    • Extended end-to-end tests to exercise Claw-backed workloads during idling and added test helpers to create, observe, and await Claw resources; improved test polling reliability.

@openshift-ci openshift-ci Bot requested review from jrosental and metlos May 21, 2026 00:57
@alexeykazakov alexeykazakov requested review from MatousJobanek and removed request for jrosental and metlos May 21, 2026 00:57
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 21, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Adds a Claw CustomResourceDefinition and documents its retrieval; implements MemberAwaitility.WaitForClaw and fixes a WaitForAAP context usage; integrates Claw creation and idle-state verification into e2e workloads and TestIdlerAndPriorityClass.

Changes

Claw resource definition and e2e testing

Layer / File(s) Summary
Claw CRD contract and documentation
deploy/crds/claw.sandbox.redhat.com_claws.yaml, deploy/crds/README.adoc
Adds the Claw CRD (group claw.sandbox.redhat.com, v1alpha1, namespaced) with spec.idle: boolean and status subresource; updates README with serving CRDs and claws CRD retrieval instructions.
WaitForClaw test helper and context fix
testsupport/wait/member.go
Updates WaitForAAP to use the poll context and adds MemberAwaitility.WaitForClaw which polls the dynamic Claw resource until spec.idle equals the expected value, returning the last fetched unstructured object or an error; adds CreateWithCleanup and imports cleanup.
E2E test Claw workload creation and verification
test/e2e/parallel/user_workloads_test.go
Adds clawRes GVR, createClaw and clawResource helpers to create a Claw and an owned Deployment, updates workload setup to include the Claw workload, increments expected pod counts, and waits for the Claw to be idled in TestIdlerAndPriorityClass.

Sequence Diagram

sequenceDiagram
  participant Test as TestIdlerAndPriorityClass
  participant PrepareWorkloads as prepareWorkloads
  participant CreateClaw as createClaw
  participant WaitHelper as WaitForClaw
  participant ClawAPI as Claw Resource
  Test->>PrepareWorkloads: prepare test resources
  PrepareWorkloads->>CreateClaw: create Claw workload
  CreateClaw->>ClawAPI: create Claw resource (idle: false)
  CreateClaw->>ClawAPI: create Deployment owned by Claw
  Test->>WaitHelper: wait for Claw idle state
  WaitHelper->>ClawAPI: poll spec.idle
  ClawAPI-->>WaitHelper: return Claw object when idle: true
  Test->>Test: verify workload idled
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested labels

feature, test, documentation

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and specifically describes the main change: adding support for idling the Claw custom resource.
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.

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

@coderabbitai coderabbitai Bot added documentation Improvements or additions to documentation feature New feature or request test Work that adds, fixes, or maintains automated tests or coverage (unit, integration, e2e, flakiness) labels May 21, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

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 `@testsupport/wait/member.go`:
- Around line 1548-1561: In WaitForClaw's PollUntilContextTimeout callback,
replace context.Background() with the provided ctx when calling
clawRes.Namespace(...).Get so the API request is cancelled on timeout, and when
calling unstructured.NestedBool check and use the returned found bool (e.g.,
idled, found, err := unstructured.NestedBool(...)); if err return true,err, if
!found return false,nil to continue polling, otherwise compare expectedIdled ==
idled and return that result.
🪄 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: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: e2ac546f-613b-4ca3-851f-e6cd9f5879d9

📥 Commits

Reviewing files that changed from the base of the PR and between b57dc7a and 306e0cc.

📒 Files selected for processing (4)
  • deploy/crds/README.adoc
  • deploy/crds/claw.sandbox.redhat.com_claws.yaml
  • test/e2e/parallel/user_workloads_test.go
  • testsupport/wait/member.go
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: GolangCI Lint
  • GitHub Check: Build & push operator bundles & dashboard image for e2e tests
🧰 Additional context used
📓 Path-based instructions (1)
**

⚙️ CodeRabbit configuration file

-Focus on major issues impacting performance, readability, maintainability and security. Avoid nitpicks and avoid verbosity.

Files:

  • deploy/crds/README.adoc
  • deploy/crds/claw.sandbox.redhat.com_claws.yaml
  • testsupport/wait/member.go
  • test/e2e/parallel/user_workloads_test.go
🪛 GitHub Check: SonarCloud Code Analysis
testsupport/wait/member.go

[warning] 1550-1550: Use the available context parameter 'ctx' instead of creating a new background context.

See more on https://sonarcloud.io/project/issues?id=codeready-toolchain_toolchain-e2e&issues=AZ5ICj2bAgU2uZTjYs5c&open=AZ5ICj2bAgU2uZTjYs5c&pullRequest=1281

🔇 Additional comments (3)
deploy/crds/claw.sandbox.redhat.com_claws.yaml (1)

1-40: LGTM!

deploy/crds/README.adoc (1)

13-16: LGTM!

test/e2e/parallel/user_workloads_test.go (1)

104-107: LGTM!

Also applies to: 188-190, 218-218, 255-299

Comment thread testsupport/wait/member.go
@coderabbitai coderabbitai Bot removed documentation Improvements or additions to documentation feature New feature or request test Work that adds, fixes, or maintains automated tests or coverage (unit, integration, e2e, flakiness) labels May 21, 2026
@coderabbitai coderabbitai Bot added documentation Improvements or additions to documentation feature New feature or request test Work that adds, fixes, or maintains automated tests or coverage (unit, integration, e2e, flakiness) labels May 21, 2026
Copy link
Copy Markdown
Collaborator

@MatousJobanek MatousJobanek left a comment

Choose a reason for hiding this comment

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

nice

Comment on lines +41 to +48
// Create a Claw workload only in the dev namespace (the one being idled).
// Not added to prepareWorkloads to avoid exceeding the ClusterResourceQuota pod limit
// when workloads are created in multiple namespaces for the same user.
clawDeployment := createClaw(t, memberAwait, "test-idler-claw", idler.Name)
podsToIdle, err := memberAwait.WaitForPods(t, idler.Name, len(podsToIdle)+int(*clawDeployment.Spec.Replicas),
wait.PodRunning(), wait.WithPodLabel("idler", "idler"), wait.WithSandboxPriorityClass())
require.NoError(t, err)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

just a detail - could have been done as part of prepareWorkloads in the same way as it's done for other workload types to verify that it ignores the "noise" namespace for claw workloads

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.

Moved: 5d735f3

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.

Had to revert it due to the pod quota issue if we create it in all namespaces in multi-namespace tiers. We alerready create too many resources in the test namespaces.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We should adjust that (or refactor the test so it uses more accounts) because this would block us from adding more workloads to the test suite

@openshift-ci
Copy link
Copy Markdown

openshift-ci Bot commented May 21, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alexeykazakov, MatousJobanek, metlos, xcoulon

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:
  • OWNERS [MatousJobanek,alexeykazakov,metlos,xcoulon]

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 removed documentation Improvements or additions to documentation feature New feature or request test Work that adds, fixes, or maintains automated tests or coverage (unit, integration, e2e, flakiness) labels May 21, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

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 `@testsupport/wait/member.go`:
- Line 17: gofmt failure due to improperly formatted imports in
testsupport/wait/member.go; run gofmt (or go fmt) on that file to fix import
ordering/formatting so the import block (including
"github.com/codeready-toolchain/toolchain-e2e/testsupport/cleanup") conforms to
gofmt rules and removes any stray blank lines or incorrect grouping.
🪄 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: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: 30b1b07b-41c0-49ba-973d-c9c0009fb705

📥 Commits

Reviewing files that changed from the base of the PR and between d1dd10f and 5d735f3.

📒 Files selected for processing (2)
  • test/e2e/parallel/user_workloads_test.go
  • testsupport/wait/member.go
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Build & push operator bundles & dashboard image for e2e tests
🧰 Additional context used
📓 Path-based instructions (1)
**

⚙️ CodeRabbit configuration file

-Focus on major issues impacting performance, readability, maintainability and security. Avoid nitpicks and avoid verbosity.

Files:

  • testsupport/wait/member.go
  • test/e2e/parallel/user_workloads_test.go
🪛 GitHub Actions: ci-build / 0_GolangCI Lint.txt
testsupport/wait/member.go

[error] 17-17: golangci-lint: File is not properly formatted (gofmt)

🪛 GitHub Actions: ci-build / GolangCI Lint
testsupport/wait/member.go

[error] 17-17: gofmt formatting issue: file is not properly formatted (gofmt) at line 17.

🪛 GitHub Check: GolangCI Lint
testsupport/wait/member.go

[failure] 17-17:
File is not properly formatted (gofmt)

🔇 Additional comments (2)
testsupport/wait/member.go (1)

1419-1427: LGTM!

test/e2e/parallel/user_workloads_test.go (1)

47-50: LGTM!

Also applies to: 177-180

Comment thread testsupport/wait/member.go Outdated
@coderabbitai coderabbitai Bot added documentation Improvements or additions to documentation feature New feature or request test Work that adds, fixes, or maintains automated tests or coverage (unit, integration, e2e, flakiness) labels May 21, 2026
@sonarqubecloud
Copy link
Copy Markdown

@alexeykazakov
Copy link
Copy Markdown
Contributor Author

/retest

@alexeykazakov alexeykazakov merged commit 8a09e02 into codeready-toolchain:master May 22, 2026
9 of 10 checks passed
@alexeykazakov alexeykazakov deleted the idler branch May 22, 2026 03:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved documentation Improvements or additions to documentation feature New feature or request test Work that adds, fixes, or maintains automated tests or coverage (unit, integration, e2e, flakiness)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants