Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make propagationPolicy configurable during job rollout #3338

Merged
merged 5 commits into from
Jul 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ To learn more about our roadmap, we recommend reading [this document](ROADMAP.md
- **General:** Add support to customize HPA name ([3057](https://github.com/kedacore/keda/issues/3057))
- **General:** Basic setup for migrating e2e tests to Go. ([#2737](https://github.com/kedacore/keda/issues/2737))
- **General:** Introduce new AWS DynamoDB Streams Scaler ([#3124](https://github.com/kedacore/keda/issues/3124))
- **General:** Make propagation policy for ScaledJob rollout configurable ([#2910](https://github.com/kedacore/keda/issues/2910))
- **General:** Support for Azure AD Workload Identity as a pod identity provider. ([#2487](https://github.com/kedacore/keda/issues/2487)|[#2656](https://github.com/kedacore/keda/issues/2656))
- **General:** Support for permission segregation when using Azure AD Pod / Workload Identity. ([#2656](https://github.com/kedacore/keda/issues/2656))

Expand All @@ -52,7 +53,6 @@ To learn more about our roadmap, we recommend reading [this document](ROADMAP.md
- **Prometheus Scaler:** Add ignoreNullValues to return error when prometheus return null in values ([#3065](https://github.com/kedacore/keda/issues/3065))
- **Selenium Grid Scaler:** Edge active sessions not being properly counted ([#2709](https://github.com/kedacore/keda/issues/2709))
- **Selenium Grid Scaler:** Max Sessions implementation issue ([#3061](https://github.com/kedacore/keda/issues/3061))

### Fixes

- **General:** Refactor adapter startup to ensure proper log initilization. ([2316](https://github.com/kedacore/keda/issues/2316))
Expand All @@ -65,7 +65,7 @@ To learn more about our roadmap, we recommend reading [this document](ROADMAP.md

### Deprecations

- TODO ([#XXX](https://github.com/kedacore/keda/issue/XXX))
- **ScaledJob**: `rolloutStrategy` is deprecated in favor of `rollout.strategy` ([#2910](https://github.com/kedacore/keda/issues/2910))

### Breaking Changes

Expand Down
11 changes: 11 additions & 0 deletions apis/keda/v1alpha1/scaledjob_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ type ScaledJobSpec struct {
// +optional
RolloutStrategy string `json:"rolloutStrategy,omitempty"`
// +optional
Rollout Rollout `json:"rollout,omitempty"`
// +optional
EnvSourceContainerName string `json:"envSourceContainerName,omitempty"`
// +optional
MaxReplicaCount *int32 `json:"maxReplicaCount,omitempty"`
Expand Down Expand Up @@ -93,6 +95,15 @@ type ScalingStrategy struct {
MultipleScalersCalculation string `json:"multipleScalersCalculation,omitempty"`
}

// Rollout defines the strategy for job rollouts
// +optional
type Rollout struct {
// +optional
Strategy string `json:"strategy,omitempty"`
// +optional
PropagationPolicy string `json:"propagationPolicy,omitempty"`
}

func init() {
SchemeBuilder.Register(&ScaledJob{}, &ScaledJobList{})
}
Expand Down
8 changes: 8 additions & 0 deletions config/crd/bases/keda.sh_scaledjobs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7595,6 +7595,14 @@ spec:
pollingInterval:
format: int32
type: integer
rollout:
description: Rollout defines the strategy for job rollouts
properties:
propagationPolicy:
type: string
strategy:
type: string
type: object
rolloutStrategy:
type: string
scalingStrategy:
Expand Down
17 changes: 15 additions & 2 deletions controllers/keda/scaledjob_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,15 @@ func (r *ScaledJobReconciler) reconcileScaledJob(ctx context.Context, logger log

// Delete Jobs owned by the previous version of the scaledJob based on the rolloutStrategy given for this scaledJob, if any
func (r *ScaledJobReconciler) deletePreviousVersionScaleJobs(ctx context.Context, logger logr.Logger, scaledJob *kedav1alpha1.ScaledJob) (string, error) {
switch scaledJob.Spec.RolloutStrategy {
var rolloutStrategy string
if len(scaledJob.Spec.RolloutStrategy) > 0 {
logger.Info("RolloutStrategy is deprecated, please us Rollout.Strategy in order to define the desired strategy for job rollouts")
rolloutStrategy = scaledJob.Spec.RolloutStrategy
} else {
rolloutStrategy = scaledJob.Spec.Rollout.Strategy
}

switch rolloutStrategy {
case "gradual":
logger.Info("RolloutStrategy: gradual, Not deleting jobs owned by the previous version of the scaleJob")
default:
Expand All @@ -187,7 +195,12 @@ func (r *ScaledJobReconciler) deletePreviousVersionScaleJobs(ctx context.Context
}
for _, job := range jobs.Items {
job := job
err = r.Client.Delete(ctx, &job, client.PropagationPolicy(metav1.DeletePropagationBackground))

propagationPolicy := metav1.DeletePropagationBackground
if scaledJob.Spec.Rollout.PropagationPolicy == "foreground" {
zroubalik marked this conversation as resolved.
Show resolved Hide resolved
propagationPolicy = metav1.DeletePropagationForeground
}
err = r.Client.Delete(ctx, &job, client.PropagationPolicy(propagationPolicy))
if err != nil {
return "Not able to delete job: " + job.Name, err
}
Expand Down