Skip to content

Commit

Permalink
updated logic; signed commit after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
keegancwinchester committed Oct 28, 2022
1 parent 02f3704 commit 1dd9773
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ To learn more about active deprecations, we recommend checking [GitHub Discussio
- [v1.0.0](#v100)

### New

- **General:** Introduce autoscaling is paused annotation for ScaledJobs ([#3303](https://github.com/kedacore/keda/issues/3303))
- **General**: Expand Prometheus metric with label "ScalerName" to distinguish different triggers. The scaleName is defined per Trigger.Name ([#3588](https://github.com/kedacore/keda/issues/3588)
- **General:** Introduce new Loki Scaler ([#3699](https://github.com/kedacore/keda/issues/3699))
- **General**: Add ratelimitting parameters to keda manager to allow override of client defaults ([#3730](https://github.com/kedacore/keda/issues/2920))
Expand Down
2 changes: 2 additions & 0 deletions apis/keda/v1alpha1/scaledjob_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ type ScaledJobStatus struct {
LastActiveTime *metav1.Time `json:"lastActiveTime,omitempty"`
// +optional
Conditions Conditions `json:"conditions,omitempty"`
// +optional
Pause string `json:"paused,omitempty"`
}

// ScaledJobList contains a list of ScaledJob
Expand Down
2 changes: 1 addition & 1 deletion controllers/keda/scaledjob_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ func (r *ScaledJobReconciler) updateTriggerTotalsOnDelete(namespacedName string)
}

// stopScaleLoops when scaledJob.Status.IsPaused() is set
func (r *ScaledJobReconciler) Pause(ctx context.Context, logger logr.Logger, scaledJob *kedav1alpha1.ScaledJob) error {
func (r *ScaledJobReconciler) Paused(ctx context.Context, logger logr.Logger, scaledJob *kedav1alpha1.ScaledJob) error {
if scaledJob.Annotations["scaledjob.keda.sh/paused"] == "true" {
logger.V(1).Info("Stopping a ScaleLoop when scaledJob is paused")
// stopScaleLoop
Expand Down
8 changes: 8 additions & 0 deletions controllers/keda/util/predicate.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ type PausedReplicasPredicate struct {
predicate.Funcs
}

// define annotation as a constant "Paused = "autoscaling.keda.sh/paused""
// define a predicate that checks if the annotation is present and if it is, return true
const Paused = "autoscaling.keda.sh/paused"

type PausedPredicate struct {
predicate.Funcs
}

func (PausedReplicasPredicate) Update(e event.UpdateEvent) bool {
if e.ObjectOld == nil || e.ObjectNew == nil {
return false
Expand Down
2 changes: 1 addition & 1 deletion pkg/scaling/executor/scale_jobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ func min(x, y int64) int64 {
}

// check if scaledJob has Paused annotation, if it does, pause the scaled job
func (e *scaleExecutor) Pause(ctx context.Context, logger logr.Logger, scaledJob *kedav1alpha1.ScaledJob) error {
func (e *scaleExecutor) Paused(ctx context.Context, logger logr.Logger, scaledJob *kedav1alpha1.ScaledJob) error {
if scaledJob.Annotations["scaledjob.keda.sh/paused"] == "true" {
logger.Info("ScaledJob is paused, stop scale loop")
return e.client.Status().Update(ctx, scaledJob)
Expand Down

0 comments on commit 1dd9773

Please sign in to comment.