Skip to content

Commit

Permalink
fix: scaledjobs stuck as not ready (#6329)
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 <Marten.Svantesson@ticket.se>
  • Loading branch information
msvticket authored Nov 23, 2024
1 parent 92f3533 commit 9831734
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 @@ -74,6 +74,7 @@ Here is an overview of all new **experimental** features:

- **General**: Centralize and improve automaxprocs configuration with proper structured logging ([#5970](https://github.com/kedacore/keda/issues/5970))
- **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 9831734

Please sign in to comment.