refactor: remove unused scaledJobGenerations sync.Map#7791
Conversation
The scaledJobGenerations sync.Map was written to (Store/Delete) but never read from — unlike ScaledObject's scaledObjectsGenerations which is checked via scaledObjectGenerationChanged() to avoid unnecessary scale-loop restarts. Since ScaledJob unconditionally restarts its scale loop on every reconcile, the generation tracking served no purpose. This removes the dead field, its initialization, and the associated key computation logic, along with the now-unused "k8s.io/client-go/tools/cache" import. Signed-off-by: Mikhail Fedosin <mfedosin@redhat.com>
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
|
Thank you for your contribution! 🙏 Please understand that we will do our best to review your PR and give you feedback as soon as possible, but please bear with us if it takes a little longer as expected. While you are waiting, make sure to:
Once the initial tests are successful, a KEDA member will ensure that the e2e tests are run. Once the e2e tests have been successfully completed, the PR may be merged at a later date. Please be patient. Learn more about our contribution guide. |
There was a problem hiding this comment.
Pull request overview
This PR removes dead generation-tracking state from ScaledJobReconciler, simplifying ScaledJob scale-loop start/stop handling now that the stored generation value is not read anywhere.
Changes:
- Removed
scaledJobGenerationsand itssync.Mapinitialization. - Removed unused cache key generation and Store/Delete calls from ScaledJob scale-loop helpers.
- Also changes the ScaledJob ready CloudEvent type, which is outside the stated refactor scope.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Apart from the removal of unused code, I also see a change that looks like a fix (ScaledObjectReadyType instead of ScaledJobReadyType). For traceability, I think it is worth adding an item to the changelog. /edit: ah, also copilot think the same |
7017741 to
0cbc6ca
Compare
|
Right... I'm going to open another PR with the event type change. |
|
/run-e2e internal |
|
/run-e2e internal passed tests: 34failed tests: 1 |
|
/run-e2e internal passed tests: 35failed tests: 0 |
The scaledJobGenerations sync.Map was written to (Store/Delete) but never read from — unlike ScaledObject's scaledObjectsGenerations which is checked via scaledObjectGenerationChanged() to avoid unnecessary scale-loop restarts. Since ScaledJob unconditionally restarts its scale loop on every reconcile, the generation tracking served no purpose. This removes the dead field, its initialization, and the associated key computation logic, along with the now-unused "k8s.io/client-go/tools/cache" import. Signed-off-by: Mikhail Fedosin <mfedosin@redhat.com> Signed-off-by: Yurii Shcherbak <ju.shcherbak@gmail.com>
The
scaledJobGenerationssync.Mapfield onScaledJobReconcilerwas written to (StoreinrequestScaleLoop,DeleteinstopScaleLoop) but never read from.Unlike
ScaledObjectReconciler, which usesscaledObjectsGenerationsviascaledObjectGenerationChanged()to skip unnecessary scale-loop restarts when the spec hasn't changed,ScaledJobReconcilerunconditionally callsrequestScaleLoopon every successful reconcile. This made the generation tracking dead code.This PR removes:
scaledJobGenerations *sync.Mapfield from the structSetupWithManagercache.MetaNamespaceKeyFunckey computation andStore/Deletecalls inrequestScaleLoop/stopScaleLoop"k8s.io/client-go/tools/cache"importrequestScaleLoopandstopScaleLoopare simplified to directly delegate toHandleScalableObject/DeleteScalableObject.Checklist
make generate-scalers-schemahas been run to update any outdated generated filesFixes #
Relates to #