feat: adding strictCooldownBehavior arg in cli - #7924
Conversation
Signed-off-by: Ronaldo Lanhellas <ronaldo.lanhellas@gmail.com>
|
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. |
✅ 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. |
|
@rlanhellas ptal at the CI failures |
Alright, will take a look. |
Signed-off-by: Ronaldo Lanhellas <ronaldo.lanhellas@gmail.com>
|
@wozniakjan , @rickbrouwer , please run the e2e tests. |
|
/run-e2e passed tests: 198failed tests: 0 |
wozniakjan
left a comment
There was a problem hiding this comment.
few discussion points below, also can you please add a changelog entry?
| // +optional | ||
| TriggersActivity map[string]TriggerActivityStatus `json:"triggersActivity,omitempty"` | ||
| // +optional | ||
| HpaMinReplicaSinceTime *metav1.Time `json:"hpaMinReplicaSinceTime,omitempty"` |
There was a problem hiding this comment.
is this needed for ScaledJobs? They don't use HPA so there is also no .spec.advanced.horizontalPodAutoscalerConfig in them
There was a problem hiding this comment.
The problem is the interface ScalableObject , both ScaledJob and ScaledObject need to implement it, so I do need to implement SetStatusHPAMinReplicaSinceTime(*metav1.Time) method. Or I create a new interface that will change many points in the code, or I implement an empty SetStatusHPAMinReplicaSinceTime(*metav1.Time) for ScaledJob.
| os.Exit(1) | ||
| } | ||
|
|
||
| scaledHandlerForScaledJob := scaling.NewScaleHandler(mgr.GetClient(), scaleClient, mgr.GetScheme(), globalHTTPTimeout, mgr.GetEventRecorder("scale-handler"), authClientSet, strictCooldownBehavior) |
There was a problem hiding this comment.
this can probably be also removed from SJs
There was a problem hiding this comment.
The scale_handler.go is used for both ScaledJob and ScaledObject. I can create a different NewScaleHandler without this bool arg, set to false by default, so just ScaledObject might call the new one with bool arg.
| } | ||
|
|
||
| // Apply HPA min replica since time | ||
| current.SetStatusHPAMinReplicaSinceTime(result.HPAMinReplicaSinceTime) |
There was a problem hiding this comment.
because result from scale executor has this set only when scaledObject.Status.HpaMinReplicaSinceTime == nil, and hard sets this to nil other times, it seems to flap with timestamp and nil each polling interval
There was a problem hiding this comment.
It should be fixed with your suggestions:
if currentReplicas <= *hpaMinReplicas && scaledObject.Status.HpaMinReplicaSinceTime != nil {
result.HPAMinReplicaSinceTime = scaledObject.Status.HpaMinReplicaSinceTime
}
So, the flow must be:
First time Current Replicas <= HPA min Replicas
1- Current POD replicas <= HPA Min Replicas, and HPAMinReplicaSinceTime is nil, we set it to the current time.
2- We add it to the result to be updated on scale_handler.
Next pass, nothing changes
1- Current POD replicas keep <= HPA MinReplicas, but now HPAMinReplicaSinceTime is NOT nil.
2- We just set the current HPAMinReplicaSinceTime to the result (your suggestion in other PR comments).
Next pass, current replicas greater than HPA min replicas.
1- Current POD Replicas > HPA min replicas, we set HPAMinReplicaSinceTime to nil.
2- Set the result value to nil too.
| result.HPAMinReplicaSinceTime = &metav1.Time{Time: time.Now()} | ||
| } else if currentReplicas > *hpaMinReplicas && scaledObject.Status.HpaMinReplicaSinceTime != nil { | ||
| result.HPAMinReplicaSinceTime = nil | ||
| } |
There was a problem hiding this comment.
I think this may need one extra case to carry the value forward
if currentReplicas <= *hpaMinReplicas && scaledObject.Status.HpaMinReplicaSinceTime != nil {
result.HPAMinReplicaSinceTime = scaledObject.Status.HpaMinReplicaSinceTime
}There was a problem hiding this comment.
Makes sense; just added.
Signed-off-by: Ronaldo Lanhellas <ronaldo.lanhellas@gmail.com>
Signed-off-by: Ronaldo Lanhellas <ronaldo.lanhellas@gmail.com>
Signed-off-by: Ronaldo Lanhellas <ronaldo.lanhellas@gmail.com>
|
@wozniakjan please review again my comments when you have a chance |
Provide a description of what has been changed
Checklist
make generate-scalers-schemahas been run to update any outdated generated filesFixes #7204