From 41dd7a8558fdb274f2c0861f6c6d1eba01f2dcd5 Mon Sep 17 00:00:00 2001 From: Jorge Turrado Ferrero Date: Thu, 29 Feb 2024 17:30:42 +0100 Subject: [PATCH] Release v2.13.1 cherry-pick (#5545) * 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 * Close gcp client on scaler closing Signed-off-by: Jorge Turrado * fix style Signed-off-by: Jorge Turrado --------- Signed-off-by: Jorge Turrado Signed-off-by: Jorge Turrado * fix(prometheus-scaler): AWS signv4 parses region if provided (#5421) Signed-off-by: Siva Guruvareddiar Co-authored-by: Jorge Turrado Ferrero Signed-off-by: Jorge Turrado * Fixed the issue#5484 with inaccurate version label in release asset (#5518) Signed-off-by: Vinod Kumar Nair Signed-off-by: Jorge Turrado * fix: Place the changelog entry in unreleased section (#5519) Signed-off-by: Jorge Turrado Signed-off-by: Jorge Turrado * prepare changelog Signed-off-by: Jorge Turrado --------- Signed-off-by: Jorge Turrado Signed-off-by: Jorge Turrado Signed-off-by: Siva Guruvareddiar Signed-off-by: Vinod Kumar Nair Co-authored-by: Siva Guruvareddiar <1725781+sguruvar@users.noreply.github.com> Co-authored-by: Vinod Kumar <24762720+vinod827@users.noreply.github.com> --- .github/ISSUE_TEMPLATE/3_bug_report.yml | 8 +++--- CHANGELOG.md | 10 +++++++ Makefile | 1 + pkg/scalers/aws/aws_sigv4.go | 8 ++++-- pkg/scalers/gcp/gcp_stackdriver_client.go | 28 +++++++++++++++---- .../gcp/gcp_stackdriver_client_test.go | 4 +-- pkg/scalers/gcp_cloud_tasks_scaler.go | 3 +- pkg/scalers/gcp_pubsub_scaler.go | 3 +- pkg/scalers/gcp_stackdriver_scaler.go | 3 +- 9 files changed, 48 insertions(+), 20 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/3_bug_report.yml b/.github/ISSUE_TEMPLATE/3_bug_report.yml index 62ed83f1e13..b771c510f1f 100644 --- a/.github/ISSUE_TEMPLATE/3_bug_report.yml +++ b/.github/ISSUE_TEMPLATE/3_bug_report.yml @@ -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" @@ -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 diff --git a/CHANGELOG.md b/CHANGELOG.md index b45df60f929..32fe220ac52 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) @@ -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 diff --git a/Makefile b/Makefile index 2b1f547d772..9d9bf985217 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/pkg/scalers/aws/aws_sigv4.go b/pkg/scalers/aws/aws_sigv4.go index 9d68461843b..a417fa8f2e3 100644 --- a/pkg/scalers/aws/aws_sigv4.go +++ b/pkg/scalers/aws/aws_sigv4.go @@ -40,7 +40,6 @@ import ( // roundTripper adds custom round tripper to sign requests type roundTripper struct { client *amp.Client - region string } var ( @@ -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 } @@ -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 @@ -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 diff --git a/pkg/scalers/gcp/gcp_stackdriver_client.go b/pkg/scalers/gcp/gcp_stackdriver_client.go index 7dd9de3825e..d7e37a17695 100644 --- a/pkg/scalers/gcp/gcp_stackdriver_client.go +++ b/pkg/scalers/gcp/gcp_stackdriver_client.go @@ -3,6 +3,7 @@ package gcp import ( "context" "encoding/json" + "errors" "fmt" "net/http" "os" @@ -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: [- - - - -] @@ -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 @@ -74,7 +80,7 @@ func NewStackDriverClient(ctx context.Context, credentials string) (*StackDriver } return &StackDriverClient{ - MetricsClient: metricsClient, + metricsClient: metricsClient, queryClient: queryClient, credentials: gcpCredentials, }, nil @@ -102,7 +108,7 @@ func NewStackDriverClientPodIdentity(ctx context.Context) (*StackDriverClient, e } return &StackDriverClient{ - MetricsClient: metricsClient, + metricsClient: metricsClient, queryClient: queryClient, projectID: project, }, nil @@ -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 @@ -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" diff --git a/pkg/scalers/gcp/gcp_stackdriver_client_test.go b/pkg/scalers/gcp/gcp_stackdriver_client_test.go index 9d72e55ed18..741e57c87ac 100644 --- a/pkg/scalers/gcp/gcp_stackdriver_client_test.go +++ b/pkg/scalers/gcp/gcp_stackdriver_client_test.go @@ -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, }, { @@ -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, }, { diff --git a/pkg/scalers/gcp_cloud_tasks_scaler.go b/pkg/scalers/gcp_cloud_tasks_scaler.go index 4ce8ac567cf..9438ffa2394 100644 --- a/pkg/scalers/gcp_cloud_tasks_scaler.go +++ b/pkg/scalers/gcp_cloud_tasks_scaler.go @@ -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 } diff --git a/pkg/scalers/gcp_pubsub_scaler.go b/pkg/scalers/gcp_pubsub_scaler.go index 6f0722a42e0..031fad1a614 100644 --- a/pkg/scalers/gcp_pubsub_scaler.go +++ b/pkg/scalers/gcp_pubsub_scaler.go @@ -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 } diff --git a/pkg/scalers/gcp_stackdriver_scaler.go b/pkg/scalers/gcp_stackdriver_scaler.go index 9deedcc3066..d0513964bbc 100644 --- a/pkg/scalers/gcp_stackdriver_scaler.go +++ b/pkg/scalers/gcp_stackdriver_scaler.go @@ -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 }