Skip to content

Commit

Permalink
fail fast on buildScalers when not able to resolve a secret (kedaco…
Browse files Browse the repository at this point in the history
…re#2394)

Co-authored-by: Jorge Turrado Ferrero <[email protected]>
Signed-off-by: Xiayang Wu <[email protected]>
  • Loading branch information
fivesheep and JorTurFer authored Jan 21, 2022
1 parent d740d67 commit e44a31e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
- **Kafka Scaler:** concurrently query brokers for consumer and producer offsets ([#2405](https://github.com/kedacore/keda/pull/2405))
- **External Scaler:** fix wrong calculation of retry backoff duration ([#2416](https://github.com/kedacore/keda/pull/2416))
- **Kafka Scaler:** allow flag `topic` to be optional, where lag of all topics within the consumer group will be used for scaling ([#2409](https://github.com/kedacore/keda/pull/2409))
- **General:** fail fast on `buildScalers` when not able to resolve a secret that a deployment is relying on ([#2394](https://github.com/kedacore/keda/pull/2394))
- **CPU Scaler:** Adding e2e test for the cpu scaler ([#2441](https://github.com/kedacore/keda/pull/2441))

### Breaking Changes
Expand Down
14 changes: 10 additions & 4 deletions pkg/scaling/scale_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,10 @@ func (h *scaleHandler) GetScalersCache(ctx context.Context, scalableObject inter
return nil, err
}

scalers := h.buildScalers(ctx, withTriggers, podTemplateSpec, containerName)
scalers, err := h.buildScalers(ctx, withTriggers, podTemplateSpec, containerName)
if err != nil {
return nil, err
}

h.scalerCaches[key] = &cache.ScalersCache{
Generation: withTriggers.Generation,
Expand Down Expand Up @@ -273,7 +276,7 @@ func (h *scaleHandler) checkScalers(ctx context.Context, scalableObject interfac
}

// buildScalers returns list of Scalers for the specified triggers
func (h *scaleHandler) buildScalers(ctx context.Context, withTriggers *kedav1alpha1.WithTriggers, podTemplateSpec *corev1.PodTemplateSpec, containerName string) []cache.ScalerBuilder {
func (h *scaleHandler) buildScalers(ctx context.Context, withTriggers *kedav1alpha1.WithTriggers, podTemplateSpec *corev1.PodTemplateSpec, containerName string) ([]cache.ScalerBuilder, error) {
logger := h.logger.WithValues("type", withTriggers.Kind, "namespace", withTriggers.Namespace, "name", withTriggers.Name)
var err error
resolvedEnv := make(map[string]string)
Expand Down Expand Up @@ -313,7 +316,10 @@ func (h *scaleHandler) buildScalers(ctx context.Context, withTriggers *kedav1alp
if scaler != nil {
scaler.Close(ctx)
}
continue
for _, builder := range result {
builder.Scaler.Close(ctx)
}
return nil, err
}

result = append(result, cache.ScalerBuilder{
Expand All @@ -322,7 +328,7 @@ func (h *scaleHandler) buildScalers(ctx context.Context, withTriggers *kedav1alp
})
}

return result
return result, nil
}

func buildScaler(ctx context.Context, client client.Client, triggerType string, config *scalers.ScalerConfig) (scalers.Scaler, error) {
Expand Down

0 comments on commit e44a31e

Please sign in to comment.