Skip to content

Commit

Permalink
add pause metric
Browse files Browse the repository at this point in the history
Signed-off-by: Elad Motola <eladmotola95@gmail.com>
  • Loading branch information
eladmotola committed Apr 22, 2023
1 parent 3dc157b commit 759a45a
Show file tree
Hide file tree
Showing 582 changed files with 35,672 additions and 11,582 deletions.
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/3_bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ body:
label: KEDA Version
description: What version of KEDA that are you running?
options:
- "2.10.1"
- "2.10.0"
- "2.9.3"
- "2.9.2"
Expand Down
3 changes: 3 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
blank_issues_enabled: true
contact_links:
- name: Get help for KEDA add-on on Azure Kubernetes Service (AKS)
url: https://github.com/azure/aks
about: Ask a question or report a bug for KEDA add-on on Azure Kubernetes Service (AKS)
- name: Ask a question about KEDA or get support
url: https://github.com/kedacore/keda/discussions/new
about: Ask a question or request support for using KEDA
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/main-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:

# https://github.com/sigstore/cosign-installer
- name: Install Cosign
uses: sigstore/cosign-installer@v2
uses: sigstore/cosign-installer@v3

- name: Check Cosign install!
run: cosign version
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ jobs:

# https://github.com/sigstore/cosign-installer
- name: Install Cosign
uses: sigstore/cosign-installer@v2
uses: sigstore/cosign-installer@v3

- name: Check Cosign install!
run: cosign version
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/template-trivy-scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
- uses: actions/checkout@v3

- name: Run Trivy
uses: aquasecurity/trivy-action@0.8.0
uses: aquasecurity/trivy-action@0.9.2
with:
scan-type: ${{ inputs.scan-type }}
image-ref: ${{ inputs.image-ref }}
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ endif
GO_BUILD_VARS= GO111MODULE=on CGO_ENABLED=$(CGO) GOOS=$(TARGET_OS) GOARCH=$(ARCH)
GO_LDFLAGS="-X=github.com/kedacore/keda/v2/version.GitCommit=$(GIT_COMMIT) -X=github.com/kedacore/keda/v2/version.Version=$(VERSION)"

COSIGN_FLAGS ?= -a GIT_HASH=${GIT_COMMIT} -a GIT_VERSION=${VERSION} -a BUILD_DATE=${DATE}
COSIGN_FLAGS ?= -y -a GIT_HASH=${GIT_COMMIT} -a GIT_VERSION=${VERSION} -a BUILD_DATE=${DATE}

# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
ENVTEST_K8S_VERSION = 1.26
Expand Down
24 changes: 21 additions & 3 deletions controllers/keda/scaledobject_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,9 @@ type ScaledObjectReconciler struct {
}

type scaledObjectMetricsData struct {
namespace string
triggerTypes []string
namespace string
triggerTypes []string
pausedObjects map[string]bool
}

var (
Expand Down Expand Up @@ -188,6 +189,11 @@ func (r *ScaledObjectReconciler) Reconcile(ctx context.Context, req ctrl.Request
conditions.SetReadyCondition(metav1.ConditionTrue, kedav1alpha1.ScaledObjectConditionReadySucccesReason, msg)
}

if _, present := scaledObject.GetAnnotations()[kedacontrollerutil.PausedReplicasAnnotation]; present {
ref := scaledObject.Spec.ScaleTargetRef
reqLogger.Info("Detect ScaledObject with pause annotation", "targetKind", ref.Kind, "targetName", ref.Name)
}

if err := kedacontrollerutil.SetStatusConditions(ctx, r.Client, reqLogger, scaledObject, &conditions); err != nil {
return ctrl.Result{}, err
}
Expand Down Expand Up @@ -523,10 +529,21 @@ func (r *ScaledObjectReconciler) updatePromMetrics(scaledObject *kedav1alpha1.Sc
}
metricsData.triggerTypes = triggerTypes

_, isPauseObject := scaledObject.GetAnnotations()[kedacontrollerutil.PausedReplicasAnnotation]
value := prommetrics.GetObjectPausedValue(namespacedName, scaledObject.Name)

if isPauseObject && value == 0 {
prommetrics.RecordScalerPauseInc(scaledObject.Namespace, scaledObject.Name)
metricsData.pausedObjects[scaledObject.Name] = true
} else if !isPauseObject && value == 1 {
prommetrics.RecordScalerPauseDec(scaledObject.Namespace, scaledObject.Name)
delete(metricsData.pausedObjects, scaledObject.Name)
}

scaledObjectPromMetricsMap[namespacedName] = metricsData
}

