Skip to content

Commit

Permalink
fix: scaledjobs stuck as not ready
Browse files Browse the repository at this point in the history
since code was missing for setting a scaledjob as ready it was stuck as unready if there ever was a problem

This is a fix for a regression in #5916

Signed-off-by: Mårten Svantesson <[email protected]>
  • Loading branch information
msvticket committed Nov 12, 2024
1 parent 8332446 commit 8cc76e8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ Here is an overview of all new **experimental** features:
### Fixes

- **General**: Paused ScaledObject count is reported correctly after operator restart ([#6321](https://github.com/kedacore/keda/issues/6321))
- **General**: ScaledJobs ready status set to true when recoverred problem ([#6329](https://github.com/kedacore/keda/pull/6329))

### Deprecations

Expand Down
11 changes: 10 additions & 1 deletion pkg/scaling/executor/scale_jobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,26 @@ func (e *scaleExecutor) RequestJobScale(ctx context.Context, scaledJob *kedav1al
logger.V(1).Info("No change in activity")
}

readyCondition := scaledJob.Status.Conditions.GetReadyCondition()
if isError {
// some triggers responded with error
// Set ScaledJob.Status.ReadyCondition to Unknown
readyCondition := scaledJob.Status.Conditions.GetReadyCondition()
msg := "Some triggers defined in ScaledJob are not working correctly"
logger.V(1).Info(msg)
if !readyCondition.IsUnknown() {
if err := e.setReadyCondition(ctx, logger, scaledJob, metav1.ConditionUnknown, "PartialTriggerError", msg); err != nil {
logger.Error(err, "error setting ready condition")
}
}
} else if !readyCondition.IsTrue() {
// if the ScaledObject's triggers aren't in the error state,
// but ScaledJob.Status.ReadyCondition is set not set to 'true' -> set it back to 'true'
msg := "ScaledJob is defined correctly and is ready for scaling"
logger.V(1).Info(msg)
if err := e.setReadyCondition(ctx, logger, scaledJob, metav1.ConditionTrue,
"ScaledJobReady", msg); err != nil {
logger.Error(err, "error setting ready condition")
}
}

condition := scaledJob.Status.Conditions.GetActiveCondition()
Expand Down

0 comments on commit 8cc76e8

Please sign in to comment.