Skip to content

Commit

Permalink
Release v2.13.1 cherry-pick (#5545)
Browse files Browse the repository at this point in the history
* fix(gcp scalers): Restore previous time horizon to fix missing metrics and properly close the connecctions (#5452)

* fix(gcp scalers): Restore previous time horizon to fix missing metrics

Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>

* Close gcp client on scaler closing

Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>

* fix style

Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>

---------

Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>
Signed-off-by: Jorge Turrado <jorge.turrado@scrm.lidl>

* fix(prometheus-scaler): AWS signv4 parses region if provided (#5421)

Signed-off-by: Siva Guruvareddiar <sivagurunath@gmail.com>
Co-authored-by: Jorge Turrado Ferrero <Jorge_turrado@hotmail.es>
Signed-off-by: Jorge Turrado <jorge.turrado@scrm.lidl>

* Fixed the issue#5484 with inaccurate version label in release asset (#5518)

Signed-off-by: Vinod Kumar Nair <vinod827@gmail.com>
Signed-off-by: Jorge Turrado <jorge.turrado@scrm.lidl>

* fix: Place the changelog entry in unreleased section (#5519)

Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>
Signed-off-by: Jorge Turrado <jorge.turrado@scrm.lidl>

* prepare changelog

Signed-off-by: Jorge Turrado <jorge.turrado@scrm.lidl>

---------

Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>
Signed-off-by: Jorge Turrado <jorge.turrado@scrm.lidl>
Signed-off-by: Siva Guruvareddiar <sivagurunath@gmail.com>
Signed-off-by: Vinod Kumar Nair <vinod827@gmail.com>
Co-authored-by: Siva Guruvareddiar <1725781+sguruvar@users.noreply.github.com>
Co-authored-by: Vinod Kumar <24762720+vinod827@users.noreply.github.com>
  • Loading branch information
3 people committed Feb 29, 2024
1 parent 367fcd3 commit 41dd7a8
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 20 deletions.
8 changes: 4 additions & 4 deletions .github/ISSUE_TEMPLATE/3_bug_report.yml
Expand Up @@ -57,6 +57,7 @@ body:
label: KEDA Version
description: What version of KEDA that are you running?
options:
- "2.13.1"
- "2.13.0"
- "2.12.1"
- "2.12.0"
Expand Down Expand Up @@ -92,12 +93,11 @@ body:
label: Kubernetes Version
description: What version of Kubernetes that are you running?
options:
- "1.29"
- "1.28"
- "1.27"
- "1.26"
- "1.25"
- "1.24"
- "1.23"
- "< 1.23"
- "< 1.26"
- "Other"
validations:
required: false
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Expand Up @@ -16,6 +16,7 @@ To learn more about active deprecations, we recommend checking [GitHub Discussio
## History

- [Unreleased](#unreleased)
- [v2.13.1](#v2131)
- [v2.13.0](#v2130)
- [v2.12.1](#v2121)
- [v2.12.0](#v2120)
Expand Down Expand Up @@ -84,6 +85,15 @@ New deprecation(s):

- **General**: TODO ([#XXX](https://github.com/kedacore/keda/issues/XXX))

## v2.13.1

### Fixes

- **General**: Fix release asset should specify the version in `keda-*-core.yaml`([#5484](https://github.com/kedacore/keda/issues/5484))
- **GCP Scalers**: Properly close the connection during the scaler cleaning process ([#5448](https://github.com/kedacore/keda/issues/5448))
- **GCP Scalers**: Restore previous time horizon to prevent querying issues ([#5429](https://github.com/kedacore/keda/issues/5429))
- **Prometheus Scaler**: Fix for missing AWS region from metadata ([#5419](https://github.com/kedacore/keda/issues/5419))

## v2.13.0

### New
Expand Down
1 change: 1 addition & 0 deletions Makefile
Expand Up @@ -233,6 +233,7 @@ release: manifests kustomize set-version ## Produce new KEDA release in keda-$(V
# Need this workaround to mitigate a problem with inserting labels into selectors,
# until this issue is solved: https://github.com/kubernetes-sigs/kustomize/issues/1009
@sed -i".out" -e 's@version:[ ].*@version: $(VERSION)@g' config/default/kustomize-config/metadataLabelTransformer.yaml
@sed -i".out" -e 's@version:[ ].*@version: $(VERSION)@g' config/minimal/kustomize-config/metadataLabelTransformer.yaml
rm -rf config/default/kustomize-config/metadataLabelTransformer.yaml.out
$(KUSTOMIZE) build config/default > keda-$(VERSION).yaml
$(KUSTOMIZE) build config/minimal > keda-$(VERSION)-core.yaml
Expand Down
8 changes: 5 additions & 3 deletions pkg/scalers/aws/aws_sigv4.go
Expand Up @@ -40,7 +40,6 @@ import (
// roundTripper adds custom round tripper to sign requests
type roundTripper struct {
client *amp.Client
region string
}

var (
Expand All @@ -60,7 +59,7 @@ func (rt *roundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
// "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" is the sha256 of ""
const reqHash = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"

err = rt.client.Options().HTTPSignerV4.SignHTTP(req.Context(), cred, req, reqHash, "aps", rt.region, time.Now())
err = rt.client.Options().HTTPSignerV4.SignHTTP(req.Context(), cred, req, reqHash, "aps", rt.client.Options().Region, time.Now())
if err != nil {
return nil, err
}
Expand All @@ -75,6 +74,10 @@ func (rt *roundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
func parseAwsAMPMetadata(config *scalersconfig.ScalerConfig) (*awsConfigMetadata, error) {
meta := awsConfigMetadata{}

if val, ok := config.TriggerMetadata["awsRegion"]; ok && val != "" {
meta.awsRegion = val
}

auth, err := GetAwsAuthorization(config.TriggerUniqueKey, config.PodIdentity, config.TriggerMetadata, config.AuthParams, config.ResolvedEnv)
if err != nil {
return nil, err
Expand Down Expand Up @@ -109,7 +112,6 @@ func NewSigV4RoundTripper(config *scalersconfig.ScalerConfig) (http.RoundTripper
client := amp.NewFromConfig(*awsCfg, func(o *amp.Options) {})
rt := &roundTripper{
client: client,
region: metadata.awsRegion,
}

return rt, nil
Expand Down
28 changes: 23 additions & 5 deletions pkg/scalers/gcp/gcp_stackdriver_client.go
Expand Up @@ -3,6 +3,7 @@ package gcp
import (
"context"
"encoding/json"
"errors"
"fmt"
"net/http"
"os"
Expand All @@ -20,7 +21,12 @@ import (
)

const (
defaultTimeHorizon = "1m"
// Although the "common" value could be 1m
// before v2.13 it was 2m, so we need to
// keep that value to not break the behaviour
// We need to revisit this in KEDA v3
// https://github.com/kedacore/keda/issues/5429
defaultTimeHorizon = "2m"

// Visualization of aggregation window:
// aggregationTimeHorizon: [- - - - -]
Expand All @@ -47,7 +53,7 @@ const (
// StackDriverClient is a generic client to fetch metrics from Stackdriver. Can be used
// for a stackdriver scaler in the future
type StackDriverClient struct {
MetricsClient *monitoring.MetricClient
metricsClient *monitoring.MetricClient
queryClient *monitoring.QueryClient
credentials GoogleApplicationCredentials
projectID string
Expand All @@ -74,7 +80,7 @@ func NewStackDriverClient(ctx context.Context, credentials string) (*StackDriver
}

return &StackDriverClient{
MetricsClient: metricsClient,
metricsClient: metricsClient,
queryClient: queryClient,
credentials: gcpCredentials,
}, nil
Expand Down Expand Up @@ -102,7 +108,7 @@ func NewStackDriverClientPodIdentity(ctx context.Context) (*StackDriverClient, e
}

return &StackDriverClient{
MetricsClient: metricsClient,
metricsClient: metricsClient,
queryClient: queryClient,
projectID: project,
}, nil
Expand Down Expand Up @@ -239,7 +245,7 @@ func (s StackDriverClient) GetMetrics(
req.Filter = filter

// Get an iterator with the list of time series
it := s.MetricsClient.ListTimeSeries(ctx, req)
it := s.metricsClient.ListTimeSeries(ctx, req)

var value float64 = -1

Expand Down Expand Up @@ -355,6 +361,18 @@ func (s StackDriverClient) BuildMQLQuery(projectID, resourceType, metric, resour
return q, nil
}

func (s *StackDriverClient) Close() error {
var queryClientError error
var metricsClientError error
if s.queryClient != nil {
queryClientError = s.queryClient.Close()
}
if s.metricsClient != nil {
metricsClientError = s.metricsClient.Close()
}
return errors.Join(queryClientError, metricsClientError)
}

// buildAggregation builds the aggregation part of a Monitoring Query Language (MQL) query
func buildAggregation(aggregation string) (string, error) {
// Match against "percentileX"
Expand Down
4 changes: 2 additions & 2 deletions pkg/scalers/gcp/gcp_stackdriver_client_test.go
Expand Up @@ -28,7 +28,7 @@ func TestBuildMQLQuery(t *testing.T) {
"topic without aggregation",
"topic", "pubsub.googleapis.com/topic/x", "mytopic", "",
"fetch pubsub_topic | metric 'pubsub.googleapis.com/topic/x' | filter (resource.project_id == 'myproject' && resource.topic_id == 'mytopic')" +
" | within 1m",
" | within 2m",
false,
},
{
Expand All @@ -42,7 +42,7 @@ func TestBuildMQLQuery(t *testing.T) {
"subscription without aggregation",
"subscription", "pubsub.googleapis.com/subscription/x", "mysubscription", "",
"fetch pubsub_subscription | metric 'pubsub.googleapis.com/subscription/x' | filter (resource.project_id == 'myproject' && resource.subscription_id == 'mysubscription')" +
" | within 1m",
" | within 2m",
false,
},
{
Expand Down
3 changes: 1 addition & 2 deletions pkg/scalers/gcp_cloud_tasks_scaler.go
Expand Up @@ -110,13 +110,12 @@ func parseGcpCloudTasksMetadata(config *scalersconfig.ScalerConfig) (*gcpCloudTa

func (s *gcpCloudTasksScaler) Close(context.Context) error {
if s.client != nil {
err := s.client.MetricsClient.Close()
err := s.client.Close()
s.client = nil
if err != nil {
s.logger.Error(err, "error closing StackDriver client")
}
}

return nil
}

Expand Down
3 changes: 1 addition & 2 deletions pkg/scalers/gcp_pubsub_scaler.go
Expand Up @@ -148,13 +148,12 @@ func parsePubSubMetadata(config *scalersconfig.ScalerConfig, logger logr.Logger)

func (s *pubsubScaler) Close(context.Context) error {
if s.client != nil {
err := s.client.MetricsClient.Close()
err := s.client.Close()
s.client = nil
if err != nil {
s.logger.Error(err, "error closing StackDriver client")
}
}

return nil
}

Expand Down
3 changes: 1 addition & 2 deletions pkg/scalers/gcp_stackdriver_scaler.go
Expand Up @@ -175,13 +175,12 @@ func initializeStackdriverClient(ctx context.Context, gcpAuthorization *gcp.Auth

func (s *stackdriverScaler) Close(context.Context) error {
if s.client != nil {
err := s.client.MetricsClient.Close()
err := s.client.Close()
s.client = nil
if err != nil {
s.logger.Error(err, "error closing StackDriver client")
}
}

return nil
}

Expand Down

0 comments on commit 41dd7a8

Please sign in to comment.