THREESCALE-14651 Fix HPA reconciler to skip API delete calls when HPA already absent#1175
THREESCALE-14651 Fix HPA reconciler to skip API delete calls when HPA already absent#1175urbanikb wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1175 +/- ##
==========================================
+ Coverage 41.84% 44.03% +2.18%
==========================================
Files 203 204 +1
Lines 20859 20923 +64
==========================================
+ Hits 8729 9213 +484
+ Misses 11350 10913 -437
- Partials 780 797 +17
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
d8fbaaf to
52b1142
Compare
ReconcileHpa() was calling DeleteResource() directly when HPA is disabled, which issues a Client().Delete() API call every reconcile cycle regardless of whether the HPA exists. After the first successful delete, subsequent cycles hit a 404 on every cycle indefinitely. Replace with TagObjectToDelete + ReconcileResource, which does a cache-backed Get first and is a no-op when the object is already gone. This is consistent with how PDB and monitoring resources are handled. Add table-driven tests covering all three HPA targets (backend-listener, backend-worker, apicast-production) across enabled, disabled, and async-disable annotation scenarios. Related: THREESCALE-14224 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
52b1142 to
61ef18d
Compare
|
/retest |
1 similar comment
|
/retest |
|
/lgtm Thanks. CI is failing however, and it seems the prow is currently a bit unstable. I will approve this PR but please postpone the merge until Monday. |
|
/retest |
|
Integration tests are failing because the route never available, similar results when running local tests. Can you check whether it's something from us or zync is actually broken |
|
It did create routes locally - it seems the timout of 900s might be too short /retest |
|
@urbanikb: The following test failed, say
Full PR test history. Your PR dashboard. DetailsInstructions 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. |
|
The latest porta image is not backward compatible, I ran integration tested locally with 2.16 porta image and the test passed. |
Summary
Fixes THREESCALE-14651: once an HPA was successfully deleted,
ReconcileHpa()was callingDeleteResource()directly on every subsequent reconcile cycle, hitting a 404 indefinitely.DeleteResource()withTagObjectToDelete+ReconcileResource, which does a cache-backed Get first and is a no-op when the object is already absent — consistent with how PDB and monitoring resources are handledbackend-listener,backend-worker,apicast-productionTest plan
make test-unit)spec.backend.listenerSpec.hpa,spec.backend.workerSpec.hpa,spec.apicast.productionSpec.hpa— no repeated delete attempts in operator logs after HPAs removedManual testing instructions
Tested with following initial setup:
While running locally with
make run.Once system was provisioned, there were no HPAs:
% oc get hpa -n 3scale-test No resources found in 3scale-test namespace.Test scenarios:
borisurbanik@MacBookPro 3scale-operator % oc patch apimanager 3scale -n 3scale-test --type=merge \ -p '{"spec":{"backend":{"listenerSpec":{"hpa":true},"workerSpec":{"hpa":true}},"apicast":{"productionSpec":{"hpa":true}}}}' apimanager.apps.3scale.net/3scale patched borisurbanik@MacBookPro 3scale-operator % oc get hpa -n 3scale-test NAME REFERENCE TARGETS MINPODS MAXPODS REPLICAS AGE apicast-production Deployment/apicast-production memory: 50%/85%, cpu: 0%/85% 1 5 1 79s backend-listener Deployment/backend-listener memory: 13%/85%, cpu: 0%/85% 1 5 1 80s backend-worker Deployment/backend-worker memory: 19%/85%, cpu: 0%/85% 1 5 1 79sborisurbanik@MacBookPro 3scale-operator % oc patch apimanager 3scale -n 3scale-test --type=merge \ -p '{"metadata":{"annotations":{"apps.3scale.net/disable-async":"true"}}}' apimanager.apps.3scale.net/3scale patched borisurbanik@MacBookPro 3scale-operator % oc get hpa -n 3scale-test NAME REFERENCE TARGETS MINPODS MAXPODS REPLICAS AGE apicast-production Deployment/apicast-production memory: 50%/85%, cpu: 0%/85% 1 5 1 8m44sborisurbanik@MacBookPro 3scale-operator % oc patch apimanager 3scale -n 3scale-test --type=json \ -p '[{"op":"remove","path":"/metadata/annotations/apps.3scale.net~1disable-async"},{"op":"replace","path":"/spec/backend/listenerSpec/hpa","value":false},{"op":"replace","path":"/spec/backend/workerSpec/hpa","value":false},{"op":"replace","path":"/spec/apicast/productionSpec/hpa","value":false}]' apimanager.apps.3scale.net/3scale patched borisurbanik@MacBookPro 3scale-operator % oc get hpa -n 3scale-test No resources found in 3scale-test namespace.🤖 Co-authored with Claude Code