Skip to content

Commit

Permalink
Merge branch 'main' into fix/nats-jetstream-message-redelivery-are-ig…
Browse files Browse the repository at this point in the history
…nored
  • Loading branch information
toniopelo authored Nov 5, 2022
2 parents 16c9187 + 4653241 commit 8735888
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ To learn more about active deprecations, we recommend checking [GitHub Discussio
- **GCP Storage Scaler:** Add prefix and delimiter support ([#3756](https://github.com/kedacore/keda/issues/3756))
- **Prometheus Scaler:** Introduce skipping of certificate check for unsigned certs ([#2310](https://github.com/kedacore/keda/issues/2310))
- **Event Hubs Scaler:** Support Azure Active Direcotry Pod & Workload Identity for Storage Blobs ([#3569](https://github.com/kedacore/keda/issues/3569))
- **Metrics API Scaler:** Add unsafeSsl paramater to skip certificate validation when connecting over HTTPS ([#3728](https://github.com/kedacore/keda/discussions/3728))

### Fixes

Expand Down
13 changes: 11 additions & 2 deletions pkg/scalers/metrics_api_scaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type metricsAPIScalerMetadata struct {
activationTargetValue float64
url string
valueLocation string
unsafeSsl bool

// apiKeyAuth
enableAPIKeyAuth bool
Expand Down Expand Up @@ -76,14 +77,13 @@ func NewMetricsAPIScaler(config *ScalerConfig) (Scaler, error) {
return nil, fmt.Errorf("error parsing metric API metadata: %s", err)
}

httpClient := kedautil.CreateHTTPClient(config.GlobalHTTPTimeout, false)
httpClient := kedautil.CreateHTTPClient(config.GlobalHTTPTimeout, meta.unsafeSsl)

if meta.enableTLS || len(meta.ca) > 0 {
config, err := kedautil.NewTLSConfig(meta.cert, meta.key, meta.ca)
if err != nil {
return nil, err
}

httpClient.Transport = &http.Transport{TLSClientConfig: config}
}

Expand All @@ -99,6 +99,15 @@ func parseMetricsAPIMetadata(config *ScalerConfig) (*metricsAPIScalerMetadata, e
meta := metricsAPIScalerMetadata{}
meta.scalerIndex = config.ScalerIndex

meta.unsafeSsl = false
if val, ok := config.TriggerMetadata["unsafeSsl"]; ok {
unsafeSsl, err := strconv.ParseBool(val)
if err != nil {
return nil, fmt.Errorf("error parsing unsafeSsl: %s", err)
}
meta.unsafeSsl = unsafeSsl
}

if val, ok := config.TriggerMetadata["targetValue"]; ok {
targetValue, err := strconv.ParseFloat(val, 64)
if err != nil {
Expand Down
6 changes: 6 additions & 0 deletions pkg/scalers/metrics_api_scaler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ var testMetricsAPIAuthMetadata = []metricAPIAuthMetadataTestData{
{map[string]string{"url": "http://dummy:1230/api/v1/", "valueLocation": "metric", "targetValue": "42", "authMode": "bearer"}, map[string]string{"token": "bearerTokenValue"}, false},
// fail bearerAuth without token
{map[string]string{"url": "http://dummy:1230/api/v1/", "valueLocation": "metric", "targetValue": "42", "authMode": "bearer"}, map[string]string{}, true},
// success unsafeSsl true
{map[string]string{"url": "http://dummy:1230/api/v1/", "valueLocation": "metric", "targetValue": "42", "unsafeSsl": "true"}, map[string]string{}, false},
// success unsafeSsl false
{map[string]string{"url": "http://dummy:1230/api/v1/", "valueLocation": "metric", "targetValue": "42", "unsafeSsl": "false"}, map[string]string{}, false},
// failed unsafeSsl non bool
{map[string]string{"url": "http://dummy:1230/api/v1/", "valueLocation": "metric", "targetValue": "42", "unsafeSsl": "yes"}, map[string]string{}, true},
}

func TestParseMetricsAPIMetadata(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions tests/scalers/prometheus/prometheus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ spec:
spec:
containers:
- name: prom-test-app
image: quay.io/zroubalik/prometheus-app:latest
image: ghcr.io/kedacore/tests-prometheus:latest
imagePullPolicy: IfNotPresent
securityContext:
allowPrivilegeEscalation: false
Expand Down Expand Up @@ -98,7 +98,7 @@ spec:
spec:
containers:
- name: prom-test-app
image: quay.io/zroubalik/prometheus-app:latest
image: ghcr.io/kedacore/tests-prometheus:latest
imagePullPolicy: IfNotPresent
securityContext:
allowPrivilegeEscalation: false
Expand Down

0 comments on commit 8735888

Please sign in to comment.