From f3c667c5fe665ebd94e245f267567d0d09576040 Mon Sep 17 00:00:00 2001 From: Nikola Jokic Date: Mon, 24 Mar 2025 12:47:25 +0100 Subject: [PATCH] remove required from counters, gauges, histograms --- .../v1alpha1/autoscalingrunnerset_types.go | 9 +- ...tions.github.com_autoscalinglisteners.yaml | 4 - ...ions.github.com_autoscalingrunnersets.yaml | 4 - charts/gha-runner-scale-set/values.yaml | 284 +++++++++--------- cmd/ghalistener/metrics/metrics.go | 11 +- ...tions.github.com_autoscalinglisteners.yaml | 4 - ...ions.github.com_autoscalingrunnersets.yaml | 4 - 7 files changed, 155 insertions(+), 165 deletions(-) diff --git a/apis/actions.github.com/v1alpha1/autoscalingrunnerset_types.go b/apis/actions.github.com/v1alpha1/autoscalingrunnerset_types.go index 921c27c4..2d7946f9 100644 --- a/apis/actions.github.com/v1alpha1/autoscalingrunnerset_types.go +++ b/apis/actions.github.com/v1alpha1/autoscalingrunnerset_types.go @@ -237,9 +237,12 @@ type ProxyServerConfig struct { // MetricsConfig holds configuration parameters for each metric type type MetricsConfig struct { - Counters map[string]*CounterMetric `json:"counters"` - Gauges map[string]*GaugeMetric `json:"gauges"` - Histograms map[string]*HistogramMetric `json:"histograms"` + // +optional + Counters map[string]*CounterMetric `json:"counters,omitempty"` + // +optional + Gauges map[string]*GaugeMetric `json:"gauges,omitempty"` + // +optional + Histograms map[string]*HistogramMetric `json:"histograms,omitempty"` } // CounterMetric holds configuration of a single metric of type Counter diff --git a/charts/gha-runner-scale-set-controller/crds/actions.github.com_autoscalinglisteners.yaml b/charts/gha-runner-scale-set-controller/crds/actions.github.com_autoscalinglisteners.yaml index e5920395..7af045bd 100644 --- a/charts/gha-runner-scale-set-controller/crds/actions.github.com_autoscalinglisteners.yaml +++ b/charts/gha-runner-scale-set-controller/crds/actions.github.com_autoscalinglisteners.yaml @@ -162,10 +162,6 @@ spec: - labels type: object type: object - required: - - counters - - gauges - - histograms type: object minRunners: description: Required diff --git a/charts/gha-runner-scale-set-controller/crds/actions.github.com_autoscalingrunnersets.yaml b/charts/gha-runner-scale-set-controller/crds/actions.github.com_autoscalingrunnersets.yaml index c7a16da3..bf6f60cc 100644 --- a/charts/gha-runner-scale-set-controller/crds/actions.github.com_autoscalingrunnersets.yaml +++ b/charts/gha-runner-scale-set-controller/crds/actions.github.com_autoscalingrunnersets.yaml @@ -142,10 +142,6 @@ spec: - labels type: object type: object - required: - - counters - - gauges - - histograms type: object listenerTemplate: description: PodTemplateSpec describes the data a pod should have when created from a template diff --git a/charts/gha-runner-scale-set/values.yaml b/charts/gha-runner-scale-set/values.yaml index d02ef3a6..a5c77a13 100644 --- a/charts/gha-runner-scale-set/values.yaml +++ b/charts/gha-runner-scale-set/values.yaml @@ -119,148 +119,148 @@ githubConfigSecret: # - name: side-car # image: example-sidecar -listenerMetrics: - counters: - gha_started_jobs_total: - labels: - ["repository", "organization", "enterprise", "job_name", "event_name"] - gha_completed_jobs_total: - labels: - [ - "repository", - "organization", - "enterprise", - "job_name", - "event_name", - "job_result", - ] - gauges: - gha_assigned_jobs: - labels: ["name", "namespace", "repository", "organization", "enterprise"] - gha_running_jobs: - labels: ["name", "namespace", "repository", "organization", "enterprise"] - gha_registered_runners: - labels: ["name", "namespace", "repository", "organization", "enterprise"] - gha_busy_runners: - labels: ["name", "namespace", "repository", "organization", "enterprise"] - gha_min_runners: - labels: ["name", "namespace", "repository", "organization", "enterprise"] - gha_max_runners: - labels: ["name", "namespace", "repository", "organization", "enterprise"] - gha_desired_runners: - labels: ["name", "namespace", "repository", "organization", "enterprise"] - gha_idle_runners: - labels: ["name", "namespace", "repository", "organization", "enterprise"] - histograms: - gha_job_startup_duration_seconds: - labels: - ["repository", "organization", "enterprise", "job_name", "event_name"] - buckets: - [ - 0.01, - 0.05, - 0.1, - 0.5, - 1.0, - 2.0, - 3.0, - 4.0, - 5.0, - 6.0, - 7.0, - 8.0, - 9.0, - 10.0, - 12.0, - 15.0, - 18.0, - 20.0, - 25.0, - 30.0, - 40.0, - 50.0, - 60.0, - 70.0, - 80.0, - 90.0, - 100.0, - 110.0, - 120.0, - 150.0, - 180.0, - 210.0, - 240.0, - 300.0, - 360.0, - 420.0, - 480.0, - 540.0, - 600.0, - 900.0, - 1200.0, - 1800.0, - 2400.0, - 3000.0, - 3600.0, - ] - gha_job_execution_duration_seconds: - labels: - [ - "repository", - "organization", - "enterprise", - "job_name", - "event_name", - "job_result", - ] - buckets: - [ - 0.01, - 0.05, - 0.1, - 0.5, - 1.0, - 2.0, - 3.0, - 4.0, - 5.0, - 6.0, - 7.0, - 8.0, - 9.0, - 10.0, - 12.0, - 15.0, - 18.0, - 20.0, - 25.0, - 30.0, - 40.0, - 50.0, - 60.0, - 70.0, - 80.0, - 90.0, - 100.0, - 110.0, - 120.0, - 150.0, - 180.0, - 210.0, - 240.0, - 300.0, - 360.0, - 420.0, - 480.0, - 540.0, - 600.0, - 900.0, - 1200.0, - 1800.0, - 2400.0, - 3000.0, - 3600.0, - ] +# listenerMetrics: +# counters: +# gha_started_jobs_total: +# labels: +# ["repository", "organization", "enterprise", "job_name", "event_name"] +# gha_completed_jobs_total: +# labels: +# [ +# "repository", +# "organization", +# "enterprise", +# "job_name", +# "event_name", +# "job_result", +# ] +# gauges: +# gha_assigned_jobs: +# labels: ["name", "namespace", "repository", "organization", "enterprise"] +# gha_running_jobs: +# labels: ["name", "namespace", "repository", "organization", "enterprise"] +# gha_registered_runners: +# labels: ["name", "namespace", "repository", "organization", "enterprise"] +# gha_busy_runners: +# labels: ["name", "namespace", "repository", "organization", "enterprise"] +# gha_min_runners: +# labels: ["name", "namespace", "repository", "organization", "enterprise"] +# gha_max_runners: +# labels: ["name", "namespace", "repository", "organization", "enterprise"] +# gha_desired_runners: +# labels: ["name", "namespace", "repository", "organization", "enterprise"] +# gha_idle_runners: +# labels: ["name", "namespace", "repository", "organization", "enterprise"] +# histograms: +# gha_job_startup_duration_seconds: +# labels: +# ["repository", "organization", "enterprise", "job_name", "event_name"] +# buckets: +# [ +# 0.01, +# 0.05, +# 0.1, +# 0.5, +# 1.0, +# 2.0, +# 3.0, +# 4.0, +# 5.0, +# 6.0, +# 7.0, +# 8.0, +# 9.0, +# 10.0, +# 12.0, +# 15.0, +# 18.0, +# 20.0, +# 25.0, +# 30.0, +# 40.0, +# 50.0, +# 60.0, +# 70.0, +# 80.0, +# 90.0, +# 100.0, +# 110.0, +# 120.0, +# 150.0, +# 180.0, +# 210.0, +# 240.0, +# 300.0, +# 360.0, +# 420.0, +# 480.0, +# 540.0, +# 600.0, +# 900.0, +# 1200.0, +# 1800.0, +# 2400.0, +# 3000.0, +# 3600.0, +# ] +# gha_job_execution_duration_seconds: +# labels: +# [ +# "repository", +# "organization", +# "enterprise", +# "job_name", +# "event_name", +# "job_result", +# ] +# buckets: +# [ +# 0.01, +# 0.05, +# 0.1, +# 0.5, +# 1.0, +# 2.0, +# 3.0, +# 4.0, +# 5.0, +# 6.0, +# 7.0, +# 8.0, +# 9.0, +# 10.0, +# 12.0, +# 15.0, +# 18.0, +# 20.0, +# 25.0, +# 30.0, +# 40.0, +# 50.0, +# 60.0, +# 70.0, +# 80.0, +# 90.0, +# 100.0, +# 110.0, +# 120.0, +# 150.0, +# 180.0, +# 210.0, +# 240.0, +# 300.0, +# 360.0, +# 420.0, +# 480.0, +# 540.0, +# 600.0, +# 900.0, +# 1200.0, +# 1800.0, +# 2400.0, +# 3000.0, +# 3600.0, +# ] ## template is the PodSpec for each runner Pod ## For reference: https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#PodSpec diff --git a/cmd/ghalistener/metrics/metrics.go b/cmd/ghalistener/metrics/metrics.go index 011cc13d..cfbd2c04 100644 --- a/cmd/ghalistener/metrics/metrics.go +++ b/cmd/ghalistener/metrics/metrics.go @@ -25,7 +25,10 @@ const ( labelKeyJobResult = "job_result" ) -const githubScaleSetSubsystem = "gha" +const ( + githubScaleSetSubsystem = "gha" + githubScaleSetSubsystemPrefix = "gha_" +) // Names of all metrics available on the listener const ( @@ -198,7 +201,7 @@ func installMetrics(config v1alpha1.MetricsConfig, reg *prometheus.Registry, log g := prometheus.V2.NewGaugeVec(prometheus.GaugeVecOpts{ GaugeOpts: prometheus.GaugeOpts{ Subsystem: githubScaleSetSubsystem, - Name: strings.TrimPrefix(name, githubScaleSetSubsystem), + Name: strings.TrimPrefix(name, githubScaleSetSubsystemPrefix), Help: help, }, VariableLabels: prometheus.UnconstrainedLabels(cfg.Labels), @@ -219,7 +222,7 @@ func installMetrics(config v1alpha1.MetricsConfig, reg *prometheus.Registry, log c := prometheus.V2.NewCounterVec(prometheus.CounterVecOpts{ CounterOpts: prometheus.CounterOpts{ Subsystem: githubScaleSetSubsystem, - Name: strings.TrimPrefix(name, githubScaleSetSubsystem), + Name: strings.TrimPrefix(name, githubScaleSetSubsystemPrefix), Help: help, }, VariableLabels: prometheus.UnconstrainedLabels(cfg.Labels), @@ -245,7 +248,7 @@ func installMetrics(config v1alpha1.MetricsConfig, reg *prometheus.Registry, log h := prometheus.V2.NewHistogramVec(prometheus.HistogramVecOpts{ HistogramOpts: prometheus.HistogramOpts{ Subsystem: githubScaleSetSubsystem, - Name: strings.TrimPrefix(name, githubScaleSetSubsystem), + Name: strings.TrimPrefix(name, githubScaleSetSubsystemPrefix), Help: help, Buckets: buckets, }, diff --git a/config/crd/bases/actions.github.com_autoscalinglisteners.yaml b/config/crd/bases/actions.github.com_autoscalinglisteners.yaml index e5920395..7af045bd 100644 --- a/config/crd/bases/actions.github.com_autoscalinglisteners.yaml +++ b/config/crd/bases/actions.github.com_autoscalinglisteners.yaml @@ -162,10 +162,6 @@ spec: - labels type: object type: object - required: - - counters - - gauges - - histograms type: object minRunners: description: Required diff --git a/config/crd/bases/actions.github.com_autoscalingrunnersets.yaml b/config/crd/bases/actions.github.com_autoscalingrunnersets.yaml index c7a16da3..bf6f60cc 100644 --- a/config/crd/bases/actions.github.com_autoscalingrunnersets.yaml +++ b/config/crd/bases/actions.github.com_autoscalingrunnersets.yaml @@ -142,10 +142,6 @@ spec: - labels type: object type: object - required: - - counters - - gauges - - histograms type: object listenerTemplate: description: PodTemplateSpec describes the data a pod should have when created from a template