From 3f6e98a9d57394b20513e5efdcab6aac37f29891 Mon Sep 17 00:00:00 2001 From: Alexander Davis Date: Fri, 14 Jun 2024 15:20:38 -0500 Subject: [PATCH 1/5] feat: add new opt-in metric of reloads by namespace --- README.md | 1 + .../chart/reloader/templates/deployment.yaml | 6 +- .../kubernetes/chart/reloader/values.yaml | 2 + .../templates/chart/values.yaml.tmpl | 2 + internal/pkg/handler/upgrade.go | 2 + internal/pkg/handler/upgrade_test.go | 262 +++++++++++++++++- internal/pkg/metrics/prometheus.go | 30 +- 7 files changed, 293 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 7c4a3edb6..763eb5548 100644 --- a/README.md +++ b/README.md @@ -328,6 +328,7 @@ helm uninstall {{RELEASE_NAME}} -n {{NAMESPACE}} | `reloader.readOnlyRootFileSystem` | Enforce readOnlyRootFilesystem | boolean | `false` | | `reloader.legacy.rbac` | | boolean | `false` | | `reloader.matchLabels` | Pod labels to match | map | `{}` | +| `reloader.enableMetricsByNamespace` | Expose an additional Prometheus counter of reloads by namespace (this metric may have high cardinality in clusters with many namespaces) | boolean | `false` | #### Deployment Reloader Parameters diff --git a/deployments/kubernetes/chart/reloader/templates/deployment.yaml b/deployments/kubernetes/chart/reloader/templates/deployment.yaml index 6d38fd355..dca675074 100644 --- a/deployments/kubernetes/chart/reloader/templates/deployment.yaml +++ b/deployments/kubernetes/chart/reloader/templates/deployment.yaml @@ -76,7 +76,7 @@ spec: - image: "{{ .Values.reloader.deployment.image.name }}:{{ .Values.reloader.deployment.image.tag }}" imagePullPolicy: {{ .Values.reloader.deployment.image.pullPolicy }} name: {{ template "reloader-fullname" . }} - {{- if or (.Values.reloader.deployment.env.open) (.Values.reloader.deployment.env.secret) (.Values.reloader.deployment.env.field) (.Values.reloader.deployment.env.existing) (eq .Values.reloader.watchGlobally false) (.Values.reloader.enableHA)}} + {{- if or (.Values.reloader.deployment.env.open) (.Values.reloader.deployment.env.secret) (.Values.reloader.deployment.env.field) (.Values.reloader.deployment.env.existing) (eq .Values.reloader.watchGlobally false) (.Values.reloader.enableHA) (.Values.reloader.enableMetricsByNamespace)}} env: {{- range $name, $value := .Values.reloader.deployment.env.open }} {{- if not (empty $value) }} @@ -129,6 +129,10 @@ spec: fieldRef: fieldPath: metadata.namespace {{- end }} + {{- if .Values.reloader.enableMetricsByNamespace }} + - name: METRICS_COUNT_BY_NAMESPACE + value: enabled + {{- end }} {{- end }} ports: diff --git a/deployments/kubernetes/chart/reloader/values.yaml b/deployments/kubernetes/chart/reloader/values.yaml index eed307c40..8094747a8 100644 --- a/deployments/kubernetes/chart/reloader/values.yaml +++ b/deployments/kubernetes/chart/reloader/values.yaml @@ -32,6 +32,8 @@ reloader: legacy: rbac: false matchLabels: {} + # Set to true to expose a prometheus counter of reloads by namespace (this metric may have high cardinality in clusters with many namespaces) + enableMetricsByNamespace: false deployment: # If you wish to run multiple replicas set reloader.enableHA = true replicas: 1 diff --git a/deployments/kubernetes/templates/chart/values.yaml.tmpl b/deployments/kubernetes/templates/chart/values.yaml.tmpl index bb34027e5..6099983e9 100644 --- a/deployments/kubernetes/templates/chart/values.yaml.tmpl +++ b/deployments/kubernetes/templates/chart/values.yaml.tmpl @@ -23,6 +23,8 @@ reloader: legacy: rbac: false matchLabels: {} + # Set to true to expose a prometheus counter of reloads by namespace (this metric may have high cardinality in clusters with many namespaces) + enableMetricsByNamespace: false deployment: replicas: 1 nodeSelector: diff --git a/internal/pkg/handler/upgrade.go b/internal/pkg/handler/upgrade.go index cf070a830..05fc0c0ed 100644 --- a/internal/pkg/handler/upgrade.go +++ b/internal/pkg/handler/upgrade.go @@ -245,6 +245,7 @@ func PerformRollingUpgrade(clients kube.Clients, config util.Config, upgradeFunc message := fmt.Sprintf("Update for '%s' of type '%s' in namespace '%s' failed with error %v", resourceName, upgradeFuncs.ResourceType, config.Namespace, err) logrus.Errorf(message) collectors.Reloaded.With(prometheus.Labels{"success": "false"}).Inc() + collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "false", "namespace": config.Namespace}).Inc() if recorder != nil { recorder.Event(i, v1.EventTypeWarning, "ReloadFail", message) } @@ -254,6 +255,7 @@ func PerformRollingUpgrade(clients kube.Clients, config util.Config, upgradeFunc message += fmt.Sprintf(", Updated '%s' of type '%s' in namespace '%s'", resourceName, upgradeFuncs.ResourceType, config.Namespace) logrus.Infof(message) collectors.Reloaded.With(prometheus.Labels{"success": "true"}).Inc() + collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "true", "namespace": config.Namespace}).Inc() alert_on_reload, ok := os.LookupEnv("ALERT_ON_RELOAD") if recorder != nil { recorder.Event(i, v1.EventTypeNormal, "Reloaded", message) diff --git a/internal/pkg/handler/upgrade_test.go b/internal/pkg/handler/upgrade_test.go index 907aa687c..ac521c36e 100644 --- a/internal/pkg/handler/upgrade_test.go +++ b/internal/pkg/handler/upgrade_test.go @@ -1278,12 +1278,12 @@ func getConfigWithAnnotations(resourceType string, name string, shaData string, } return util.Config{ - Namespace: ns, - ResourceName: name, - SHAValue: shaData, - Annotation: annotation, - TypedAutoAnnotation: typedAutoAnnotation, - Type: resourceType, + Namespace: ns, + ResourceName: name, + SHAValue: shaData, + Annotation: annotation, + TypedAutoAnnotation: typedAutoAnnotation, + Type: resourceType, } } @@ -1317,6 +1317,10 @@ func TestRollingUpgradeForDeploymentWithConfigmapUsingArs(t *testing.T) { if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { + t.Errorf("Counter by namespace was not increased") + } } func TestRollingUpgradeForDeploymentWithConfigmapWithoutReloadAnnotationAndWithoutAutoReloadAllNoTriggersUsingArs(t *testing.T) { @@ -1340,7 +1344,11 @@ func TestRollingUpgradeForDeploymentWithConfigmapWithoutReloadAnnotationAndWitho } if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) > 0 { - t.Errorf("Counter was increased") + t.Errorf("Counter was increased unexpectedly") + } + + if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) > 0 { + t.Errorf("Counter by namespace was increased unexpectedly") } } @@ -1369,6 +1377,10 @@ func TestRollingUpgradeForDeploymentWithConfigmapWithoutReloadAnnotationButWithA if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { + t.Errorf("Counter by namespace was not increased") + } } func TestRollingUpgradeForDeploymentWithConfigmapInProjectedVolumeUsingArs(t *testing.T) { @@ -1393,6 +1405,10 @@ func TestRollingUpgradeForDeploymentWithConfigmapInProjectedVolumeUsingArs(t *te if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { + t.Errorf("Counter by namespace was not increased") + } } func TestRollingUpgradeForDeploymentWithConfigmapViaSearchAnnotationUsingArs(t *testing.T) { @@ -1418,6 +1434,10 @@ func TestRollingUpgradeForDeploymentWithConfigmapViaSearchAnnotationUsingArs(t * if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { + t.Errorf("Counter by namespace was not increased") + } } func TestRollingUpgradeForDeploymentWithConfigmapViaSearchAnnotationNoTriggersUsingArs(t *testing.T) { @@ -1444,6 +1464,10 @@ func TestRollingUpgradeForDeploymentWithConfigmapViaSearchAnnotationNoTriggersUs if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) > 0 { t.Errorf("Counter was increased unexpectedly") } + + if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) > 1 { + t.Errorf("Counter by namespace was increased unexpectedly") + } } func TestRollingUpgradeForDeploymentWithConfigmapViaSearchAnnotationNotMappedUsingArs(t *testing.T) { @@ -1483,6 +1507,10 @@ func TestRollingUpgradeForDeploymentWithConfigmapViaSearchAnnotationNotMappedUsi if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) > 0 { t.Errorf("Counter was increased unexpectedly") } + + if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) > 1 { + t.Errorf("Counter by namespace was increased unexpectedly") + } } func TestRollingUpgradeForDeploymentWithConfigmapInInitContainerUsingArs(t *testing.T) { @@ -1508,6 +1536,10 @@ func TestRollingUpgradeForDeploymentWithConfigmapInInitContainerUsingArs(t *test if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { + t.Errorf("Counter by namespace was not increased") + } } func TestRollingUpgradeForDeploymentWithConfigmapInProjectVolumeInInitContainerUsingArs(t *testing.T) { @@ -1533,6 +1565,10 @@ func TestRollingUpgradeForDeploymentWithConfigmapInProjectVolumeInInitContainerU if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { + t.Errorf("Counter by namespace was not increased") + } } func TestRollingUpgradeForDeploymentWithConfigmapAsEnvVarUsingArs(t *testing.T) { @@ -1558,6 +1594,10 @@ func TestRollingUpgradeForDeploymentWithConfigmapAsEnvVarUsingArs(t *testing.T) if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { + t.Errorf("Counter by namespace was not increased") + } } func TestRollingUpgradeForDeploymentWithConfigmapAsEnvVarInInitContainerUsingArs(t *testing.T) { @@ -1583,6 +1623,10 @@ func TestRollingUpgradeForDeploymentWithConfigmapAsEnvVarInInitContainerUsingArs if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { + t.Errorf("Counter by namespace was not increased") + } } func TestRollingUpgradeForDeploymentWithConfigmapAsEnvVarFromUsingArs(t *testing.T) { @@ -1608,6 +1652,10 @@ func TestRollingUpgradeForDeploymentWithConfigmapAsEnvVarFromUsingArs(t *testing if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { + t.Errorf("Counter by namespace was not increased") + } } func TestRollingUpgradeForDeploymentWithSecretUsingArs(t *testing.T) { @@ -1633,6 +1681,10 @@ func TestRollingUpgradeForDeploymentWithSecretUsingArs(t *testing.T) { if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { + t.Errorf("Counter by namespace was not increased") + } } func TestRollingUpgradeForDeploymentWithSecretInProjectedVolumeUsingArs(t *testing.T) { @@ -1658,6 +1710,10 @@ func TestRollingUpgradeForDeploymentWithSecretInProjectedVolumeUsingArs(t *testi if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { + t.Errorf("Counter by namespace was not increased") + } } func TestRollingUpgradeForDeploymentWithSecretinInitContainerUsingArs(t *testing.T) { @@ -1683,6 +1739,10 @@ func TestRollingUpgradeForDeploymentWithSecretinInitContainerUsingArs(t *testing if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { + t.Errorf("Counter by namespace was not increased") + } } func TestRollingUpgradeForDeploymentWithSecretInProjectedVolumeinInitContainerUsingArs(t *testing.T) { @@ -1708,6 +1768,10 @@ func TestRollingUpgradeForDeploymentWithSecretInProjectedVolumeinInitContainerUs if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { + t.Errorf("Counter by namespace was not increased") + } } func TestRollingUpgradeForDeploymentWithSecretAsEnvVarUsingArs(t *testing.T) { @@ -1733,6 +1797,10 @@ func TestRollingUpgradeForDeploymentWithSecretAsEnvVarUsingArs(t *testing.T) { if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { + t.Errorf("Counter by namespace was not increased") + } } func TestRollingUpgradeForDeploymentWithSecretAsEnvVarFromUsingArs(t *testing.T) { @@ -1758,6 +1826,10 @@ func TestRollingUpgradeForDeploymentWithSecretAsEnvVarFromUsingArs(t *testing.T) if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { + t.Errorf("Counter by namespace was not increased") + } } func TestRollingUpgradeForDeploymentWithSecretAsEnvVarInInitContainerUsingArs(t *testing.T) { @@ -1783,6 +1855,10 @@ func TestRollingUpgradeForDeploymentWithSecretAsEnvVarInInitContainerUsingArs(t if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { + t.Errorf("Counter by namespace was not increased") + } } func TestRollingUpgradeForDeploymentWithSecretAutoAnnotationUsingArs(t *testing.T) { @@ -1808,6 +1884,10 @@ func TestRollingUpgradeForDeploymentWithSecretAutoAnnotationUsingArs(t *testing. if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { + t.Errorf("Counter by namespace was not increased") + } } func TestRollingUpgradeForDeploymentWithConfigMapAutoAnnotationUsingArs(t *testing.T) { @@ -1833,6 +1913,10 @@ func TestRollingUpgradeForDeploymentWithConfigMapAutoAnnotationUsingArs(t *testi if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { + t.Errorf("Counter by namespace was not increased") + } } func TestRollingUpgradeForDaemonSetWithConfigmapUsingArs(t *testing.T) { @@ -1858,6 +1942,10 @@ func TestRollingUpgradeForDaemonSetWithConfigmapUsingArs(t *testing.T) { if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { + t.Errorf("Counter by namespace was not increased") + } } func TestRollingUpgradeForDaemonSetWithConfigmapInProjectedVolumeUsingArs(t *testing.T) { @@ -1883,6 +1971,10 @@ func TestRollingUpgradeForDaemonSetWithConfigmapInProjectedVolumeUsingArs(t *tes if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { + t.Errorf("Counter by namespace was not increased") + } } func TestRollingUpgradeForDaemonSetWithConfigmapAsEnvVarUsingArs(t *testing.T) { @@ -1908,6 +2000,10 @@ func TestRollingUpgradeForDaemonSetWithConfigmapAsEnvVarUsingArs(t *testing.T) { if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { + t.Errorf("Counter by namespace was not increased") + } } func TestRollingUpgradeForDaemonSetWithSecretUsingArs(t *testing.T) { @@ -1933,6 +2029,10 @@ func TestRollingUpgradeForDaemonSetWithSecretUsingArs(t *testing.T) { if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { + t.Errorf("Counter by namespace was not increased") + } } func TestRollingUpgradeForDaemonSetWithSecretInProjectedVolumeUsingArs(t *testing.T) { @@ -1958,6 +2058,10 @@ func TestRollingUpgradeForDaemonSetWithSecretInProjectedVolumeUsingArs(t *testin if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { + t.Errorf("Counter by namespace was not increased") + } } func TestRollingUpgradeForStatefulSetWithConfigmapUsingArs(t *testing.T) { @@ -1983,6 +2087,10 @@ func TestRollingUpgradeForStatefulSetWithConfigmapUsingArs(t *testing.T) { if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { + t.Errorf("Counter by namespace was not increased") + } } func TestRollingUpgradeForStatefulSetWithConfigmapInProjectedVolumeUsingArs(t *testing.T) { @@ -2008,6 +2116,10 @@ func TestRollingUpgradeForStatefulSetWithConfigmapInProjectedVolumeUsingArs(t *t if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { + t.Errorf("Counter by namespace was not increased") + } } func TestRollingUpgradeForStatefulSetWithSecretUsingArs(t *testing.T) { @@ -2033,6 +2145,10 @@ func TestRollingUpgradeForStatefulSetWithSecretUsingArs(t *testing.T) { if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { + t.Errorf("Counter by namespace was not increased") + } } func TestRollingUpgradeForStatefulSetWithSecretInProjectedVolumeUsingArs(t *testing.T) { @@ -2058,6 +2174,10 @@ func TestRollingUpgradeForStatefulSetWithSecretInProjectedVolumeUsingArs(t *test if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { + t.Errorf("Counter by namespace was not increased") + } } func TestRollingUpgradeForDeploymentWithPodAnnotationsUsingArs(t *testing.T) { @@ -2110,6 +2230,10 @@ func TestRollingUpgradeForDeploymentWithPodAnnotationsUsingArs(t *testing.T) { if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { + t.Errorf("Counter by namespace was not increased") + } } func TestFailedRollingUpgradeUsingArs(t *testing.T) { @@ -2128,6 +2252,10 @@ func TestFailedRollingUpgradeUsingArs(t *testing.T) { if promtestutil.ToFloat64(collectors.Reloaded.With(labelFailed)) != 1 { t.Errorf("Counter was not increased") } + + if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "false", "namespace": arsNamespace})) != 1 { + t.Errorf("Counter by namespace was not increased") + } } func TestRollingUpgradeForDeploymentWithConfigmapUsingErs(t *testing.T) { @@ -2153,6 +2281,10 @@ func TestRollingUpgradeForDeploymentWithConfigmapUsingErs(t *testing.T) { if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { + t.Errorf("Counter by namespace was not increased") + } } func TestRollingUpgradeForDeploymentWithConfigmapInProjectedVolumeUsingErs(t *testing.T) { @@ -2177,6 +2309,10 @@ func TestRollingUpgradeForDeploymentWithConfigmapInProjectedVolumeUsingErs(t *te if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { + t.Errorf("Counter by namespace was not increased") + } } func TestRollingUpgradeForDeploymentWithConfigmapViaSearchAnnotationUsingErs(t *testing.T) { @@ -2202,6 +2338,10 @@ func TestRollingUpgradeForDeploymentWithConfigmapViaSearchAnnotationUsingErs(t * if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { + t.Errorf("Counter by namespace was not increased") + } } func TestRollingUpgradeForDeploymentWithConfigmapViaSearchAnnotationNoTriggersUsingErs(t *testing.T) { @@ -2228,6 +2368,10 @@ func TestRollingUpgradeForDeploymentWithConfigmapViaSearchAnnotationNoTriggersUs if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) > 0 { t.Errorf("Counter was increased unexpectedly") } + + if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) > 0 { + t.Errorf("Counter by namespace was increased unexpectedly") + } } func TestRollingUpgradeForDeploymentWithConfigmapViaSearchAnnotationNotMappedUsingErs(t *testing.T) { @@ -2267,6 +2411,10 @@ func TestRollingUpgradeForDeploymentWithConfigmapViaSearchAnnotationNotMappedUsi if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) > 0 { t.Errorf("Counter was increased unexpectedly") } + + if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) > 0 { + t.Errorf("Counter by namespace was increased unexpectedly") + } } func TestRollingUpgradeForDeploymentWithConfigmapInInitContainerUsingErs(t *testing.T) { @@ -2292,6 +2440,10 @@ func TestRollingUpgradeForDeploymentWithConfigmapInInitContainerUsingErs(t *test if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { + t.Errorf("Counter by namespace was not increased") + } } func TestRollingUpgradeForDeploymentWithConfigmapInProjectVolumeInInitContainerUsingErs(t *testing.T) { @@ -2317,6 +2469,10 @@ func TestRollingUpgradeForDeploymentWithConfigmapInProjectVolumeInInitContainerU if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { + t.Errorf("Counter by namespace was not increased") + } } func TestRollingUpgradeForDeploymentWithConfigmapAsEnvVarUsingErs(t *testing.T) { @@ -2342,6 +2498,10 @@ func TestRollingUpgradeForDeploymentWithConfigmapAsEnvVarUsingErs(t *testing.T) if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { + t.Errorf("Counter by namespace was not increased") + } } func TestRollingUpgradeForDeploymentWithConfigmapAsEnvVarInInitContainerUsingErs(t *testing.T) { @@ -2367,6 +2527,10 @@ func TestRollingUpgradeForDeploymentWithConfigmapAsEnvVarInInitContainerUsingErs if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { + t.Errorf("Counter by namespace was not increased") + } } func TestRollingUpgradeForDeploymentWithConfigmapAsEnvVarFromUsingErs(t *testing.T) { @@ -2392,6 +2556,10 @@ func TestRollingUpgradeForDeploymentWithConfigmapAsEnvVarFromUsingErs(t *testing if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { + t.Errorf("Counter by namespace was not increased") + } } func TestRollingUpgradeForDeploymentWithSecretUsingErs(t *testing.T) { @@ -2417,6 +2585,10 @@ func TestRollingUpgradeForDeploymentWithSecretUsingErs(t *testing.T) { if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { + t.Errorf("Counter by namespace was not increased") + } } func TestRollingUpgradeForDeploymentWithSecretInProjectedVolumeUsingErs(t *testing.T) { @@ -2442,6 +2614,10 @@ func TestRollingUpgradeForDeploymentWithSecretInProjectedVolumeUsingErs(t *testi if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { + t.Errorf("Counter by namespace was not increased") + } } func TestRollingUpgradeForDeploymentWithSecretinInitContainerUsingErs(t *testing.T) { @@ -2467,6 +2643,10 @@ func TestRollingUpgradeForDeploymentWithSecretinInitContainerUsingErs(t *testing if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { + t.Errorf("Counter by namespace was not increased") + } } func TestRollingUpgradeForDeploymentWithSecretInProjectedVolumeinInitContainerUsingErs(t *testing.T) { @@ -2492,6 +2672,10 @@ func TestRollingUpgradeForDeploymentWithSecretInProjectedVolumeinInitContainerUs if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { + t.Errorf("Counter by namespace was not increased") + } } func TestRollingUpgradeForDeploymentWithSecretAsEnvVarUsingErs(t *testing.T) { @@ -2517,6 +2701,10 @@ func TestRollingUpgradeForDeploymentWithSecretAsEnvVarUsingErs(t *testing.T) { if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { + t.Errorf("Counter by namespace was not increased") + } } func TestRollingUpgradeForDeploymentWithSecretAsEnvVarFromUsingErs(t *testing.T) { @@ -2542,6 +2730,10 @@ func TestRollingUpgradeForDeploymentWithSecretAsEnvVarFromUsingErs(t *testing.T) if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { + t.Errorf("Counter by namespace was not increased") + } } func TestRollingUpgradeForDeploymentWithSecretAsEnvVarInInitContainerUsingErs(t *testing.T) { @@ -2567,6 +2759,10 @@ func TestRollingUpgradeForDeploymentWithSecretAsEnvVarInInitContainerUsingErs(t if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { + t.Errorf("Counter by namespace was not increased") + } } func TestRollingUpgradeForDeploymentWithSecretAutoAnnotationUsingErs(t *testing.T) { @@ -2592,6 +2788,10 @@ func TestRollingUpgradeForDeploymentWithSecretAutoAnnotationUsingErs(t *testing. if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { + t.Errorf("Counter by namespace was not increased") + } } func TestRollingUpgradeForDeploymentWithConfigMapAutoAnnotationUsingErs(t *testing.T) { @@ -2617,6 +2817,10 @@ func TestRollingUpgradeForDeploymentWithConfigMapAutoAnnotationUsingErs(t *testi if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { + t.Errorf("Counter by namespace was not increased") + } } func TestRollingUpgradeForDaemonSetWithConfigmapUsingErs(t *testing.T) { @@ -2642,6 +2846,10 @@ func TestRollingUpgradeForDaemonSetWithConfigmapUsingErs(t *testing.T) { if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { + t.Errorf("Counter by namespace was not increased") + } } func TestRollingUpgradeForDaemonSetWithConfigmapInProjectedVolumeUsingErs(t *testing.T) { @@ -2667,6 +2875,10 @@ func TestRollingUpgradeForDaemonSetWithConfigmapInProjectedVolumeUsingErs(t *tes if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { + t.Errorf("Counter by namespace was not increased") + } } func TestRollingUpgradeForDaemonSetWithConfigmapAsEnvVarUsingErs(t *testing.T) { @@ -2692,6 +2904,10 @@ func TestRollingUpgradeForDaemonSetWithConfigmapAsEnvVarUsingErs(t *testing.T) { if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { + t.Errorf("Counter by namespace was not increased") + } } func TestRollingUpgradeForDaemonSetWithSecretUsingErs(t *testing.T) { @@ -2717,6 +2933,10 @@ func TestRollingUpgradeForDaemonSetWithSecretUsingErs(t *testing.T) { if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { + t.Errorf("Counter by namespace was not increased") + } } func TestRollingUpgradeForDaemonSetWithSecretInProjectedVolumeUsingErs(t *testing.T) { @@ -2742,6 +2962,10 @@ func TestRollingUpgradeForDaemonSetWithSecretInProjectedVolumeUsingErs(t *testin if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { + t.Errorf("Counter by namespace was not increased") + } } func TestRollingUpgradeForStatefulSetWithConfigmapUsingErs(t *testing.T) { @@ -2767,6 +2991,10 @@ func TestRollingUpgradeForStatefulSetWithConfigmapUsingErs(t *testing.T) { if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { + t.Errorf("Counter by namespace was not increased") + } } func TestRollingUpgradeForStatefulSetWithConfigmapInProjectedVolumeUsingErs(t *testing.T) { @@ -2792,6 +3020,10 @@ func TestRollingUpgradeForStatefulSetWithConfigmapInProjectedVolumeUsingErs(t *t if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { + t.Errorf("Counter by namespace was not increased") + } } func TestRollingUpgradeForStatefulSetWithSecretUsingErs(t *testing.T) { @@ -2817,6 +3049,10 @@ func TestRollingUpgradeForStatefulSetWithSecretUsingErs(t *testing.T) { if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { + t.Errorf("Counter by namespace was not increased") + } } func TestRollingUpgradeForStatefulSetWithSecretInProjectedVolumeUsingErs(t *testing.T) { @@ -2842,6 +3078,10 @@ func TestRollingUpgradeForStatefulSetWithSecretInProjectedVolumeUsingErs(t *test if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { + t.Errorf("Counter by namespace was not increased") + } } func TestRollingUpgradeForDeploymentWithPodAnnotationsUsingErs(t *testing.T) { @@ -2895,6 +3135,10 @@ func TestRollingUpgradeForDeploymentWithPodAnnotationsUsingErs(t *testing.T) { if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { + t.Errorf("Counter by namespace was not increased") + } } func TestFailedRollingUpgradeUsingErs(t *testing.T) { @@ -2913,4 +3157,8 @@ func TestFailedRollingUpgradeUsingErs(t *testing.T) { if promtestutil.ToFloat64(collectors.Reloaded.With(labelFailed)) != 1 { t.Errorf("Counter was not increased") } + + if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "false", "namespace": ersNamespace})) != 1 { + t.Errorf("Counter by namespace was not increased") + } } diff --git a/internal/pkg/metrics/prometheus.go b/internal/pkg/metrics/prometheus.go index 76c3a3b45..94153eace 100644 --- a/internal/pkg/metrics/prometheus.go +++ b/internal/pkg/metrics/prometheus.go @@ -1,13 +1,16 @@ package metrics import ( + "net/http" + "os" + "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promhttp" - "net/http" ) type Collectors struct { - Reloaded *prometheus.CounterVec + Reloaded *prometheus.CounterVec + ReloadedByNamespace *prometheus.CounterVec } func NewCollectors() Collectors { @@ -17,21 +20,40 @@ func NewCollectors() Collectors { Name: "reload_executed_total", Help: "Counter of reloads executed by Reloader.", }, - []string{"success"}, + []string{ + "success", + }, ) //set 0 as default value reloaded.With(prometheus.Labels{"success": "true"}).Add(0) reloaded.With(prometheus.Labels{"success": "false"}).Add(0) + reloaded_by_namespace := prometheus.NewCounterVec( + prometheus.CounterOpts{ + Namespace: "reloader", + Name: "reload_executed_total_by_namespace", + Help: "Counter of reloads executed by Reloader by namespace.", + }, + []string{ + "success", + "namespace", + }, + ) return Collectors{ - Reloaded: reloaded, + Reloaded: reloaded, + ReloadedByNamespace: reloaded_by_namespace, } } func SetupPrometheusEndpoint() Collectors { collectors := NewCollectors() prometheus.MustRegister(collectors.Reloaded) + + if os.Getenv("METRICS_COUNT_BY_NAMESPACE") == "enabled" { + prometheus.MustRegister(collectors.ReloadedByNamespace) + } + http.Handle("/metrics", promhttp.Handler()) return collectors From 6eeba71273648c4571cec01a015ece16b0be4291 Mon Sep 17 00:00:00 2001 From: Alexander Davis Date: Fri, 14 Jun 2024 15:30:30 -0500 Subject: [PATCH 2/5] chore(docs): add information about new opt-in metric --- docs/Verify-Reloader-Working.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/docs/Verify-Reloader-Working.md b/docs/Verify-Reloader-Working.md index d9fff9b2b..859874310 100644 --- a/docs/Verify-Reloader-Working.md +++ b/docs/Verify-Reloader-Working.md @@ -60,3 +60,16 @@ When Reloader is unable to reload, `reloader_reload_executed_total{success="fals reloader_reload_executed_total{success="false"} 15 reloader_reload_executed_total{success="true"} 12 ``` + +### Opt-in Granular Metrics + +Reloader can also export a metric to show the number of reloads by namespace. This feature is disabled by default, as it can lead to high cardinality in clusters with many namespaces. + +The metric will have both `success` and `namespace` as attributes: + +```text +reloader_reload_executed_total{success="false", namespace="some-namespace"} 2 +reloader_reload_executed_total{success="true", namespace="some-namespace"} 1 +``` + +To opt-in, set the environment variable `METRICS_COUNT_BY_NAMESPACE` to `enabled` or set the Helm value `reloader.enableMetricsByNamespace` to `true`. From 220a9d5f68ea6517c94597372471e56e1b81079b Mon Sep 17 00:00:00 2001 From: Alexander Davis Date: Fri, 14 Jun 2024 15:49:22 -0500 Subject: [PATCH 3/5] fix: wrong conditional on new metric test --- internal/pkg/handler/upgrade_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/pkg/handler/upgrade_test.go b/internal/pkg/handler/upgrade_test.go index ac521c36e..8aad6cf1d 100644 --- a/internal/pkg/handler/upgrade_test.go +++ b/internal/pkg/handler/upgrade_test.go @@ -1465,7 +1465,7 @@ func TestRollingUpgradeForDeploymentWithConfigmapViaSearchAnnotationNoTriggersUs t.Errorf("Counter was increased unexpectedly") } - if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) > 1 { + if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) > 0 { t.Errorf("Counter by namespace was increased unexpectedly") } } @@ -1508,7 +1508,7 @@ func TestRollingUpgradeForDeploymentWithConfigmapViaSearchAnnotationNotMappedUsi t.Errorf("Counter was increased unexpectedly") } - if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) > 1 { + if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) > 0 { t.Errorf("Counter by namespace was increased unexpectedly") } } From 09d90532e652fa83926625ced80d703f70e32c17 Mon Sep 17 00:00:00 2001 From: Alexander Davis Date: Fri, 14 Jun 2024 15:54:55 -0500 Subject: [PATCH 4/5] chore(docs): apply reviewdog grammar suggestion --- docs/Verify-Reloader-Working.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/Verify-Reloader-Working.md b/docs/Verify-Reloader-Working.md index 859874310..f9d653ad9 100644 --- a/docs/Verify-Reloader-Working.md +++ b/docs/Verify-Reloader-Working.md @@ -61,7 +61,7 @@ reloader_reload_executed_total{success="false"} 15 reloader_reload_executed_total{success="true"} 12 ``` -### Opt-in Granular Metrics +### Reloads by Namespace Reloader can also export a metric to show the number of reloads by namespace. This feature is disabled by default, as it can lead to high cardinality in clusters with many namespaces. @@ -72,4 +72,4 @@ reloader_reload_executed_total{success="false", namespace="some-namespace"} 2 reloader_reload_executed_total{success="true", namespace="some-namespace"} 1 ``` -To opt-in, set the environment variable `METRICS_COUNT_BY_NAMESPACE` to `enabled` or set the Helm value `reloader.enableMetricsByNamespace` to `true`. +To opt in, set the environment variable `METRICS_COUNT_BY_NAMESPACE` to `enabled` or set the Helm value `reloader.enableMetricsByNamespace` to `true`. From 6cd458b8ed055e97c4f8e61fc96cc8d4fcae200c Mon Sep 17 00:00:00 2001 From: Alexander Davis Date: Fri, 14 Jun 2024 16:24:09 -0500 Subject: [PATCH 5/5] chore(tests): fix ReloadedByNamespace tests --- internal/pkg/handler/upgrade_test.go | 124 +++++++++++++-------------- 1 file changed, 62 insertions(+), 62 deletions(-) diff --git a/internal/pkg/handler/upgrade_test.go b/internal/pkg/handler/upgrade_test.go index 8aad6cf1d..f6f5fbb1b 100644 --- a/internal/pkg/handler/upgrade_test.go +++ b/internal/pkg/handler/upgrade_test.go @@ -1318,7 +1318,7 @@ func TestRollingUpgradeForDeploymentWithConfigmapUsingArs(t *testing.T) { t.Errorf("Counter was not increased") } - if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { + if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { t.Errorf("Counter by namespace was not increased") } } @@ -1347,7 +1347,7 @@ func TestRollingUpgradeForDeploymentWithConfigmapWithoutReloadAnnotationAndWitho t.Errorf("Counter was increased unexpectedly") } - if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) > 0 { + if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) > 0 { t.Errorf("Counter by namespace was increased unexpectedly") } } @@ -1378,7 +1378,7 @@ func TestRollingUpgradeForDeploymentWithConfigmapWithoutReloadAnnotationButWithA t.Errorf("Counter was not increased") } - if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { + if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { t.Errorf("Counter by namespace was not increased") } } @@ -1406,7 +1406,7 @@ func TestRollingUpgradeForDeploymentWithConfigmapInProjectedVolumeUsingArs(t *te t.Errorf("Counter was not increased") } - if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { + if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { t.Errorf("Counter by namespace was not increased") } } @@ -1435,7 +1435,7 @@ func TestRollingUpgradeForDeploymentWithConfigmapViaSearchAnnotationUsingArs(t * t.Errorf("Counter was not increased") } - if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { + if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { t.Errorf("Counter by namespace was not increased") } } @@ -1465,7 +1465,7 @@ func TestRollingUpgradeForDeploymentWithConfigmapViaSearchAnnotationNoTriggersUs t.Errorf("Counter was increased unexpectedly") } - if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) > 0 { + if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) > 0 { t.Errorf("Counter by namespace was increased unexpectedly") } } @@ -1508,7 +1508,7 @@ func TestRollingUpgradeForDeploymentWithConfigmapViaSearchAnnotationNotMappedUsi t.Errorf("Counter was increased unexpectedly") } - if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) > 0 { + if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) > 0 { t.Errorf("Counter by namespace was increased unexpectedly") } } @@ -1537,7 +1537,7 @@ func TestRollingUpgradeForDeploymentWithConfigmapInInitContainerUsingArs(t *test t.Errorf("Counter was not increased") } - if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { + if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { t.Errorf("Counter by namespace was not increased") } } @@ -1566,7 +1566,7 @@ func TestRollingUpgradeForDeploymentWithConfigmapInProjectVolumeInInitContainerU t.Errorf("Counter was not increased") } - if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { + if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { t.Errorf("Counter by namespace was not increased") } } @@ -1595,7 +1595,7 @@ func TestRollingUpgradeForDeploymentWithConfigmapAsEnvVarUsingArs(t *testing.T) t.Errorf("Counter was not increased") } - if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { + if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { t.Errorf("Counter by namespace was not increased") } } @@ -1624,7 +1624,7 @@ func TestRollingUpgradeForDeploymentWithConfigmapAsEnvVarInInitContainerUsingArs t.Errorf("Counter was not increased") } - if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { + if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { t.Errorf("Counter by namespace was not increased") } } @@ -1653,7 +1653,7 @@ func TestRollingUpgradeForDeploymentWithConfigmapAsEnvVarFromUsingArs(t *testing t.Errorf("Counter was not increased") } - if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { + if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { t.Errorf("Counter by namespace was not increased") } } @@ -1682,7 +1682,7 @@ func TestRollingUpgradeForDeploymentWithSecretUsingArs(t *testing.T) { t.Errorf("Counter was not increased") } - if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { + if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { t.Errorf("Counter by namespace was not increased") } } @@ -1711,7 +1711,7 @@ func TestRollingUpgradeForDeploymentWithSecretInProjectedVolumeUsingArs(t *testi t.Errorf("Counter was not increased") } - if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { + if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { t.Errorf("Counter by namespace was not increased") } } @@ -1740,7 +1740,7 @@ func TestRollingUpgradeForDeploymentWithSecretinInitContainerUsingArs(t *testing t.Errorf("Counter was not increased") } - if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { + if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { t.Errorf("Counter by namespace was not increased") } } @@ -1769,7 +1769,7 @@ func TestRollingUpgradeForDeploymentWithSecretInProjectedVolumeinInitContainerUs t.Errorf("Counter was not increased") } - if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { + if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { t.Errorf("Counter by namespace was not increased") } } @@ -1798,7 +1798,7 @@ func TestRollingUpgradeForDeploymentWithSecretAsEnvVarUsingArs(t *testing.T) { t.Errorf("Counter was not increased") } - if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { + if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { t.Errorf("Counter by namespace was not increased") } } @@ -1827,7 +1827,7 @@ func TestRollingUpgradeForDeploymentWithSecretAsEnvVarFromUsingArs(t *testing.T) t.Errorf("Counter was not increased") } - if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { + if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { t.Errorf("Counter by namespace was not increased") } } @@ -1856,7 +1856,7 @@ func TestRollingUpgradeForDeploymentWithSecretAsEnvVarInInitContainerUsingArs(t t.Errorf("Counter was not increased") } - if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { + if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { t.Errorf("Counter by namespace was not increased") } } @@ -1885,7 +1885,7 @@ func TestRollingUpgradeForDeploymentWithSecretAutoAnnotationUsingArs(t *testing. t.Errorf("Counter was not increased") } - if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { + if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { t.Errorf("Counter by namespace was not increased") } } @@ -1914,7 +1914,7 @@ func TestRollingUpgradeForDeploymentWithConfigMapAutoAnnotationUsingArs(t *testi t.Errorf("Counter was not increased") } - if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { + if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { t.Errorf("Counter by namespace was not increased") } } @@ -1943,7 +1943,7 @@ func TestRollingUpgradeForDaemonSetWithConfigmapUsingArs(t *testing.T) { t.Errorf("Counter was not increased") } - if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { + if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { t.Errorf("Counter by namespace was not increased") } } @@ -1972,7 +1972,7 @@ func TestRollingUpgradeForDaemonSetWithConfigmapInProjectedVolumeUsingArs(t *tes t.Errorf("Counter was not increased") } - if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { + if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { t.Errorf("Counter by namespace was not increased") } } @@ -2001,7 +2001,7 @@ func TestRollingUpgradeForDaemonSetWithConfigmapAsEnvVarUsingArs(t *testing.T) { t.Errorf("Counter was not increased") } - if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { + if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { t.Errorf("Counter by namespace was not increased") } } @@ -2030,7 +2030,7 @@ func TestRollingUpgradeForDaemonSetWithSecretUsingArs(t *testing.T) { t.Errorf("Counter was not increased") } - if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { + if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { t.Errorf("Counter by namespace was not increased") } } @@ -2059,7 +2059,7 @@ func TestRollingUpgradeForDaemonSetWithSecretInProjectedVolumeUsingArs(t *testin t.Errorf("Counter was not increased") } - if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { + if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { t.Errorf("Counter by namespace was not increased") } } @@ -2088,7 +2088,7 @@ func TestRollingUpgradeForStatefulSetWithConfigmapUsingArs(t *testing.T) { t.Errorf("Counter was not increased") } - if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { + if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { t.Errorf("Counter by namespace was not increased") } } @@ -2117,7 +2117,7 @@ func TestRollingUpgradeForStatefulSetWithConfigmapInProjectedVolumeUsingArs(t *t t.Errorf("Counter was not increased") } - if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { + if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { t.Errorf("Counter by namespace was not increased") } } @@ -2146,7 +2146,7 @@ func TestRollingUpgradeForStatefulSetWithSecretUsingArs(t *testing.T) { t.Errorf("Counter was not increased") } - if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { + if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { t.Errorf("Counter by namespace was not increased") } } @@ -2175,7 +2175,7 @@ func TestRollingUpgradeForStatefulSetWithSecretInProjectedVolumeUsingArs(t *test t.Errorf("Counter was not increased") } - if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { + if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { t.Errorf("Counter by namespace was not increased") } } @@ -2231,7 +2231,7 @@ func TestRollingUpgradeForDeploymentWithPodAnnotationsUsingArs(t *testing.T) { t.Errorf("Counter was not increased") } - if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { + if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "true", "namespace": arsNamespace})) != 1 { t.Errorf("Counter by namespace was not increased") } } @@ -2253,7 +2253,7 @@ func TestFailedRollingUpgradeUsingArs(t *testing.T) { t.Errorf("Counter was not increased") } - if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "false", "namespace": arsNamespace})) != 1 { + if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "false", "namespace": arsNamespace})) != 1 { t.Errorf("Counter by namespace was not increased") } } @@ -2282,7 +2282,7 @@ func TestRollingUpgradeForDeploymentWithConfigmapUsingErs(t *testing.T) { t.Errorf("Counter was not increased") } - if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { + if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { t.Errorf("Counter by namespace was not increased") } } @@ -2310,7 +2310,7 @@ func TestRollingUpgradeForDeploymentWithConfigmapInProjectedVolumeUsingErs(t *te t.Errorf("Counter was not increased") } - if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { + if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { t.Errorf("Counter by namespace was not increased") } } @@ -2339,7 +2339,7 @@ func TestRollingUpgradeForDeploymentWithConfigmapViaSearchAnnotationUsingErs(t * t.Errorf("Counter was not increased") } - if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { + if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { t.Errorf("Counter by namespace was not increased") } } @@ -2369,7 +2369,7 @@ func TestRollingUpgradeForDeploymentWithConfigmapViaSearchAnnotationNoTriggersUs t.Errorf("Counter was increased unexpectedly") } - if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) > 0 { + if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) > 0 { t.Errorf("Counter by namespace was increased unexpectedly") } } @@ -2412,7 +2412,7 @@ func TestRollingUpgradeForDeploymentWithConfigmapViaSearchAnnotationNotMappedUsi t.Errorf("Counter was increased unexpectedly") } - if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) > 0 { + if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) > 0 { t.Errorf("Counter by namespace was increased unexpectedly") } } @@ -2441,7 +2441,7 @@ func TestRollingUpgradeForDeploymentWithConfigmapInInitContainerUsingErs(t *test t.Errorf("Counter was not increased") } - if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { + if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { t.Errorf("Counter by namespace was not increased") } } @@ -2470,7 +2470,7 @@ func TestRollingUpgradeForDeploymentWithConfigmapInProjectVolumeInInitContainerU t.Errorf("Counter was not increased") } - if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { + if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { t.Errorf("Counter by namespace was not increased") } } @@ -2499,7 +2499,7 @@ func TestRollingUpgradeForDeploymentWithConfigmapAsEnvVarUsingErs(t *testing.T) t.Errorf("Counter was not increased") } - if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { + if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { t.Errorf("Counter by namespace was not increased") } } @@ -2528,7 +2528,7 @@ func TestRollingUpgradeForDeploymentWithConfigmapAsEnvVarInInitContainerUsingErs t.Errorf("Counter was not increased") } - if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { + if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { t.Errorf("Counter by namespace was not increased") } } @@ -2557,7 +2557,7 @@ func TestRollingUpgradeForDeploymentWithConfigmapAsEnvVarFromUsingErs(t *testing t.Errorf("Counter was not increased") } - if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { + if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { t.Errorf("Counter by namespace was not increased") } } @@ -2586,7 +2586,7 @@ func TestRollingUpgradeForDeploymentWithSecretUsingErs(t *testing.T) { t.Errorf("Counter was not increased") } - if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { + if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { t.Errorf("Counter by namespace was not increased") } } @@ -2615,7 +2615,7 @@ func TestRollingUpgradeForDeploymentWithSecretInProjectedVolumeUsingErs(t *testi t.Errorf("Counter was not increased") } - if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { + if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { t.Errorf("Counter by namespace was not increased") } } @@ -2644,7 +2644,7 @@ func TestRollingUpgradeForDeploymentWithSecretinInitContainerUsingErs(t *testing t.Errorf("Counter was not increased") } - if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { + if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { t.Errorf("Counter by namespace was not increased") } } @@ -2673,7 +2673,7 @@ func TestRollingUpgradeForDeploymentWithSecretInProjectedVolumeinInitContainerUs t.Errorf("Counter was not increased") } - if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { + if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { t.Errorf("Counter by namespace was not increased") } } @@ -2702,7 +2702,7 @@ func TestRollingUpgradeForDeploymentWithSecretAsEnvVarUsingErs(t *testing.T) { t.Errorf("Counter was not increased") } - if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { + if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { t.Errorf("Counter by namespace was not increased") } } @@ -2731,7 +2731,7 @@ func TestRollingUpgradeForDeploymentWithSecretAsEnvVarFromUsingErs(t *testing.T) t.Errorf("Counter was not increased") } - if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { + if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { t.Errorf("Counter by namespace was not increased") } } @@ -2760,7 +2760,7 @@ func TestRollingUpgradeForDeploymentWithSecretAsEnvVarInInitContainerUsingErs(t t.Errorf("Counter was not increased") } - if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { + if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { t.Errorf("Counter by namespace was not increased") } } @@ -2789,7 +2789,7 @@ func TestRollingUpgradeForDeploymentWithSecretAutoAnnotationUsingErs(t *testing. t.Errorf("Counter was not increased") } - if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { + if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { t.Errorf("Counter by namespace was not increased") } } @@ -2818,7 +2818,7 @@ func TestRollingUpgradeForDeploymentWithConfigMapAutoAnnotationUsingErs(t *testi t.Errorf("Counter was not increased") } - if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { + if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { t.Errorf("Counter by namespace was not increased") } } @@ -2847,7 +2847,7 @@ func TestRollingUpgradeForDaemonSetWithConfigmapUsingErs(t *testing.T) { t.Errorf("Counter was not increased") } - if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { + if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { t.Errorf("Counter by namespace was not increased") } } @@ -2876,7 +2876,7 @@ func TestRollingUpgradeForDaemonSetWithConfigmapInProjectedVolumeUsingErs(t *tes t.Errorf("Counter was not increased") } - if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { + if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { t.Errorf("Counter by namespace was not increased") } } @@ -2905,7 +2905,7 @@ func TestRollingUpgradeForDaemonSetWithConfigmapAsEnvVarUsingErs(t *testing.T) { t.Errorf("Counter was not increased") } - if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { + if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { t.Errorf("Counter by namespace was not increased") } } @@ -2934,7 +2934,7 @@ func TestRollingUpgradeForDaemonSetWithSecretUsingErs(t *testing.T) { t.Errorf("Counter was not increased") } - if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { + if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { t.Errorf("Counter by namespace was not increased") } } @@ -2963,7 +2963,7 @@ func TestRollingUpgradeForDaemonSetWithSecretInProjectedVolumeUsingErs(t *testin t.Errorf("Counter was not increased") } - if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { + if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { t.Errorf("Counter by namespace was not increased") } } @@ -2992,7 +2992,7 @@ func TestRollingUpgradeForStatefulSetWithConfigmapUsingErs(t *testing.T) { t.Errorf("Counter was not increased") } - if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { + if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { t.Errorf("Counter by namespace was not increased") } } @@ -3021,7 +3021,7 @@ func TestRollingUpgradeForStatefulSetWithConfigmapInProjectedVolumeUsingErs(t *t t.Errorf("Counter was not increased") } - if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { + if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { t.Errorf("Counter by namespace was not increased") } } @@ -3050,7 +3050,7 @@ func TestRollingUpgradeForStatefulSetWithSecretUsingErs(t *testing.T) { t.Errorf("Counter was not increased") } - if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { + if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { t.Errorf("Counter by namespace was not increased") } } @@ -3079,7 +3079,7 @@ func TestRollingUpgradeForStatefulSetWithSecretInProjectedVolumeUsingErs(t *test t.Errorf("Counter was not increased") } - if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { + if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { t.Errorf("Counter by namespace was not increased") } } @@ -3136,7 +3136,7 @@ func TestRollingUpgradeForDeploymentWithPodAnnotationsUsingErs(t *testing.T) { t.Errorf("Counter was not increased") } - if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { + if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "true", "namespace": ersNamespace})) != 1 { t.Errorf("Counter by namespace was not increased") } } @@ -3158,7 +3158,7 @@ func TestFailedRollingUpgradeUsingErs(t *testing.T) { t.Errorf("Counter was not increased") } - if promtestutil.ToFloat64(collectors.Reloaded.With(prometheus.Labels{"success": "false", "namespace": ersNamespace})) != 1 { + if promtestutil.ToFloat64(collectors.ReloadedByNamespace.With(prometheus.Labels{"success": "false", "namespace": ersNamespace})) != 1 { t.Errorf("Counter by namespace was not increased") } }