func (r *ScaledObjectReconciler) updatePromMetricsOnDelete(namespacedName string) {
func (r *ScaledObjectReconciler) updatePromMetricsOnDelete(namespacedName string, scaledObject string) {
scaledObjectPromMetricsLock.Lock()
defer scaledObjectPromMetricsLock.Unlock()

Expand All @@ -535,6 +552,7 @@ func (r *ScaledObjectReconciler) updatePromMetricsOnDelete(namespacedName string
for _, triggerType := range metricsData.triggerTypes {
prommetrics.DecrementTriggerTotal(triggerType)
}
prommetrics.RecordScalerPauseDec(namespacedName, scaledObject)
}

delete(scaledObjectPromMetricsMap, namespacedName)
Expand Down
2 changes: 1 addition & 1 deletion controllers/keda/scaledobject_finalizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func (r *ScaledObjectReconciler) finalizeScaledObject(ctx context.Context, logge
return err
}

r.updatePromMetricsOnDelete(namespacedName)
r.updatePromMetricsOnDelete(namespacedName, scaledObject.Name)
}

logger.Info("Successfully finalized ScaledObject")
Expand Down
97 changes: 50 additions & 47 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,61 +4,61 @@ go 1.19

require (
cloud.google.com/go/compute/metadata v0.2.3
cloud.google.com/go/monitoring v1.12.0
cloud.google.com/go/storage v1.29.0
github.com/Azure/azure-amqp-common-go/v3 v3.2.3
github.com/Azure/azure-event-hubs-go/v3 v3.3.20
cloud.google.com/go/monitoring v1.13.0
cloud.google.com/go/storage v1.30.1
github.com/Azure/azure-amqp-common-go/v4 v4.1.0
github.com/Azure/azure-event-hubs-go/v3 v3.5.0
github.com/Azure/azure-kusto-go v0.9.2
github.com/Azure/azure-sdk-for-go v68.0.0+incompatible
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0-beta.1
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.0-beta.3
github.com/Azure/azure-sdk-for-go/sdk/messaging/azservicebus v1.2.0
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.5.0-beta.1
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.0-beta.4
github.com/Azure/azure-sdk-for-go/sdk/messaging/azservicebus v1.2.1
github.com/Azure/azure-storage-blob-go v0.15.0
github.com/Azure/azure-storage-queue-go v0.0.0-20191125232315-636801874cdd
github.com/Azure/go-autorest/autorest v0.11.28
github.com/Azure/go-autorest/autorest/azure/auth v0.5.12
github.com/AzureAD/microsoft-authentication-library-for-go v0.8.1
github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0
github.com/DataDog/datadog-api-client-go v1.16.0
github.com/Huawei/gophercloud v1.0.21
github.com/Shopify/sarama v1.38.1
github.com/arangodb/go-driver v1.5.2
github.com/aws/aws-sdk-go v1.44.216
github.com/aws/aws-sdk-go v1.44.236
github.com/denisenkom/go-mssqldb v0.12.3
github.com/dysnix/predictkube-libs v0.0.4-0.20230109175007-5a82fccd31c7
github.com/dysnix/predictkube-proto v0.0.0-20220713123213-7135dce1e9c9
github.com/elastic/go-elasticsearch/v7 v7.17.7
github.com/go-kivik/couchdb/v3 v3.3.0
github.com/go-kivik/kivik/v3 v3.2.3
github.com/go-logr/logr v1.2.3
github.com/go-playground/validator/v10 v10.11.2
github.com/go-kivik/kivik/v3 v3.2.4
github.com/go-logr/logr v1.2.4
github.com/go-playground/validator/v10 v10.12.0
github.com/go-sql-driver/mysql v1.7.0
github.com/gobwas/glob v0.2.3
github.com/gocql/gocql v1.3.1
github.com/gocql/gocql v1.3.2
github.com/golang/mock v1.6.0
github.com/google/go-cmp v0.5.9
github.com/google/go-github/v50 v50.1.0
github.com/google/go-github/v50 v50.2.0
github.com/google/uuid v1.3.0
github.com/gophercloud/gophercloud v1.2.0
github.com/gophercloud/gophercloud v1.3.0
github.com/hashicorp/vault/api v1.9.0
github.com/imdario/mergo v0.3.13
github.com/influxdata/influxdb-client-go/v2 v2.12.2
github.com/imdario/mergo v0.3.15
github.com/influxdata/influxdb-client-go/v2 v2.12.3
github.com/joho/godotenv v1.5.1
github.com/lib/pq v1.10.7
github.com/microsoft/ApplicationInsights-Go v0.4.4
github.com/microsoft/azure-devops-go-api/azuredevops v1.0.0-b5
github.com/mitchellh/hashstructure v1.1.0
github.com/newrelic/newrelic-client-go v1.1.0
github.com/onsi/ginkgo/v2 v2.9.0
github.com/onsi/gomega v1.27.2
github.com/onsi/ginkgo/v2 v2.9.2
github.com/onsi/gomega v1.27.6
github.com/open-policy-agent/cert-controller v0.7.0
github.com/phayes/freeport v0.0.0-20220201140144-74d24b5ae9f5
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.14.0
github.com/prometheus/client_model v0.3.0
github.com/prometheus/common v0.42.0
github.com/rabbitmq/amqp091-go v1.6.1
github.com/rabbitmq/amqp091-go v1.8.0
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475
github.com/redis/go-redis/v9 v9.0.2
github.com/redis/go-redis/v9 v9.0.3
github.com/robfig/cron/v3 v3.0.1
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.8.2
Expand All @@ -67,24 +67,24 @@ require (
github.com/xhit/go-str2duration/v2 v2.1.0
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a
go.etcd.io/etcd/client/v3 v3.5.7
go.mongodb.org/mongo-driver v1.11.2
go.mongodb.org/mongo-driver v1.11.4
golang.org/x/oauth2 v0.6.0
golang.org/x/sync v0.1.0
google.golang.org/api v0.111.0
google.golang.org/grpc v1.53.0
google.golang.org/api v0.115.0
google.golang.org/grpc v1.54.0
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.3.0
google.golang.org/protobuf v1.28.1
k8s.io/api v0.26.2
k8s.io/apimachinery v0.26.2
k8s.io/client-go v0.26.2
k8s.io/code-generator v0.26.2
google.golang.org/protobuf v1.30.0
k8s.io/api v0.26.3
k8s.io/apimachinery v0.26.3
k8s.io/client-go v0.26.3
k8s.io/code-generator v0.26.3
k8s.io/klog/v2 v2.90.1
k8s.io/kube-openapi v0.0.0-20230303024457-afdc3dddf62d
k8s.io/metrics v0.26.2
k8s.io/utils v0.0.0-20230220204549-a5ecb0141aa5
knative.dev/pkg v0.0.0-20230306194819-b77a78c6c0ad
sigs.k8s.io/controller-runtime v0.14.5
sigs.k8s.io/controller-runtime/tools/setup-envtest v0.0.0-20230307042619-c304e7ec2ee7
k8s.io/metrics v0.26.3
k8s.io/utils v0.0.0-20230313181309-38a27ef9d749
knative.dev/pkg v0.0.0-20230404101938-ee73c9355c9d
sigs.k8s.io/controller-runtime v0.14.6
sigs.k8s.io/controller-runtime/tools/setup-envtest v0.0.0-20230403212152-53057ba616d1
sigs.k8s.io/controller-tools v0.11.3
sigs.k8s.io/custom-metrics-apiserver v1.25.1-0.20230308103314-bd3192a29bc8
sigs.k8s.io/kustomize/kustomize/v4 v4.5.7
Expand Down Expand Up @@ -118,12 +118,12 @@ replace (

require (
cloud.google.com/go v0.110.0 // indirect
cloud.google.com/go/compute v1.18.0 // indirect
cloud.google.com/go/iam v0.12.0 // indirect
cloud.google.com/go/compute v1.19.0 // indirect
cloud.google.com/go/iam v0.13.0 // indirect
code.cloudfoundry.org/clock v1.0.0 // indirect
github.com/Azure/azure-pipeline-go v0.2.3 // indirect
github.com/Azure/azure-sdk-for-go/sdk/internal v1.1.2 // indirect
github.com/Azure/go-amqp v0.17.5 // indirect
github.com/Azure/go-amqp v0.19.1 // indirect
github.com/Azure/go-autorest v14.2.0+incompatible // indirect
github.com/Azure/go-autorest/autorest/adal v0.9.22 // indirect
github.com/Azure/go-autorest/autorest/azure/cli v0.4.6 // indirect
Expand All @@ -134,6 +134,7 @@ require (
github.com/Azure/go-autorest/tracing v0.6.0 // indirect
github.com/DataDog/zstd v1.5.2 // indirect
github.com/NYTimes/gziphandler v1.1.1 // indirect
github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8 // indirect
github.com/andybalholm/brotli v1.0.5 // indirect
github.com/antlr/antlr4/runtime/Go/antlr v1.4.10 // indirect
github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect
Expand All @@ -144,6 +145,7 @@ require (
github.com/cenkalti/backoff/v3 v3.2.2 // indirect
github.com/cenkalti/backoff/v4 v4.2.0 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cloudflare/circl v1.1.0 // indirect
github.com/coreos/go-semver v0.3.1 // indirect
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
Expand All @@ -168,7 +170,7 @@ require (
github.com/go-openapi/swag v0.22.3 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
github.com/gobuffalo/flect v0.3.0 // indirect
github.com/gofrs/uuid v4.2.0+incompatible // indirect
github.com/gogo/protobuf v1.3.2 // indirect
Expand All @@ -177,7 +179,7 @@ require (
github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 // indirect
github.com/golang-sql/sqlexp v0.1.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/cel-go v0.13.0 // indirect
github.com/google/gnostic v0.6.9 // indirect
Expand All @@ -186,7 +188,7 @@ require (
github.com/google/pprof v0.0.0-20230228050547-1710fef4ab10 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.2.3 // indirect
github.com/googleapis/gax-go/v2 v2.7.0 // indirect
github.com/googleapis/gax-go/v2 v2.8.0 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.2 // indirect
Expand Down Expand Up @@ -237,6 +239,7 @@ require (
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/procfs v0.9.0 // indirect
github.com/rivo/uniseg v0.4.4 // indirect
github.com/rogpeppe/go-internal v1.10.0 // indirect
github.com/ryanuber/go-glob v1.0.0 // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/spf13/afero v1.6.0 // indirect
Expand Down Expand Up @@ -273,18 +276,18 @@ require (
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
go.uber.org/zap v1.24.0 // indirect
golang.org/x/crypto v0.6.0 // indirect
golang.org/x/mod v0.8.0 // indirect
golang.org/x/crypto v0.7.0 // indirect
golang.org/x/mod v0.9.0 // indirect
golang.org/x/net v0.8.0 // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/term v0.5.0 // indirect
golang.org/x/text v0.7.0 // indirect
golang.org/x/sys v0.6.0 // indirect
golang.org/x/term v0.6.0 // indirect
golang.org/x/text v0.8.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.6.0 // indirect
golang.org/x/tools v0.7.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20230227214838-9b19f0bdc514 // indirect
google.golang.org/genproto v0.0.0-20230331144136-dcfb400f0633 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
gopkg.in/square/go-jose.v2 v2.6.0 // indirect
Expand Down
Loading

0 comments on commit 759a45a

Please sign in to comment.