feat: add rhdh.redhat.com/idle annotation for idling/waking workloads - #3318
Conversation
…nstances When the `rhdh.redhat.com/idle: "true"` annotation is set on a Backstage CR, the operator overrides replicas to 0 on the Backstage Deployment and (if enabled) the local DB StatefulSet. Removing the annotation triggers a wake-up, restoring replicas to the user's patched value or defaulting to 1. This enables external controllers (e.g. Dev Sandbox idler) to scale RHDH instances to zero without conflicting with the operator's Server-Side Apply field ownership of the replicas field. State machine: - Normal: replicas not managed by idle logic (HPA-friendly) - Idle (annotation="true"): replicas forced to 0, status reason set to "Idled" - Wake (annotation removed, was Idled): replicas restored, then released Ref: RHIDP-15995 Assisted-by: Claude
rhdh.redhat.com/idle annotation for idling/waking workloads
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3318 +/- ##
==========================================
+ Coverage 63.49% 63.54% +0.04%
==========================================
Files 38 38
Lines 2356 2367 +11
==========================================
+ Hits 1496 1504 +8
- Misses 711 714 +3
Partials 149 149
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Documents the rhdh.redhat.com/idle annotation: how to idle and wake instances, behavior with local vs external DB, HPA compatibility, and status condition transitions. Ref: RHIDP-15995 Assisted-by: Claude
The CI runs with USE_EXISTING_CONTROLLER=true, where ReconcileAny is a no-op and reconciliation happens asynchronously via the background controller. Synchronous assertions after ReconcileAny fail because the controller hasn't processed the annotation change yet. Wrap all post-idle and post-wake assertions in Eventually blocks to poll until the controller reconciles. Ref: RHIDP-15995 Assisted-by: Claude
gazarenkov
left a comment
There was a problem hiding this comment.
Why that complex?
IMO the logic is just:
- check the annotation (in corresponding addToModel or updateAndValidate methods)
- if idled set replica=0 in deployment, statefulset
- otherwise keep unchanged
Did I miss something?
Yeah, good point. This is just the initial draft Claude implementation for this. Still refining it :). Thanks. |
Move the idle annotation check (replicas=0) into the updateAndValidate methods of BackstageDeployment and DbStatefulSet, removing the separate idle/wake block from the controller. Wake logic is unnecessary because the model is rebuilt from scratch on every reconcile — when the annotation is removed, replicas naturally get their default or patched value. Assisted-by: Claude
e4120f2 to
18a27ea
Compare
PR Summary by QodoAdd rhdh.redhat.com/idle annotation to scale Backstage (and local DB) to zero
AI Description
Diagram
High-Level Assessment
Files changed (12)
|
Code Review by Qodo
Context used✅ Compliance rules (platform):
18 rules✅ Cross-repo context Explored:
repo: redhat-developer/rhdh (sha: 3875f708) Not relevant to this PR:
redhat-developer/rhdh-plugins 1.
|
|
/agentic_review |
|
Code review by qodo was updated up to the latest commit 78b8f8a |
- Document namespace scope, CRD prerequisite, and CI/monitoring contract for the Idled status condition - Fix integration test to actually set replicas via spec.deployment.patch and assert wake restores to the patched value (3), not just the default Assisted-by: Claude
78b8f8a to
a02dddc
Compare
|
|
/build-images |
|
✅ PR images built successfully! Images are available for testing:
Also available with PR number tag:
Triggered by @rm3l |



Description
Adds support for the
rhdh.redhat.com/idleannotation on the Backstage CR. When set to"true", the operator overrides replicas to 0 on the Backstage Deployment and (if enabled) the local DB StatefulSet. Removing the annotation triggers a wake-up, restoring replicas to the user's patched value or defaulting to 1.This enables external controllers (e.g. Dev Sandbox idler) to scale RHDH instances to zero without conflicting with the operator's Server-Side Apply field ownership of the replicas field.
State machine:
annotation="true"): replicas forced to 0, status condition reason set toIdledIdled): replicas restored to patch value or 1, then released on next reconcile so HPA can take overExternal DB compatibility: When
spec.database.enableLocalDb=false, only the Backstage Deployment is affected. The external DB is never touched.Which issue(s)
Fixes RHIDP-15995
Part of: RHIDP-15996, RHDHPLAN-1040
PR acceptance criteria
How to test changes / Special notes to the reviewer
Building Container Images for Testing
Need to test container images from this PR?
For Maintainers: To trigger a test image build, review the code and comment
/build-images.This always builds the HEAD of the PR branch.
For Contributors: Ask a maintainer to run
/build-images.Images will be built and pushed to Quay with links posted in comments.