From 5d6309b941e6fe62216e1d853df5fc778b7bcc74 Mon Sep 17 00:00:00 2001 From: Jean-Francois Roy Date: Tue, 11 Jun 2024 11:36:53 -0700 Subject: [PATCH 01/29] fix: replace + with _ in Chart.Version When using Flux with the OCI chart, the chart version has a git hash suffix (ex: 1.0.107+20eb5010550b), which is invalid as a metadata label. --- deployments/kubernetes/chart/reloader/templates/_helpers.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployments/kubernetes/chart/reloader/templates/_helpers.tpl b/deployments/kubernetes/chart/reloader/templates/_helpers.tpl index 9edf6cad..04b3ee4d 100644 --- a/deployments/kubernetes/chart/reloader/templates/_helpers.tpl +++ b/deployments/kubernetes/chart/reloader/templates/_helpers.tpl @@ -22,7 +22,7 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this {{- define "reloader-labels.chart" -}} app: {{ template "reloader-fullname" . }} -chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" +chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" release: {{ .Release.Name | quote }} heritage: {{ .Release.Service | quote }} app.kubernetes.io/managed-by: {{ .Release.Service | quote }} From 3f6e98a9d57394b20513e5efdcab6aac37f29891 Mon Sep 17 00:00:00 2001 From: Alexander Davis Date: Fri, 14 Jun 2024 15:20:38 -0500 Subject: [PATCH 02/29] 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 7c4a3edb..763eb554 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 6d38fd35..dca67507 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 eed307c4..8094747a 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 bb34027e..6099983e 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 cf070a83..05fc0c0e 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 907aa687..ac521c36 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 76c3a3b4..94153eac 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 03/29] 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 d9fff9b2..85987431 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 04/29] 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 ac521c36..8aad6cf1 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 05/29] 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 85987431..f9d653ad 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 06/29] 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 8aad6cf1..f6f5fbb1 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") } } From 3848e031c258edcfbee005c6c9766800e3c46669 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 15 Jun 2024 00:04:07 +0000 Subject: [PATCH 07/29] fix(deps): update module github.com/spf13/cobra to v1.8.1 --- go.mod | 2 +- go.sum | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index d4d696ef..5055086f 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/parnurzeal/gorequest v0.2.16 github.com/prometheus/client_golang v1.19.1 github.com/sirupsen/logrus v1.9.3 - github.com/spf13/cobra v1.8.0 + github.com/spf13/cobra v1.8.1 k8s.io/api v0.28.4 k8s.io/apimachinery v0.28.4 k8s.io/client-go v0.28.4 diff --git a/go.sum b/go.sum index 3a60a5ad..a9d3b0e2 100644 --- a/go.sum +++ b/go.sum @@ -5,6 +5,7 @@ github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6r github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -111,6 +112,8 @@ github.com/smartystreets/goconvey v1.7.2 h1:9RBaZCeXEQ3UselpuwUQHltGVXvdwm6cv1hg github.com/smartystreets/goconvey v1.7.2/go.mod h1:Vw0tHAZW6lzCRk3xgdin6fKYcG+G3Pg9vgXWeJpQFMM= github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0= github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho= +github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM= +github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= From 2260d728737bb016824fd66c4608c018d80044b5 Mon Sep 17 00:00:00 2001 From: deschmih Date: Tue, 18 Jun 2024 09:57:56 +0200 Subject: [PATCH 08/29] feature reload-on-delete implemented, test cases enhanced --- README.md | 7 +- .../chart/reloader/templates/deployment.yaml | 5 +- .../kubernetes/chart/reloader/values.yaml | 1 + internal/pkg/cmd/reloader.go | 1 + internal/pkg/controller/controller.go | 13 +- internal/pkg/handler/create.go | 2 +- internal/pkg/handler/delete.go | 92 +++ internal/pkg/handler/update.go | 2 +- internal/pkg/handler/upgrade.go | 48 +- internal/pkg/handler/upgrade_test.go | 529 ++++++++++++------ internal/pkg/options/flags.go | 4 +- internal/pkg/testutil/kube.go | 53 ++ 12 files changed, 568 insertions(+), 189 deletions(-) create mode 100644 internal/pkg/handler/delete.go diff --git a/README.md b/README.md index 7c4a3edb..2312147a 100644 --- a/README.md +++ b/README.md @@ -317,6 +317,7 @@ helm uninstall {{RELEASE_NAME}} -n {{NAMESPACE}} | `reloader.ignoreSecrets` | To ignore secrets. Valid value are either `true` or `false`. Either `ignoreSecrets` or `ignoreConfigMaps` can be ignored, not both at the same time | boolean | `false` | | `reloader.ignoreConfigMaps` | To ignore configMaps. Valid value are either `true` or `false` | boolean | `false` | | `reloader.reloadOnCreate` | Enable reload on create events. Valid value are either `true` or `false` | boolean | `false` | +| `reloader.reloadOnDelete` | Enable reload on delete events. Valid value are either `true` or `false` | boolean | `false` | | `reloader.syncAfterRestart` | Enable sync after Reloader restarts for **Add** events, works only when reloadOnCreate is `true`. Valid value are either `true` or `false` | boolean | `false` | | `reloader.reloadStrategy` | Strategy to trigger resource restart, set to either `default`, `env-vars` or `annotations` | enumeration | `default` | | `reloader.ignoreNamespaces` | List of comma separated namespaces to ignore, if multiple are provided, they are combined with the AND operator | string | `""` | @@ -377,11 +378,15 @@ helm uninstall {{RELEASE_NAME}} -n {{NAMESPACE}} 1. Configmaps/secrets being added to the cache will cause Reloader to perform a rolling update of the associated workload 1. When applications are deployed for the first time, Reloader will perform a rolling update of the associated workload 1. If you are running Reloader in HA mode all workloads will have a rolling update performed when a new leader is elected +- `reloadOnDelete` controls how Reloader handles secrets being deleted. If `reloadOnDelete` is set to true: + 1. Configmaps/secrets being deleted will cause Reloader to perform a rolling update of the associated workload - `serviceMonitor` will be removed in future releases of Reloader in favour of Pod monitor - If `reloadOnCreate` is set to false: 1. Updates to configmaps/secrets that occur while there is no leader will not be picked up by the new leader until a subsequent update of the configmap/secret occurs 1. In the worst case the window in which there can be no leader is 15s as this is the LeaseDuration -- By default, `reloadOnCreate` and `syncAfterRestart` are both set to false. Both need to be enabled explicitly +- If `reloadOnDelete` is set to false: + 1. Deleting of configmaps/secrets has no effect to pods that references these resources. +- By default, `reloadOnCreate`, `reloadOnDelete` and `syncAfterRestart` are all set to false. All need to be enabled explicitly ## Help diff --git a/deployments/kubernetes/chart/reloader/templates/deployment.yaml b/deployments/kubernetes/chart/reloader/templates/deployment.yaml index 6d38fd35..2178a207 100644 --- a/deployments/kubernetes/chart/reloader/templates/deployment.yaml +++ b/deployments/kubernetes/chart/reloader/templates/deployment.yaml @@ -171,7 +171,7 @@ spec: {{- . | toYaml | nindent 10 }} {{- end }} {{- end }} - {{- if or (.Values.reloader.logFormat) (.Values.reloader.ignoreSecrets) (.Values.reloader.ignoreNamespaces) (.Values.reloader.namespaceSelector) (.Values.reloader.resourceLabelSelector) (.Values.reloader.ignoreConfigMaps) (.Values.reloader.custom_annotations) (eq .Values.reloader.isArgoRollouts true) (eq .Values.reloader.reloadOnCreate true) (ne .Values.reloader.reloadStrategy "default") (.Values.reloader.enableHA) (.Values.reloader.autoReloadAll)}} + {{- if or (.Values.reloader.logFormat) (.Values.reloader.ignoreSecrets) (.Values.reloader.ignoreNamespaces) (.Values.reloader.namespaceSelector) (.Values.reloader.resourceLabelSelector) (.Values.reloader.ignoreConfigMaps) (.Values.reloader.custom_annotations) (eq .Values.reloader.isArgoRollouts true) (eq .Values.reloader.reloadOnCreate true) (eq .Values.reloader.reloadOnDelete true) (ne .Values.reloader.reloadStrategy "default") (.Values.reloader.enableHA) (.Values.reloader.autoReloadAll)}} args: {{- if .Values.reloader.logFormat }} - "--log-format={{ .Values.reloader.logFormat }}" @@ -231,6 +231,9 @@ spec: {{- if eq .Values.reloader.reloadOnCreate true }} - "--reload-on-create={{ .Values.reloader.reloadOnCreate }}" {{- end }} + {{- if eq .Values.reloader.reloadOnDelete true }} + - "--reload-on-delete={{ .Values.reloader.reloadOnDelete }}" + {{- end }} {{- if eq .Values.reloader.syncAfterRestart true }} - "--sync-after-restart={{ .Values.reloader.syncAfterRestart }}" {{- end }} diff --git a/deployments/kubernetes/chart/reloader/values.yaml b/deployments/kubernetes/chart/reloader/values.yaml index eed307c4..cd7c0121 100644 --- a/deployments/kubernetes/chart/reloader/values.yaml +++ b/deployments/kubernetes/chart/reloader/values.yaml @@ -18,6 +18,7 @@ reloader: ignoreSecrets: false ignoreConfigMaps: false reloadOnCreate: false + reloadOnDelete: false syncAfterRestart: false reloadStrategy: default # Set to default, env-vars or annotations ignoreNamespaces: "" # Comma separated list of namespaces to ignore diff --git a/internal/pkg/cmd/reloader.go b/internal/pkg/cmd/reloader.go index 54d52cb9..f0aac834 100644 --- a/internal/pkg/cmd/reloader.go +++ b/internal/pkg/cmd/reloader.go @@ -51,6 +51,7 @@ func NewReloaderCommand() *cobra.Command { cmd.PersistentFlags().StringVar(&options.IsArgoRollouts, "is-Argo-Rollouts", "false", "Add support for argo rollouts") cmd.PersistentFlags().StringVar(&options.ReloadStrategy, constants.ReloadStrategyFlag, constants.EnvVarsReloadStrategy, "Specifies the desired reload strategy") cmd.PersistentFlags().StringVar(&options.ReloadOnCreate, "reload-on-create", "false", "Add support to watch create events") + cmd.PersistentFlags().StringVar(&options.ReloadOnDelete, "reload-on-delete", "false", "Add support to watch delete events") cmd.PersistentFlags().BoolVar(&options.EnableHA, "enable-ha", false, "Adds support for running multiple replicas via leadership election") cmd.PersistentFlags().BoolVar(&options.SyncAfterRestart, "sync-after-restart", false, "Sync add events after reloader restarts") diff --git a/internal/pkg/controller/controller.go b/internal/pkg/controller/controller.go index 1b380ecd..bffc48a5 100644 --- a/internal/pkg/controller/controller.go +++ b/internal/pkg/controller/controller.go @@ -178,13 +178,22 @@ func (c *Controller) Update(old interface{}, new interface{}) { // Delete function to add an object to the queue in case of deleting a resource func (c *Controller) Delete(old interface{}) { + + if options.ReloadOnDelete == "true" { + if !c.resourceInIgnoredNamespace(old) && c.resourceInSelectedNamespaces(old) && secretControllerInitialized && configmapControllerInitialized { + c.queue.Add(handler.ResourceDeleteHandler{ + Resource: old, + Collectors: c.collectors, + Recorder: c.recorder, + }) + } + } + switch object := old.(type) { case *v1.Namespace: c.removeSelectedNamespaceFromCache(*object) return } - - // Todo: Any future delete event can be handled here } // Run function for controller which handles the queue diff --git a/internal/pkg/handler/create.go b/internal/pkg/handler/create.go index 6c869c3c..a35da5e7 100644 --- a/internal/pkg/handler/create.go +++ b/internal/pkg/handler/create.go @@ -27,7 +27,7 @@ func (r ResourceCreatedHandler) Handle() error { return sendUpgradeWebhook(config, options.WebhookUrl) } // process resource based on its type - return doRollingUpgrade(config, r.Collectors, r.Recorder) + return doRollingUpgrade(config, r.Collectors, r.Recorder, invokeReloadStrategy) } return nil } diff --git a/internal/pkg/handler/delete.go b/internal/pkg/handler/delete.go new file mode 100644 index 00000000..2378d0fb --- /dev/null +++ b/internal/pkg/handler/delete.go @@ -0,0 +1,92 @@ +package handler + +import ( + "github.com/sirupsen/logrus" + "github.com/stakater/Reloader/internal/pkg/callbacks" + "github.com/stakater/Reloader/internal/pkg/constants" + "github.com/stakater/Reloader/internal/pkg/metrics" + "github.com/stakater/Reloader/internal/pkg/options" + "github.com/stakater/Reloader/internal/pkg/testutil" + "github.com/stakater/Reloader/internal/pkg/util" + v1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/client-go/tools/record" +) + +// ResourceDeleteHandler contains new objects +type ResourceDeleteHandler struct { + Resource interface{} + Collectors metrics.Collectors + Recorder record.EventRecorder +} + +// Handle processes resources being deleted +func (r ResourceDeleteHandler) Handle() error { + if r.Resource == nil { + logrus.Errorf("Resource delete handler received nil resource") + } else { + config, _ := r.GetConfig() + // Send webhook + if options.WebhookUrl != "" { + return sendUpgradeWebhook(config, options.WebhookUrl) + } + // process resource based on its type + return doRollingUpgrade(config, r.Collectors, r.Recorder, invokeDeleteStrategy) + } + return nil +} + +// GetConfig gets configurations containing SHA, annotations, namespace and resource name +func (r ResourceDeleteHandler) GetConfig() (util.Config, string) { + var oldSHAData string + var config util.Config + if _, ok := r.Resource.(*v1.ConfigMap); ok { + config = util.GetConfigmapConfig(r.Resource.(*v1.ConfigMap)) + } else if _, ok := r.Resource.(*v1.Secret); ok { + config = util.GetSecretConfig(r.Resource.(*v1.Secret)) + } else { + logrus.Warnf("Invalid resource: Resource should be 'Secret' or 'Configmap' but found, %v", r.Resource) + } + return config, oldSHAData +} + +func invokeDeleteStrategy(upgradeFuncs callbacks.RollingUpgradeFuncs, item runtime.Object, config util.Config, autoReload bool) constants.Result { + if options.ReloadStrategy == constants.AnnotationsReloadStrategy { + return removePodAnnotations(upgradeFuncs, item, config, autoReload) + } + + return removeContainerEnvVars(upgradeFuncs, item, config, autoReload) +} + +func removePodAnnotations(upgradeFuncs callbacks.RollingUpgradeFuncs, item runtime.Object, config util.Config, autoReload bool) constants.Result { + config.SHAValue = testutil.GetSHAfromEmptyData() + return updatePodAnnotations(upgradeFuncs, item, config, autoReload) +} + +func removeContainerEnvVars(upgradeFuncs callbacks.RollingUpgradeFuncs, item runtime.Object, config util.Config, autoReload bool) constants.Result { + envVar := getEnvVarName(config.ResourceName, config.Type) + container := getContainerUsingResource(upgradeFuncs, item, config, autoReload) + + if container == nil { + return constants.NoContainerFound + } + + //remove if env var exists + containers := upgradeFuncs.ContainersFunc(item) + for i := range containers { + envs := containers[i].Env + index := -1 + for j := range envs { + if envs[j].Name == envVar { + index = j + break + } + } + if index != -1 { + containers[i].Env = append(containers[i].Env[:index], containers[i].Env[index+1:]...) + return constants.Updated + } + } + + return constants.NotUpdated +} diff --git a/internal/pkg/handler/update.go b/internal/pkg/handler/update.go index edb2556d..0575e190 100644 --- a/internal/pkg/handler/update.go +++ b/internal/pkg/handler/update.go @@ -29,7 +29,7 @@ func (r ResourceUpdatedHandler) Handle() error { return sendUpgradeWebhook(config, options.WebhookUrl) } // process resource based on its type - return doRollingUpgrade(config, r.Collectors, r.Recorder) + return doRollingUpgrade(config, r.Collectors, r.Recorder, invokeReloadStrategy) } } return nil diff --git a/internal/pkg/handler/upgrade.go b/internal/pkg/handler/upgrade.go index cf070a83..0d8b1fff 100644 --- a/internal/pkg/handler/upgrade.go +++ b/internal/pkg/handler/upgrade.go @@ -142,35 +142,35 @@ func sendWebhook(url string) (string, []error) { return buffer.String(), nil } -func doRollingUpgrade(config util.Config, collectors metrics.Collectors, recorder record.EventRecorder) error { +func doRollingUpgrade(config util.Config, collectors metrics.Collectors, recorder record.EventRecorder, invoke invokeStrategy) error { clients := kube.GetClients() - err := rollingUpgrade(clients, config, GetDeploymentRollingUpgradeFuncs(), collectors, recorder) + err := rollingUpgrade(clients, config, GetDeploymentRollingUpgradeFuncs(), collectors, recorder, invoke) if err != nil { return err } - err = rollingUpgrade(clients, config, GetCronJobCreateJobFuncs(), collectors, recorder) + err = rollingUpgrade(clients, config, GetCronJobCreateJobFuncs(), collectors, recorder, invoke) if err != nil { return err } - err = rollingUpgrade(clients, config, GetDaemonSetRollingUpgradeFuncs(), collectors, recorder) + err = rollingUpgrade(clients, config, GetDaemonSetRollingUpgradeFuncs(), collectors, recorder, invoke) if err != nil { return err } - err = rollingUpgrade(clients, config, GetStatefulSetRollingUpgradeFuncs(), collectors, recorder) + err = rollingUpgrade(clients, config, GetStatefulSetRollingUpgradeFuncs(), collectors, recorder, invoke) if err != nil { return err } if kube.IsOpenshift { - err = rollingUpgrade(clients, config, GetDeploymentConfigRollingUpgradeFuncs(), collectors, recorder) + err = rollingUpgrade(clients, config, GetDeploymentConfigRollingUpgradeFuncs(), collectors, recorder, invoke) if err != nil { return err } } if options.IsArgoRollouts == "true" { - err = rollingUpgrade(clients, config, GetArgoRolloutRollingUpgradeFuncs(), collectors, recorder) + err = rollingUpgrade(clients, config, GetArgoRolloutRollingUpgradeFuncs(), collectors, recorder, invoke) if err != nil { return err } @@ -179,17 +179,17 @@ func doRollingUpgrade(config util.Config, collectors metrics.Collectors, recorde return nil } -func rollingUpgrade(clients kube.Clients, config util.Config, upgradeFuncs callbacks.RollingUpgradeFuncs, collectors metrics.Collectors, recorder record.EventRecorder) error { +func rollingUpgrade(clients kube.Clients, config util.Config, upgradeFuncs callbacks.RollingUpgradeFuncs, collectors metrics.Collectors, recorder record.EventRecorder, strategy invokeStrategy) error { - err := PerformRollingUpgrade(clients, config, upgradeFuncs, collectors, recorder) + err := PerformAction(clients, config, upgradeFuncs, collectors, recorder, strategy) if err != nil { logrus.Errorf("Rolling upgrade for '%s' failed with error = %v", config.ResourceName, err) } return err } -// PerformRollingUpgrade upgrades the deployment if there is any change in configmap or secret data -func PerformRollingUpgrade(clients kube.Clients, config util.Config, upgradeFuncs callbacks.RollingUpgradeFuncs, collectors metrics.Collectors, recorder record.EventRecorder) error { +// PerformAction invokes the deployment if there is any change in configmap or secret data +func PerformAction(clients kube.Clients, config util.Config, upgradeFuncs callbacks.RollingUpgradeFuncs, collectors metrics.Collectors, recorder record.EventRecorder, strategy invokeStrategy) error { items := upgradeFuncs.ItemsFunc(clients, config.Namespace) for _, i := range items { @@ -210,7 +210,7 @@ func PerformRollingUpgrade(clients kube.Clients, config util.Config, upgradeFunc reloaderEnabled, _ := strconv.ParseBool(reloaderEnabledValue) typedAutoAnnotationEnabled, _ := strconv.ParseBool(typedAutoAnnotationEnabledValue) if reloaderEnabled || typedAutoAnnotationEnabled || reloaderEnabledValue == "" && typedAutoAnnotationEnabledValue == "" && options.AutoReloadAll { - result = invokeReloadStrategy(upgradeFuncs, i, config, true) + result = strategy(upgradeFuncs, i, config, true) } if result != constants.Updated && annotationValue != "" { @@ -219,7 +219,7 @@ func PerformRollingUpgrade(clients kube.Clients, config util.Config, upgradeFunc value = strings.TrimSpace(value) re := regexp.MustCompile("^" + value + "$") if re.Match([]byte(config.ResourceName)) { - result = invokeReloadStrategy(upgradeFuncs, i, config, false) + result = strategy(upgradeFuncs, i, config, false) if result == constants.Updated { break } @@ -230,7 +230,7 @@ func PerformRollingUpgrade(clients kube.Clients, config util.Config, upgradeFunc if result != constants.Updated && searchAnnotationValue == "true" { matchAnnotationValue := config.ResourceAnnotations[options.SearchMatchAnnotation] if matchAnnotationValue == "true" { - result = invokeReloadStrategy(upgradeFuncs, i, config, true) + result = strategy(upgradeFuncs, i, config, true) } } @@ -380,6 +380,8 @@ func getContainerUsingResource(upgradeFuncs callbacks.RollingUpgradeFuncs, item return container } +type invokeStrategy func(upgradeFuncs callbacks.RollingUpgradeFuncs, item runtime.Object, config util.Config, autoReload bool) constants.Result + func invokeReloadStrategy(upgradeFuncs callbacks.RollingUpgradeFuncs, item runtime.Object, config util.Config, autoReload bool) constants.Result { if options.ReloadStrategy == constants.AnnotationsReloadStrategy { return updatePodAnnotations(upgradeFuncs, item, config, autoReload) @@ -416,6 +418,13 @@ func updatePodAnnotations(upgradeFuncs callbacks.RollingUpgradeFuncs, item runti return constants.Updated } +func getReloaderAnnotationKey() string { + return fmt.Sprintf("%s/%s", + constants.ReloaderAnnotationPrefix, + constants.LastReloadedFromAnnotation, + ) +} + func createReloadedAnnotations(target *util.ReloadSource) (map[string]string, error) { if target == nil { return nil, errors.New("target is required") @@ -426,10 +435,7 @@ func createReloadedAnnotations(target *util.ReloadSource) (map[string]string, er // Intentionally only storing the last item in order to keep // the generated annotations as small as possible. annotations := make(map[string]string) - lastReloadedResourceName := fmt.Sprintf("%s/%s", - constants.ReloaderAnnotationPrefix, - constants.LastReloadedFromAnnotation, - ) + lastReloadedResourceName := getReloaderAnnotationKey() lastReloadedResource, err := json.Marshal(target) if err != nil { @@ -440,9 +446,13 @@ func createReloadedAnnotations(target *util.ReloadSource) (map[string]string, er return annotations, nil } +func getEnvVarName(resourceName string, typeName string) string { + return constants.EnvVarPrefix + util.ConvertToEnvVarName(resourceName) + "_" + typeName +} + func updateContainerEnvVars(upgradeFuncs callbacks.RollingUpgradeFuncs, item runtime.Object, config util.Config, autoReload bool) constants.Result { var result constants.Result - envVar := constants.EnvVarPrefix + util.ConvertToEnvVarName(config.ResourceName) + "_" + config.Type + envVar := getEnvVarName(config.ResourceName, config.Type) container := getContainerUsingResource(upgradeFuncs, item, config, autoReload) if container == nil { diff --git a/internal/pkg/handler/upgrade_test.go b/internal/pkg/handler/upgrade_test.go index 907aa687..130be2c1 100644 --- a/internal/pkg/handler/upgrade_test.go +++ b/internal/pkg/handler/upgrade_test.go @@ -10,6 +10,7 @@ import ( "github.com/prometheus/client_golang/prometheus" promtestutil "github.com/prometheus/client_golang/prometheus/testutil" "github.com/sirupsen/logrus" + "github.com/stakater/Reloader/internal/pkg/callbacks" "github.com/stakater/Reloader/internal/pkg/constants" "github.com/stakater/Reloader/internal/pkg/metrics" "github.com/stakater/Reloader/internal/pkg/options" @@ -1278,12 +1279,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, } } @@ -1294,15 +1295,34 @@ func getCollectors() metrics.Collectors { var labelSucceeded = prometheus.Labels{"success": "true"} var labelFailed = prometheus.Labels{"success": "false"} +func testRollingUpgradeInvokeDeleteStrategyArs(t *testing.T, clients kube.Clients, config util.Config, upgradeFuncs callbacks.RollingUpgradeFuncs, collectors metrics.Collectors, envVarPostfix string) { + err := PerformAction(clients, config, upgradeFuncs, collectors, nil, invokeDeleteStrategy) + time.Sleep(5 * time.Second) + if err != nil { + t.Errorf("Rolling upgrade failed for %s with %s", upgradeFuncs.ResourceType, envVarPostfix) + } + + config.SHAValue = testutil.GetSHAfromEmptyData() + removed := testutil.VerifyResourceAnnotationUpdate(clients, config, upgradeFuncs) + if !removed { + t.Errorf("%s was not updated", upgradeFuncs.ResourceType) + } + + if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 2 { + t.Errorf("Counter was not increased") + } +} + func TestRollingUpgradeForDeploymentWithConfigmapUsingArs(t *testing.T) { options.ReloadStrategy = constants.AnnotationsReloadStrategy + envVarPostfix := constants.ConfigmapEnvVarPostfix shaData := testutil.ConvertResourceToSHA(testutil.ConfigmapResourceType, arsNamespace, arsConfigmapName, "www.stakater.com") - config := getConfigWithAnnotations(constants.ConfigmapEnvVarPostfix, arsConfigmapName, shaData, options.ConfigmapUpdateOnChangeAnnotation, options.ConfigmapReloaderAutoAnnotation) + config := getConfigWithAnnotations(envVarPostfix, arsConfigmapName, shaData, options.ConfigmapUpdateOnChangeAnnotation, options.ConfigmapReloaderAutoAnnotation) deploymentFuncs := GetDeploymentRollingUpgradeFuncs() collectors := getCollectors() - err := PerformRollingUpgrade(clients, config, deploymentFuncs, collectors, nil) + err := PerformAction(clients, config, deploymentFuncs, collectors, nil, invokeReloadStrategy) time.Sleep(5 * time.Second) if err != nil { t.Errorf("Rolling upgrade failed for Deployment with Configmap") @@ -1317,17 +1337,20 @@ func TestRollingUpgradeForDeploymentWithConfigmapUsingArs(t *testing.T) { if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, deploymentFuncs, collectors, envVarPostfix) } func TestRollingUpgradeForDeploymentWithConfigmapWithoutReloadAnnotationAndWithoutAutoReloadAllNoTriggersUsingArs(t *testing.T) { options.ReloadStrategy = constants.AnnotationsReloadStrategy + envVarPostfix := constants.ConfigmapEnvVarPostfix shaData := testutil.ConvertResourceToSHA(testutil.ConfigmapResourceType, arsNamespace, arsConfigMapWithNonAnnotatedDeployment, "www.stakater.com") - config := getConfigWithAnnotations(constants.ConfigmapEnvVarPostfix, arsConfigMapWithNonAnnotatedDeployment, shaData, options.ConfigmapUpdateOnChangeAnnotation, options.ConfigmapReloaderAutoAnnotation) + config := getConfigWithAnnotations(envVarPostfix, arsConfigMapWithNonAnnotatedDeployment, shaData, options.ConfigmapUpdateOnChangeAnnotation, options.ConfigmapReloaderAutoAnnotation) deploymentFuncs := GetDeploymentRollingUpgradeFuncs() collectors := getCollectors() - err := PerformRollingUpgrade(clients, config, deploymentFuncs, collectors, nil) + err := PerformAction(clients, config, deploymentFuncs, collectors, nil, invokeReloadStrategy) time.Sleep(5 * time.Second) if err != nil { t.Errorf("Rolling upgrade failed for Deployment with Configmap") @@ -1348,13 +1371,14 @@ func TestRollingUpgradeForDeploymentWithConfigmapWithoutReloadAnnotationButWithA options.ReloadStrategy = constants.AnnotationsReloadStrategy options.AutoReloadAll = true defer func() { options.AutoReloadAll = false }() + envVarPostfix := constants.ConfigmapEnvVarPostfix shaData := testutil.ConvertResourceToSHA(testutil.ConfigmapResourceType, arsNamespace, arsConfigMapWithNonAnnotatedDeployment, "www.stakater.com") - config := getConfigWithAnnotations(constants.ConfigmapEnvVarPostfix, arsConfigMapWithNonAnnotatedDeployment, shaData, "", options.ConfigmapReloaderAutoAnnotation) + config := getConfigWithAnnotations(envVarPostfix, arsConfigMapWithNonAnnotatedDeployment, shaData, "", options.ConfigmapReloaderAutoAnnotation) deploymentFuncs := GetDeploymentRollingUpgradeFuncs() collectors := getCollectors() - err := PerformRollingUpgrade(clients, config, deploymentFuncs, collectors, nil) + err := PerformAction(clients, config, deploymentFuncs, collectors, nil, invokeReloadStrategy) time.Sleep(5 * time.Second) if err != nil { t.Errorf("Rolling upgrade failed for Deployment with Configmap") @@ -1369,17 +1393,20 @@ func TestRollingUpgradeForDeploymentWithConfigmapWithoutReloadAnnotationButWithA if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, deploymentFuncs, collectors, envVarPostfix) } func TestRollingUpgradeForDeploymentWithConfigmapInProjectedVolumeUsingArs(t *testing.T) { options.ReloadStrategy = constants.AnnotationsReloadStrategy + envVarPostfix := constants.ConfigmapEnvVarPostfix shaData := testutil.ConvertResourceToSHA(testutil.ConfigmapResourceType, arsNamespace, arsProjectedConfigMapName, "www.stakater.com") - config := getConfigWithAnnotations(constants.ConfigmapEnvVarPostfix, arsProjectedConfigMapName, shaData, options.ConfigmapUpdateOnChangeAnnotation, options.ConfigmapReloaderAutoAnnotation) + config := getConfigWithAnnotations(envVarPostfix, arsProjectedConfigMapName, shaData, options.ConfigmapUpdateOnChangeAnnotation, options.ConfigmapReloaderAutoAnnotation) deploymentFuncs := GetDeploymentRollingUpgradeFuncs() collectors := getCollectors() - err := PerformRollingUpgrade(clients, config, deploymentFuncs, collectors, nil) + err := PerformAction(clients, config, deploymentFuncs, collectors, nil, invokeReloadStrategy) if err != nil { t.Errorf("Rolling upgrade failed for Deployment with Configmap in projected volume") } @@ -1393,18 +1420,21 @@ func TestRollingUpgradeForDeploymentWithConfigmapInProjectedVolumeUsingArs(t *te if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, deploymentFuncs, collectors, envVarPostfix) } func TestRollingUpgradeForDeploymentWithConfigmapViaSearchAnnotationUsingArs(t *testing.T) { options.ReloadStrategy = constants.AnnotationsReloadStrategy + envVarPostfix := constants.ConfigmapEnvVarPostfix shaData := testutil.ConvertResourceToSHA(testutil.ConfigmapResourceType, arsNamespace, arsConfigmapAnnotated, "www.stakater.com") - config := getConfigWithAnnotations(constants.ConfigmapEnvVarPostfix, arsConfigmapAnnotated, shaData, "", options.ConfigmapReloaderAutoAnnotation) + config := getConfigWithAnnotations(envVarPostfix, arsConfigmapAnnotated, shaData, "", options.ConfigmapReloaderAutoAnnotation) config.ResourceAnnotations = map[string]string{"reloader.stakater.com/match": "true"} deploymentFuncs := GetDeploymentRollingUpgradeFuncs() collectors := getCollectors() - err := PerformRollingUpgrade(clients, config, deploymentFuncs, collectors, nil) + err := PerformAction(clients, config, deploymentFuncs, collectors, nil, invokeReloadStrategy) if err != nil { t.Errorf("Rolling upgrade failed for Deployment with Configmap") } @@ -1418,18 +1448,21 @@ func TestRollingUpgradeForDeploymentWithConfigmapViaSearchAnnotationUsingArs(t * if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, deploymentFuncs, collectors, envVarPostfix) } func TestRollingUpgradeForDeploymentWithConfigmapViaSearchAnnotationNoTriggersUsingArs(t *testing.T) { options.ReloadStrategy = constants.AnnotationsReloadStrategy + envVarPostfix := constants.ConfigmapEnvVarPostfix shaData := testutil.ConvertResourceToSHA(testutil.ConfigmapResourceType, arsNamespace, arsConfigmapAnnotated, "www.stakater.com") - config := getConfigWithAnnotations(constants.ConfigmapEnvVarPostfix, arsConfigmapAnnotated, shaData, "", options.ConfigmapReloaderAutoAnnotation) + config := getConfigWithAnnotations(envVarPostfix, arsConfigmapAnnotated, shaData, "", options.ConfigmapReloaderAutoAnnotation) config.ResourceAnnotations = map[string]string{"reloader.stakater.com/match": "false"} deploymentFuncs := GetDeploymentRollingUpgradeFuncs() collectors := getCollectors() - err := PerformRollingUpgrade(clients, config, deploymentFuncs, collectors, nil) + err := PerformAction(clients, config, deploymentFuncs, collectors, nil, invokeReloadStrategy) if err != nil { t.Errorf("Rolling upgrade failed for Deployment with Configmap") } @@ -1448,6 +1481,7 @@ func TestRollingUpgradeForDeploymentWithConfigmapViaSearchAnnotationNoTriggersUs func TestRollingUpgradeForDeploymentWithConfigmapViaSearchAnnotationNotMappedUsingArs(t *testing.T) { options.ReloadStrategy = constants.AnnotationsReloadStrategy + envVarPostfix := constants.ConfigmapEnvVarPostfix deployment, err := testutil.CreateDeploymentWithEnvVarSourceAndAnnotations( clients.KubernetesClient, @@ -1464,12 +1498,12 @@ func TestRollingUpgradeForDeploymentWithConfigmapViaSearchAnnotationNotMappedUsi // defer clients.KubernetesClient.AppsV1().Deployments(namespace).Delete(deployment.Name, &v1.DeleteOptions{}) shaData := testutil.ConvertResourceToSHA(testutil.ConfigmapResourceType, arsNamespace, arsConfigmapAnnotated, "www.stakater.com") - config := getConfigWithAnnotations(constants.ConfigmapEnvVarPostfix, arsConfigmapAnnotated, shaData, "", options.ConfigmapReloaderAutoAnnotation) + config := getConfigWithAnnotations(envVarPostfix, arsConfigmapAnnotated, shaData, "", options.ConfigmapReloaderAutoAnnotation) config.ResourceAnnotations = map[string]string{"reloader.stakater.com/match": "false"} deploymentFuncs := GetDeploymentRollingUpgradeFuncs() collectors := getCollectors() - err = PerformRollingUpgrade(clients, config, deploymentFuncs, collectors, nil) + err = PerformAction(clients, config, deploymentFuncs, collectors, nil, invokeReloadStrategy) if err != nil { t.Errorf("Rolling upgrade failed for Deployment with Configmap") } @@ -1487,13 +1521,14 @@ func TestRollingUpgradeForDeploymentWithConfigmapViaSearchAnnotationNotMappedUsi func TestRollingUpgradeForDeploymentWithConfigmapInInitContainerUsingArs(t *testing.T) { options.ReloadStrategy = constants.AnnotationsReloadStrategy + envVarPostfix := constants.ConfigmapEnvVarPostfix shaData := testutil.ConvertResourceToSHA(testutil.ConfigmapResourceType, arsNamespace, arsConfigmapWithInitContainer, "www.stakater.com") - config := getConfigWithAnnotations(constants.ConfigmapEnvVarPostfix, arsConfigmapWithInitContainer, shaData, options.ConfigmapUpdateOnChangeAnnotation, options.ConfigmapReloaderAutoAnnotation) + config := getConfigWithAnnotations(envVarPostfix, arsConfigmapWithInitContainer, shaData, options.ConfigmapUpdateOnChangeAnnotation, options.ConfigmapReloaderAutoAnnotation) deploymentFuncs := GetDeploymentRollingUpgradeFuncs() collectors := getCollectors() - err := PerformRollingUpgrade(clients, config, deploymentFuncs, collectors, nil) + err := PerformAction(clients, config, deploymentFuncs, collectors, nil, invokeReloadStrategy) time.Sleep(5 * time.Second) if err != nil { t.Errorf("Rolling upgrade failed for Deployment with Configmap") @@ -1508,17 +1543,20 @@ func TestRollingUpgradeForDeploymentWithConfigmapInInitContainerUsingArs(t *test if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, deploymentFuncs, collectors, envVarPostfix) } func TestRollingUpgradeForDeploymentWithConfigmapInProjectVolumeInInitContainerUsingArs(t *testing.T) { options.ReloadStrategy = constants.AnnotationsReloadStrategy + envVarPostfix := constants.ConfigmapEnvVarPostfix shaData := testutil.ConvertResourceToSHA(testutil.ConfigmapResourceType, arsNamespace, arsProjectedConfigMapWithInitContainer, "www.stakater.com") - config := getConfigWithAnnotations(constants.ConfigmapEnvVarPostfix, arsProjectedConfigMapWithInitContainer, shaData, options.ConfigmapUpdateOnChangeAnnotation, options.ConfigmapReloaderAutoAnnotation) + config := getConfigWithAnnotations(envVarPostfix, arsProjectedConfigMapWithInitContainer, shaData, options.ConfigmapUpdateOnChangeAnnotation, options.ConfigmapReloaderAutoAnnotation) deploymentFuncs := GetDeploymentRollingUpgradeFuncs() collectors := getCollectors() - err := PerformRollingUpgrade(clients, config, deploymentFuncs, collectors, nil) + err := PerformAction(clients, config, deploymentFuncs, collectors, nil, invokeReloadStrategy) time.Sleep(5 * time.Second) if err != nil { t.Errorf("Rolling upgrade failed for Deployment with Configmap in projected volume") @@ -1533,17 +1571,20 @@ func TestRollingUpgradeForDeploymentWithConfigmapInProjectVolumeInInitContainerU if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, deploymentFuncs, collectors, envVarPostfix) } func TestRollingUpgradeForDeploymentWithConfigmapAsEnvVarUsingArs(t *testing.T) { options.ReloadStrategy = constants.AnnotationsReloadStrategy + envVarPostfix := constants.ConfigmapEnvVarPostfix shaData := testutil.ConvertResourceToSHA(testutil.ConfigmapResourceType, arsNamespace, arsConfigmapWithEnvName, "www.stakater.com") - config := getConfigWithAnnotations(constants.ConfigmapEnvVarPostfix, arsConfigmapWithEnvName, shaData, options.ReloaderAutoAnnotation, options.ConfigmapReloaderAutoAnnotation) + config := getConfigWithAnnotations(envVarPostfix, arsConfigmapWithEnvName, shaData, options.ReloaderAutoAnnotation, options.ConfigmapReloaderAutoAnnotation) deploymentFuncs := GetDeploymentRollingUpgradeFuncs() collectors := getCollectors() - err := PerformRollingUpgrade(clients, config, deploymentFuncs, collectors, nil) + err := PerformAction(clients, config, deploymentFuncs, collectors, nil, invokeReloadStrategy) time.Sleep(5 * time.Second) if err != nil { t.Errorf("Rolling upgrade failed for Deployment with Configmap used as env var") @@ -1558,17 +1599,20 @@ func TestRollingUpgradeForDeploymentWithConfigmapAsEnvVarUsingArs(t *testing.T) if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, deploymentFuncs, collectors, envVarPostfix) } func TestRollingUpgradeForDeploymentWithConfigmapAsEnvVarInInitContainerUsingArs(t *testing.T) { options.ReloadStrategy = constants.AnnotationsReloadStrategy + envVarPostfix := constants.ConfigmapEnvVarPostfix shaData := testutil.ConvertResourceToSHA(testutil.ConfigmapResourceType, arsNamespace, arsConfigmapWithInitEnv, "www.stakater.com") - config := getConfigWithAnnotations(constants.ConfigmapEnvVarPostfix, arsConfigmapWithInitEnv, shaData, options.ReloaderAutoAnnotation, options.ConfigmapReloaderAutoAnnotation) + config := getConfigWithAnnotations(envVarPostfix, arsConfigmapWithInitEnv, shaData, options.ReloaderAutoAnnotation, options.ConfigmapReloaderAutoAnnotation) deploymentFuncs := GetDeploymentRollingUpgradeFuncs() collectors := getCollectors() - err := PerformRollingUpgrade(clients, config, deploymentFuncs, collectors, nil) + err := PerformAction(clients, config, deploymentFuncs, collectors, nil, invokeReloadStrategy) time.Sleep(5 * time.Second) if err != nil { t.Errorf("Rolling upgrade failed for Deployment with Configmap used as env var") @@ -1583,17 +1627,20 @@ func TestRollingUpgradeForDeploymentWithConfigmapAsEnvVarInInitContainerUsingArs if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, deploymentFuncs, collectors, envVarPostfix) } func TestRollingUpgradeForDeploymentWithConfigmapAsEnvVarFromUsingArs(t *testing.T) { options.ReloadStrategy = constants.AnnotationsReloadStrategy + envVarPostfix := constants.ConfigmapEnvVarPostfix shaData := testutil.ConvertResourceToSHA(testutil.ConfigmapResourceType, arsNamespace, arsConfigmapWithEnvFromName, "www.stakater.com") - config := getConfigWithAnnotations(constants.ConfigmapEnvVarPostfix, arsConfigmapWithEnvFromName, shaData, options.ReloaderAutoAnnotation, options.ConfigmapReloaderAutoAnnotation) + config := getConfigWithAnnotations(envVarPostfix, arsConfigmapWithEnvFromName, shaData, options.ReloaderAutoAnnotation, options.ConfigmapReloaderAutoAnnotation) deploymentFuncs := GetDeploymentRollingUpgradeFuncs() collectors := getCollectors() - err := PerformRollingUpgrade(clients, config, deploymentFuncs, collectors, nil) + err := PerformAction(clients, config, deploymentFuncs, collectors, nil, invokeReloadStrategy) time.Sleep(5 * time.Second) if err != nil { t.Errorf("Rolling upgrade failed for Deployment with Configmap used as env var") @@ -1608,17 +1655,20 @@ func TestRollingUpgradeForDeploymentWithConfigmapAsEnvVarFromUsingArs(t *testing if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, deploymentFuncs, collectors, envVarPostfix) } func TestRollingUpgradeForDeploymentWithSecretUsingArs(t *testing.T) { options.ReloadStrategy = constants.AnnotationsReloadStrategy + envVarPostfix := constants.SecretEnvVarPostfix shaData := testutil.ConvertResourceToSHA(testutil.SecretResourceType, arsNamespace, arsSecretName, "dGVzdFVwZGF0ZWRTZWNyZXRFbmNvZGluZ0ZvclJlbG9hZGVy") - config := getConfigWithAnnotations(constants.SecretEnvVarPostfix, arsSecretName, shaData, options.SecretUpdateOnChangeAnnotation, options.SecretReloaderAutoAnnotation) + config := getConfigWithAnnotations(envVarPostfix, arsSecretName, shaData, options.SecretUpdateOnChangeAnnotation, options.SecretReloaderAutoAnnotation) deploymentFuncs := GetDeploymentRollingUpgradeFuncs() collectors := getCollectors() - err := PerformRollingUpgrade(clients, config, deploymentFuncs, collectors, nil) + err := PerformAction(clients, config, deploymentFuncs, collectors, nil, invokeReloadStrategy) time.Sleep(5 * time.Second) if err != nil { t.Errorf("Rolling upgrade failed for Deployment with Secret") @@ -1633,17 +1683,20 @@ func TestRollingUpgradeForDeploymentWithSecretUsingArs(t *testing.T) { if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, deploymentFuncs, collectors, envVarPostfix) } func TestRollingUpgradeForDeploymentWithSecretInProjectedVolumeUsingArs(t *testing.T) { options.ReloadStrategy = constants.AnnotationsReloadStrategy + envVarPostfix := constants.SecretEnvVarPostfix shaData := testutil.ConvertResourceToSHA(testutil.SecretResourceType, arsNamespace, arsProjectedSecretName, "dGVzdFVwZGF0ZWRTZWNyZXRFbmNvZGluZ0ZvclJlbG9hZGVy") - config := getConfigWithAnnotations(constants.SecretEnvVarPostfix, arsProjectedSecretName, shaData, options.SecretUpdateOnChangeAnnotation, options.SecretReloaderAutoAnnotation) + config := getConfigWithAnnotations(envVarPostfix, arsProjectedSecretName, shaData, options.SecretUpdateOnChangeAnnotation, options.SecretReloaderAutoAnnotation) deploymentFuncs := GetDeploymentRollingUpgradeFuncs() collectors := getCollectors() - err := PerformRollingUpgrade(clients, config, deploymentFuncs, collectors, nil) + err := PerformAction(clients, config, deploymentFuncs, collectors, nil, invokeReloadStrategy) time.Sleep(5 * time.Second) if err != nil { t.Errorf("Rolling upgrade failed for Deployment with Secret in projected volume") @@ -1658,17 +1711,20 @@ func TestRollingUpgradeForDeploymentWithSecretInProjectedVolumeUsingArs(t *testi if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, deploymentFuncs, collectors, envVarPostfix) } func TestRollingUpgradeForDeploymentWithSecretinInitContainerUsingArs(t *testing.T) { options.ReloadStrategy = constants.AnnotationsReloadStrategy + envVarPostfix := constants.SecretEnvVarPostfix shaData := testutil.ConvertResourceToSHA(testutil.SecretResourceType, arsNamespace, arsSecretWithInitContainer, "dGVzdFVwZGF0ZWRTZWNyZXRFbmNvZGluZ0ZvclJlbG9hZGVy") - config := getConfigWithAnnotations(constants.SecretEnvVarPostfix, arsSecretWithInitContainer, shaData, options.SecretUpdateOnChangeAnnotation, options.SecretReloaderAutoAnnotation) + config := getConfigWithAnnotations(envVarPostfix, arsSecretWithInitContainer, shaData, options.SecretUpdateOnChangeAnnotation, options.SecretReloaderAutoAnnotation) deploymentFuncs := GetDeploymentRollingUpgradeFuncs() collectors := getCollectors() - err := PerformRollingUpgrade(clients, config, deploymentFuncs, collectors, nil) + err := PerformAction(clients, config, deploymentFuncs, collectors, nil, invokeReloadStrategy) time.Sleep(5 * time.Second) if err != nil { t.Errorf("Rolling upgrade failed for Deployment with Secret") @@ -1683,17 +1739,20 @@ func TestRollingUpgradeForDeploymentWithSecretinInitContainerUsingArs(t *testing if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, deploymentFuncs, collectors, envVarPostfix) } func TestRollingUpgradeForDeploymentWithSecretInProjectedVolumeinInitContainerUsingArs(t *testing.T) { options.ReloadStrategy = constants.AnnotationsReloadStrategy + envVarPostfix := constants.SecretEnvVarPostfix shaData := testutil.ConvertResourceToSHA(testutil.SecretResourceType, arsNamespace, arsProjectedSecretWithInitContainer, "dGVzdFVwZGF0ZWRTZWNyZXRFbmNvZGluZ0ZvclJlbG9hZGVy") - config := getConfigWithAnnotations(constants.SecretEnvVarPostfix, arsProjectedSecretWithInitContainer, shaData, options.SecretUpdateOnChangeAnnotation, options.SecretReloaderAutoAnnotation) + config := getConfigWithAnnotations(envVarPostfix, arsProjectedSecretWithInitContainer, shaData, options.SecretUpdateOnChangeAnnotation, options.SecretReloaderAutoAnnotation) deploymentFuncs := GetDeploymentRollingUpgradeFuncs() collectors := getCollectors() - err := PerformRollingUpgrade(clients, config, deploymentFuncs, collectors, nil) + err := PerformAction(clients, config, deploymentFuncs, collectors, nil, invokeReloadStrategy) time.Sleep(5 * time.Second) if err != nil { t.Errorf("Rolling upgrade failed for Deployment with Secret in projected volume") @@ -1708,17 +1767,20 @@ func TestRollingUpgradeForDeploymentWithSecretInProjectedVolumeinInitContainerUs if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, deploymentFuncs, collectors, envVarPostfix) } func TestRollingUpgradeForDeploymentWithSecretAsEnvVarUsingArs(t *testing.T) { options.ReloadStrategy = constants.AnnotationsReloadStrategy + envVarPostfix := constants.SecretEnvVarPostfix shaData := testutil.ConvertResourceToSHA(testutil.SecretResourceType, arsNamespace, arsSecretWithEnvName, "dGVzdFVwZGF0ZWRTZWNyZXRFbmNvZGluZ0ZvclJlbG9hZGVy") - config := getConfigWithAnnotations(constants.SecretEnvVarPostfix, arsSecretWithEnvName, shaData, options.ReloaderAutoAnnotation, options.SecretReloaderAutoAnnotation) + config := getConfigWithAnnotations(envVarPostfix, arsSecretWithEnvName, shaData, options.ReloaderAutoAnnotation, options.SecretReloaderAutoAnnotation) deploymentFuncs := GetDeploymentRollingUpgradeFuncs() collectors := getCollectors() - err := PerformRollingUpgrade(clients, config, deploymentFuncs, collectors, nil) + err := PerformAction(clients, config, deploymentFuncs, collectors, nil, invokeReloadStrategy) time.Sleep(5 * time.Second) if err != nil { t.Errorf("Rolling upgrade failed for Deployment with Secret") @@ -1733,17 +1795,20 @@ func TestRollingUpgradeForDeploymentWithSecretAsEnvVarUsingArs(t *testing.T) { if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, deploymentFuncs, collectors, envVarPostfix) } func TestRollingUpgradeForDeploymentWithSecretAsEnvVarFromUsingArs(t *testing.T) { options.ReloadStrategy = constants.AnnotationsReloadStrategy + envVarPostfix := constants.SecretEnvVarPostfix shaData := testutil.ConvertResourceToSHA(testutil.SecretResourceType, arsNamespace, arsSecretWithEnvFromName, "dGVzdFVwZGF0ZWRTZWNyZXRFbmNvZGluZ0ZvclJlbG9hZGVy") - config := getConfigWithAnnotations(constants.SecretEnvVarPostfix, arsSecretWithEnvFromName, shaData, options.ReloaderAutoAnnotation, options.SecretReloaderAutoAnnotation) + config := getConfigWithAnnotations(envVarPostfix, arsSecretWithEnvFromName, shaData, options.ReloaderAutoAnnotation, options.SecretReloaderAutoAnnotation) deploymentFuncs := GetDeploymentRollingUpgradeFuncs() collectors := getCollectors() - err := PerformRollingUpgrade(clients, config, deploymentFuncs, collectors, nil) + err := PerformAction(clients, config, deploymentFuncs, collectors, nil, invokeReloadStrategy) time.Sleep(5 * time.Second) if err != nil { t.Errorf("Rolling upgrade failed for Deployment with Secret") @@ -1758,17 +1823,20 @@ func TestRollingUpgradeForDeploymentWithSecretAsEnvVarFromUsingArs(t *testing.T) if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, deploymentFuncs, collectors, envVarPostfix) } func TestRollingUpgradeForDeploymentWithSecretAsEnvVarInInitContainerUsingArs(t *testing.T) { options.ReloadStrategy = constants.AnnotationsReloadStrategy + envVarPostfix := constants.SecretEnvVarPostfix shaData := testutil.ConvertResourceToSHA(testutil.SecretResourceType, arsNamespace, arsSecretWithInitEnv, "dGVzdFVwZGF0ZWRTZWNyZXRFbmNvZGluZ0ZvclJlbG9hZGVy") - config := getConfigWithAnnotations(constants.SecretEnvVarPostfix, arsSecretWithInitEnv, shaData, options.ReloaderAutoAnnotation, options.SecretReloaderAutoAnnotation) + config := getConfigWithAnnotations(envVarPostfix, arsSecretWithInitEnv, shaData, options.ReloaderAutoAnnotation, options.SecretReloaderAutoAnnotation) deploymentFuncs := GetDeploymentRollingUpgradeFuncs() collectors := getCollectors() - err := PerformRollingUpgrade(clients, config, deploymentFuncs, collectors, nil) + err := PerformAction(clients, config, deploymentFuncs, collectors, nil, invokeReloadStrategy) time.Sleep(5 * time.Second) if err != nil { t.Errorf("Rolling upgrade failed for Deployment with Secret") @@ -1783,17 +1851,20 @@ func TestRollingUpgradeForDeploymentWithSecretAsEnvVarInInitContainerUsingArs(t if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, deploymentFuncs, collectors, envVarPostfix) } func TestRollingUpgradeForDeploymentWithSecretAutoAnnotationUsingArs(t *testing.T) { options.ReloadStrategy = constants.AnnotationsReloadStrategy + envVarPostfix := constants.SecretEnvVarPostfix shaData := testutil.ConvertResourceToSHA(testutil.SecretResourceType, arsNamespace, arsSecretWithSecretAutoAnnotation, "dGVzdFVwZGF0ZWRTZWNyZXRFbmNvZGluZ0ZvclJlbG9hZGVy") - config := getConfigWithAnnotations(constants.SecretEnvVarPostfix, arsSecretWithSecretAutoAnnotation, shaData, "", options.SecretReloaderAutoAnnotation) + config := getConfigWithAnnotations(envVarPostfix, arsSecretWithSecretAutoAnnotation, shaData, "", options.SecretReloaderAutoAnnotation) deploymentFuncs := GetDeploymentRollingUpgradeFuncs() collectors := getCollectors() - err := PerformRollingUpgrade(clients, config, deploymentFuncs, collectors, nil) + err := PerformAction(clients, config, deploymentFuncs, collectors, nil, invokeReloadStrategy) time.Sleep(5 * time.Second) if err != nil { t.Errorf("Rolling upgrade failed for Deployment with Secret") @@ -1808,17 +1879,20 @@ func TestRollingUpgradeForDeploymentWithSecretAutoAnnotationUsingArs(t *testing. if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, deploymentFuncs, collectors, envVarPostfix) } func TestRollingUpgradeForDeploymentWithConfigMapAutoAnnotationUsingArs(t *testing.T) { options.ReloadStrategy = constants.AnnotationsReloadStrategy + envVarPostfix := constants.ConfigmapEnvVarPostfix shaData := testutil.ConvertResourceToSHA(testutil.ConfigmapResourceType, arsNamespace, arsConfigmapWithConfigMapAutoAnnotation, "www.facebook.com") - config := getConfigWithAnnotations(constants.ConfigmapEnvVarPostfix, arsConfigmapWithConfigMapAutoAnnotation, shaData, "", options.ConfigmapReloaderAutoAnnotation) + config := getConfigWithAnnotations(envVarPostfix, arsConfigmapWithConfigMapAutoAnnotation, shaData, "", options.ConfigmapReloaderAutoAnnotation) deploymentFuncs := GetDeploymentRollingUpgradeFuncs() collectors := getCollectors() - err := PerformRollingUpgrade(clients, config, deploymentFuncs, collectors, nil) + err := PerformAction(clients, config, deploymentFuncs, collectors, nil, invokeReloadStrategy) time.Sleep(5 * time.Second) if err != nil { t.Errorf("Rolling upgrade failed for Deployment with ConfigMap") @@ -1833,17 +1907,20 @@ func TestRollingUpgradeForDeploymentWithConfigMapAutoAnnotationUsingArs(t *testi if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, deploymentFuncs, collectors, envVarPostfix) } func TestRollingUpgradeForDaemonSetWithConfigmapUsingArs(t *testing.T) { options.ReloadStrategy = constants.AnnotationsReloadStrategy + envVarPostfix := constants.ConfigmapEnvVarPostfix shaData := testutil.ConvertResourceToSHA(testutil.ConfigmapResourceType, arsNamespace, arsConfigmapName, "www.facebook.com") - config := getConfigWithAnnotations(constants.ConfigmapEnvVarPostfix, arsConfigmapName, shaData, options.ConfigmapUpdateOnChangeAnnotation, options.ConfigmapReloaderAutoAnnotation) + config := getConfigWithAnnotations(envVarPostfix, arsConfigmapName, shaData, options.ConfigmapUpdateOnChangeAnnotation, options.ConfigmapReloaderAutoAnnotation) daemonSetFuncs := GetDaemonSetRollingUpgradeFuncs() collectors := getCollectors() - err := PerformRollingUpgrade(clients, config, daemonSetFuncs, collectors, nil) + err := PerformAction(clients, config, daemonSetFuncs, collectors, nil, invokeReloadStrategy) time.Sleep(5 * time.Second) if err != nil { t.Errorf("Rolling upgrade failed for DaemonSet with configmap") @@ -1858,17 +1935,20 @@ func TestRollingUpgradeForDaemonSetWithConfigmapUsingArs(t *testing.T) { if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, daemonSetFuncs, collectors, envVarPostfix) } func TestRollingUpgradeForDaemonSetWithConfigmapInProjectedVolumeUsingArs(t *testing.T) { options.ReloadStrategy = constants.AnnotationsReloadStrategy + envVarPostfix := constants.ConfigmapEnvVarPostfix shaData := testutil.ConvertResourceToSHA(testutil.ConfigmapResourceType, arsNamespace, arsProjectedConfigMapName, "www.facebook.com") - config := getConfigWithAnnotations(constants.ConfigmapEnvVarPostfix, arsProjectedConfigMapName, shaData, options.ConfigmapUpdateOnChangeAnnotation, options.ConfigmapReloaderAutoAnnotation) + config := getConfigWithAnnotations(envVarPostfix, arsProjectedConfigMapName, shaData, options.ConfigmapUpdateOnChangeAnnotation, options.ConfigmapReloaderAutoAnnotation) daemonSetFuncs := GetDaemonSetRollingUpgradeFuncs() collectors := getCollectors() - err := PerformRollingUpgrade(clients, config, daemonSetFuncs, collectors, nil) + err := PerformAction(clients, config, daemonSetFuncs, collectors, nil, invokeReloadStrategy) time.Sleep(5 * time.Second) if err != nil { t.Errorf("Rolling upgrade failed for DaemonSet with configmap in projected volume") @@ -1883,17 +1963,20 @@ func TestRollingUpgradeForDaemonSetWithConfigmapInProjectedVolumeUsingArs(t *tes if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, daemonSetFuncs, collectors, envVarPostfix) } func TestRollingUpgradeForDaemonSetWithConfigmapAsEnvVarUsingArs(t *testing.T) { options.ReloadStrategy = constants.AnnotationsReloadStrategy + envVarPostfix := constants.ConfigmapEnvVarPostfix shaData := testutil.ConvertResourceToSHA(testutil.ConfigmapResourceType, arsNamespace, arsConfigmapWithEnvName, "www.facebook.com") - config := getConfigWithAnnotations(constants.ConfigmapEnvVarPostfix, arsConfigmapWithEnvName, shaData, options.ReloaderAutoAnnotation, options.ConfigmapReloaderAutoAnnotation) + config := getConfigWithAnnotations(envVarPostfix, arsConfigmapWithEnvName, shaData, options.ReloaderAutoAnnotation, options.ConfigmapReloaderAutoAnnotation) daemonSetFuncs := GetDaemonSetRollingUpgradeFuncs() collectors := getCollectors() - err := PerformRollingUpgrade(clients, config, daemonSetFuncs, collectors, nil) + err := PerformAction(clients, config, daemonSetFuncs, collectors, nil, invokeReloadStrategy) time.Sleep(5 * time.Second) if err != nil { t.Errorf("Rolling upgrade failed for DaemonSet with configmap used as env var") @@ -1908,17 +1991,20 @@ func TestRollingUpgradeForDaemonSetWithConfigmapAsEnvVarUsingArs(t *testing.T) { if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, daemonSetFuncs, collectors, envVarPostfix) } func TestRollingUpgradeForDaemonSetWithSecretUsingArs(t *testing.T) { options.ReloadStrategy = constants.AnnotationsReloadStrategy + envVarPostfix := constants.SecretEnvVarPostfix shaData := testutil.ConvertResourceToSHA(testutil.SecretResourceType, arsNamespace, arsSecretName, "d3d3LmZhY2Vib29rLmNvbQ==") - config := getConfigWithAnnotations(constants.SecretEnvVarPostfix, arsSecretName, shaData, options.SecretUpdateOnChangeAnnotation, options.SecretReloaderAutoAnnotation) + config := getConfigWithAnnotations(envVarPostfix, arsSecretName, shaData, options.SecretUpdateOnChangeAnnotation, options.SecretReloaderAutoAnnotation) daemonSetFuncs := GetDaemonSetRollingUpgradeFuncs() collectors := getCollectors() - err := PerformRollingUpgrade(clients, config, daemonSetFuncs, collectors, nil) + err := PerformAction(clients, config, daemonSetFuncs, collectors, nil, invokeReloadStrategy) time.Sleep(5 * time.Second) if err != nil { t.Errorf("Rolling upgrade failed for DaemonSet with secret") @@ -1933,17 +2019,20 @@ func TestRollingUpgradeForDaemonSetWithSecretUsingArs(t *testing.T) { if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, daemonSetFuncs, collectors, envVarPostfix) } func TestRollingUpgradeForDaemonSetWithSecretInProjectedVolumeUsingArs(t *testing.T) { options.ReloadStrategy = constants.AnnotationsReloadStrategy + envVarPostfix := constants.SecretEnvVarPostfix shaData := testutil.ConvertResourceToSHA(testutil.SecretResourceType, arsNamespace, arsProjectedSecretName, "d3d3LmZhY2Vib29rLmNvbQ==") - config := getConfigWithAnnotations(constants.SecretEnvVarPostfix, arsProjectedSecretName, shaData, options.SecretUpdateOnChangeAnnotation, options.SecretReloaderAutoAnnotation) + config := getConfigWithAnnotations(envVarPostfix, arsProjectedSecretName, shaData, options.SecretUpdateOnChangeAnnotation, options.SecretReloaderAutoAnnotation) daemonSetFuncs := GetDaemonSetRollingUpgradeFuncs() collectors := getCollectors() - err := PerformRollingUpgrade(clients, config, daemonSetFuncs, collectors, nil) + err := PerformAction(clients, config, daemonSetFuncs, collectors, nil, invokeReloadStrategy) time.Sleep(5 * time.Second) if err != nil { t.Errorf("Rolling upgrade failed for DaemonSet with secret in projected volume") @@ -1958,17 +2047,20 @@ func TestRollingUpgradeForDaemonSetWithSecretInProjectedVolumeUsingArs(t *testin if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, daemonSetFuncs, collectors, envVarPostfix) } func TestRollingUpgradeForStatefulSetWithConfigmapUsingArs(t *testing.T) { options.ReloadStrategy = constants.AnnotationsReloadStrategy + envVarPostfix := constants.ConfigmapEnvVarPostfix shaData := testutil.ConvertResourceToSHA(testutil.ConfigmapResourceType, arsNamespace, arsConfigmapName, "www.twitter.com") - config := getConfigWithAnnotations(constants.ConfigmapEnvVarPostfix, arsConfigmapName, shaData, options.ConfigmapUpdateOnChangeAnnotation, options.ConfigmapReloaderAutoAnnotation) + config := getConfigWithAnnotations(envVarPostfix, arsConfigmapName, shaData, options.ConfigmapUpdateOnChangeAnnotation, options.ConfigmapReloaderAutoAnnotation) statefulSetFuncs := GetStatefulSetRollingUpgradeFuncs() collectors := getCollectors() - err := PerformRollingUpgrade(clients, config, statefulSetFuncs, collectors, nil) + err := PerformAction(clients, config, statefulSetFuncs, collectors, nil, invokeReloadStrategy) time.Sleep(5 * time.Second) if err != nil { t.Errorf("Rolling upgrade failed for StatefulSet with configmap") @@ -1983,17 +2075,20 @@ func TestRollingUpgradeForStatefulSetWithConfigmapUsingArs(t *testing.T) { if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, statefulSetFuncs, collectors, envVarPostfix) } func TestRollingUpgradeForStatefulSetWithConfigmapInProjectedVolumeUsingArs(t *testing.T) { options.ReloadStrategy = constants.AnnotationsReloadStrategy + envVarPostfix := constants.ConfigmapEnvVarPostfix shaData := testutil.ConvertResourceToSHA(testutil.ConfigmapResourceType, arsNamespace, arsProjectedConfigMapName, "www.twitter.com") - config := getConfigWithAnnotations(constants.ConfigmapEnvVarPostfix, arsProjectedConfigMapName, shaData, options.ConfigmapUpdateOnChangeAnnotation, options.ConfigmapReloaderAutoAnnotation) + config := getConfigWithAnnotations(envVarPostfix, arsProjectedConfigMapName, shaData, options.ConfigmapUpdateOnChangeAnnotation, options.ConfigmapReloaderAutoAnnotation) statefulSetFuncs := GetStatefulSetRollingUpgradeFuncs() collectors := getCollectors() - err := PerformRollingUpgrade(clients, config, statefulSetFuncs, collectors, nil) + err := PerformAction(clients, config, statefulSetFuncs, collectors, nil, invokeReloadStrategy) time.Sleep(5 * time.Second) if err != nil { t.Errorf("Rolling upgrade failed for StatefulSet with configmap in projected volume") @@ -2008,17 +2103,20 @@ func TestRollingUpgradeForStatefulSetWithConfigmapInProjectedVolumeUsingArs(t *t if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, statefulSetFuncs, collectors, envVarPostfix) } func TestRollingUpgradeForStatefulSetWithSecretUsingArs(t *testing.T) { options.ReloadStrategy = constants.AnnotationsReloadStrategy + envVarPostfix := constants.SecretEnvVarPostfix shaData := testutil.ConvertResourceToSHA(testutil.SecretResourceType, arsNamespace, arsSecretName, "d3d3LnR3aXR0ZXIuY29t") - config := getConfigWithAnnotations(constants.SecretEnvVarPostfix, arsSecretName, shaData, options.SecretUpdateOnChangeAnnotation, options.SecretReloaderAutoAnnotation) + config := getConfigWithAnnotations(envVarPostfix, arsSecretName, shaData, options.SecretUpdateOnChangeAnnotation, options.SecretReloaderAutoAnnotation) statefulSetFuncs := GetStatefulSetRollingUpgradeFuncs() collectors := getCollectors() - err := PerformRollingUpgrade(clients, config, statefulSetFuncs, collectors, nil) + err := PerformAction(clients, config, statefulSetFuncs, collectors, nil, invokeReloadStrategy) time.Sleep(5 * time.Second) if err != nil { t.Errorf("Rolling upgrade failed for StatefulSet with secret") @@ -2033,17 +2131,20 @@ func TestRollingUpgradeForStatefulSetWithSecretUsingArs(t *testing.T) { if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, statefulSetFuncs, collectors, envVarPostfix) } func TestRollingUpgradeForStatefulSetWithSecretInProjectedVolumeUsingArs(t *testing.T) { options.ReloadStrategy = constants.AnnotationsReloadStrategy + envVarPostfix := constants.SecretEnvVarPostfix shaData := testutil.ConvertResourceToSHA(testutil.SecretResourceType, arsNamespace, arsProjectedSecretName, "d3d3LnR3aXR0ZXIuY29t") - config := getConfigWithAnnotations(constants.SecretEnvVarPostfix, arsProjectedSecretName, shaData, options.SecretUpdateOnChangeAnnotation, options.SecretReloaderAutoAnnotation) + config := getConfigWithAnnotations(envVarPostfix, arsProjectedSecretName, shaData, options.SecretUpdateOnChangeAnnotation, options.SecretReloaderAutoAnnotation) statefulSetFuncs := GetStatefulSetRollingUpgradeFuncs() collectors := getCollectors() - err := PerformRollingUpgrade(clients, config, statefulSetFuncs, collectors, nil) + err := PerformAction(clients, config, statefulSetFuncs, collectors, nil, invokeReloadStrategy) time.Sleep(5 * time.Second) if err != nil { t.Errorf("Rolling upgrade failed for StatefulSet with secret in projected volume") @@ -2058,17 +2159,20 @@ func TestRollingUpgradeForStatefulSetWithSecretInProjectedVolumeUsingArs(t *test if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + testRollingUpgradeInvokeDeleteStrategyArs(t, clients, config, statefulSetFuncs, collectors, envVarPostfix) } func TestRollingUpgradeForDeploymentWithPodAnnotationsUsingArs(t *testing.T) { options.ReloadStrategy = constants.AnnotationsReloadStrategy + envVarPostfix := constants.ConfigmapEnvVarPostfix shaData := testutil.ConvertResourceToSHA(testutil.ConfigmapResourceType, arsNamespace, arsConfigmapWithPodAnnotations, "www.stakater.com") - config := getConfigWithAnnotations(constants.ConfigmapEnvVarPostfix, arsConfigmapWithPodAnnotations, shaData, options.ConfigmapUpdateOnChangeAnnotation, options.ConfigmapReloaderAutoAnnotation) + config := getConfigWithAnnotations(envVarPostfix, arsConfigmapWithPodAnnotations, shaData, options.ConfigmapUpdateOnChangeAnnotation, options.ConfigmapReloaderAutoAnnotation) deploymentFuncs := GetDeploymentRollingUpgradeFuncs() collectors := getCollectors() - err := PerformRollingUpgrade(clients, config, deploymentFuncs, collectors, nil) + err := PerformAction(clients, config, deploymentFuncs, collectors, nil, invokeReloadStrategy) time.Sleep(5 * time.Second) if err != nil { t.Errorf("Rolling upgrade failed for Deployment with pod annotations") @@ -2123,29 +2227,47 @@ func TestFailedRollingUpgradeUsingArs(t *testing.T) { } collectors := getCollectors() - _ = PerformRollingUpgrade(clients, config, deploymentFuncs, collectors, nil) + _ = PerformAction(clients, config, deploymentFuncs, collectors, nil, invokeReloadStrategy) if promtestutil.ToFloat64(collectors.Reloaded.With(labelFailed)) != 1 { t.Errorf("Counter was not increased") } } +func testRollingUpgradeInvokeDeleteStrategyErs(t *testing.T, clients kube.Clients, config util.Config, upgradeFuncs callbacks.RollingUpgradeFuncs, collectors metrics.Collectors, envVarPostfix string) { + err := PerformAction(clients, config, upgradeFuncs, collectors, nil, invokeDeleteStrategy) + time.Sleep(5 * time.Second) + if err != nil { + t.Errorf("Rolling upgrade failed for %s with %s", upgradeFuncs.ResourceType, envVarPostfix) + } + + removed := testutil.VerifyResourceEnvVarRemoved(clients, config, envVarPostfix, upgradeFuncs) + if !removed { + t.Errorf("%s was not updated", upgradeFuncs.ResourceType) + } + + if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 2 { + t.Errorf("Counter was not increased") + } +} + func TestRollingUpgradeForDeploymentWithConfigmapUsingErs(t *testing.T) { options.ReloadStrategy = constants.EnvVarsReloadStrategy + envVarPostfix := constants.ConfigmapEnvVarPostfix shaData := testutil.ConvertResourceToSHA(testutil.ConfigmapResourceType, ersNamespace, ersConfigmapName, "www.stakater.com") - config := getConfigWithAnnotations(constants.ConfigmapEnvVarPostfix, ersConfigmapName, shaData, options.ConfigmapUpdateOnChangeAnnotation, options.ConfigmapReloaderAutoAnnotation) + config := getConfigWithAnnotations(envVarPostfix, ersConfigmapName, shaData, options.ConfigmapUpdateOnChangeAnnotation, options.ConfigmapReloaderAutoAnnotation) deploymentFuncs := GetDeploymentRollingUpgradeFuncs() collectors := getCollectors() - err := PerformRollingUpgrade(clients, config, deploymentFuncs, collectors, nil) + err := PerformAction(clients, config, deploymentFuncs, collectors, nil, invokeReloadStrategy) time.Sleep(5 * time.Second) if err != nil { - t.Errorf("Rolling upgrade failed for Deployment with Configmap") + t.Errorf("Rolling upgrade failed for %s with %s", deploymentFuncs.ResourceType, envVarPostfix) } logrus.Infof("Verifying deployment update") - updated := testutil.VerifyResourceEnvVarUpdate(clients, config, constants.ConfigmapEnvVarPostfix, deploymentFuncs) + updated := testutil.VerifyResourceEnvVarUpdate(clients, config, envVarPostfix, deploymentFuncs) if !updated { t.Errorf("Deployment was not updated") } @@ -2153,23 +2275,26 @@ func TestRollingUpgradeForDeploymentWithConfigmapUsingErs(t *testing.T) { if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + testRollingUpgradeInvokeDeleteStrategyErs(t, clients, config, deploymentFuncs, collectors, envVarPostfix) } func TestRollingUpgradeForDeploymentWithConfigmapInProjectedVolumeUsingErs(t *testing.T) { options.ReloadStrategy = constants.EnvVarsReloadStrategy + envVarPostfix := constants.ConfigmapEnvVarPostfix shaData := testutil.ConvertResourceToSHA(testutil.ConfigmapResourceType, ersNamespace, ersProjectedConfigMapName, "www.stakater.com") - config := getConfigWithAnnotations(constants.ConfigmapEnvVarPostfix, ersProjectedConfigMapName, shaData, options.ConfigmapUpdateOnChangeAnnotation, options.ConfigmapReloaderAutoAnnotation) + config := getConfigWithAnnotations(envVarPostfix, ersProjectedConfigMapName, shaData, options.ConfigmapUpdateOnChangeAnnotation, options.ConfigmapReloaderAutoAnnotation) deploymentFuncs := GetDeploymentRollingUpgradeFuncs() collectors := getCollectors() - err := PerformRollingUpgrade(clients, config, deploymentFuncs, collectors, nil) + err := PerformAction(clients, config, deploymentFuncs, collectors, nil, invokeReloadStrategy) if err != nil { t.Errorf("Rolling upgrade failed for Deployment with Configmap in projected volume") } logrus.Infof("Verifying deployment update") - updated := testutil.VerifyResourceEnvVarUpdate(clients, config, constants.ConfigmapEnvVarPostfix, deploymentFuncs) + updated := testutil.VerifyResourceEnvVarUpdate(clients, config, envVarPostfix, deploymentFuncs) if !updated { t.Errorf("Deployment was not updated") } @@ -2177,24 +2302,27 @@ func TestRollingUpgradeForDeploymentWithConfigmapInProjectedVolumeUsingErs(t *te if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + testRollingUpgradeInvokeDeleteStrategyErs(t, clients, config, deploymentFuncs, collectors, envVarPostfix) } func TestRollingUpgradeForDeploymentWithConfigmapViaSearchAnnotationUsingErs(t *testing.T) { options.ReloadStrategy = constants.EnvVarsReloadStrategy + envVarPostfix := constants.ConfigmapEnvVarPostfix shaData := testutil.ConvertResourceToSHA(testutil.ConfigmapResourceType, ersNamespace, ersConfigmapAnnotated, "www.stakater.com") - config := getConfigWithAnnotations(constants.ConfigmapEnvVarPostfix, ersConfigmapAnnotated, shaData, "", options.ConfigmapReloaderAutoAnnotation) + config := getConfigWithAnnotations(envVarPostfix, ersConfigmapAnnotated, shaData, "", options.ConfigmapReloaderAutoAnnotation) config.ResourceAnnotations = map[string]string{"reloader.stakater.com/match": "true"} deploymentFuncs := GetDeploymentRollingUpgradeFuncs() collectors := getCollectors() - err := PerformRollingUpgrade(clients, config, deploymentFuncs, collectors, nil) + err := PerformAction(clients, config, deploymentFuncs, collectors, nil, invokeReloadStrategy) if err != nil { - t.Errorf("Rolling upgrade failed for Deployment with Configmap") + t.Errorf("Rolling upgrade failed for %s with %s", deploymentFuncs.ResourceType, envVarPostfix) } logrus.Infof("Verifying deployment update") - updated := testutil.VerifyResourceEnvVarUpdate(clients, config, constants.ConfigmapEnvVarPostfix, deploymentFuncs) + updated := testutil.VerifyResourceEnvVarUpdate(clients, config, envVarPostfix, deploymentFuncs) if !updated { t.Errorf("Deployment was not updated") } @@ -2202,24 +2330,27 @@ func TestRollingUpgradeForDeploymentWithConfigmapViaSearchAnnotationUsingErs(t * if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + testRollingUpgradeInvokeDeleteStrategyErs(t, clients, config, deploymentFuncs, collectors, envVarPostfix) } func TestRollingUpgradeForDeploymentWithConfigmapViaSearchAnnotationNoTriggersUsingErs(t *testing.T) { options.ReloadStrategy = constants.EnvVarsReloadStrategy + envVarPostfix := constants.ConfigmapEnvVarPostfix shaData := testutil.ConvertResourceToSHA(testutil.ConfigmapResourceType, ersNamespace, ersConfigmapAnnotated, "www.stakater.com") - config := getConfigWithAnnotations(constants.ConfigmapEnvVarPostfix, ersConfigmapAnnotated, shaData, "", options.ConfigmapReloaderAutoAnnotation) + config := getConfigWithAnnotations(envVarPostfix, ersConfigmapAnnotated, shaData, "", options.ConfigmapReloaderAutoAnnotation) config.ResourceAnnotations = map[string]string{"reloader.stakater.com/match": "false"} deploymentFuncs := GetDeploymentRollingUpgradeFuncs() collectors := getCollectors() - err := PerformRollingUpgrade(clients, config, deploymentFuncs, collectors, nil) + err := PerformAction(clients, config, deploymentFuncs, collectors, nil, invokeReloadStrategy) if err != nil { - t.Errorf("Rolling upgrade failed for Deployment with Configmap") + t.Errorf("Rolling upgrade failed for %s with %s", deploymentFuncs.ResourceType, envVarPostfix) } logrus.Infof("Verifying deployment update") - updated := testutil.VerifyResourceEnvVarUpdate(clients, config, constants.ConfigmapEnvVarPostfix, deploymentFuncs) + updated := testutil.VerifyResourceEnvVarUpdate(clients, config, envVarPostfix, deploymentFuncs) time.Sleep(5 * time.Second) if updated { t.Errorf("Deployment was updated unexpectedly") @@ -2232,6 +2363,7 @@ func TestRollingUpgradeForDeploymentWithConfigmapViaSearchAnnotationNoTriggersUs func TestRollingUpgradeForDeploymentWithConfigmapViaSearchAnnotationNotMappedUsingErs(t *testing.T) { options.ReloadStrategy = constants.EnvVarsReloadStrategy + envVarPostfix := constants.ConfigmapEnvVarPostfix deployment, err := testutil.CreateDeploymentWithEnvVarSourceAndAnnotations( clients.KubernetesClient, @@ -2248,18 +2380,18 @@ func TestRollingUpgradeForDeploymentWithConfigmapViaSearchAnnotationNotMappedUsi // defer clients.KubernetesClient.AppsV1().Deployments(namespace).Delete(deployment.Name, &v1.DeleteOptions{}) shaData := testutil.ConvertResourceToSHA(testutil.ConfigmapResourceType, ersNamespace, ersConfigmapAnnotated, "www.stakater.com") - config := getConfigWithAnnotations(constants.ConfigmapEnvVarPostfix, ersConfigmapAnnotated, shaData, "", options.ConfigmapReloaderAutoAnnotation) + config := getConfigWithAnnotations(envVarPostfix, ersConfigmapAnnotated, shaData, "", options.ConfigmapReloaderAutoAnnotation) config.ResourceAnnotations = map[string]string{"reloader.stakater.com/match": "false"} deploymentFuncs := GetDeploymentRollingUpgradeFuncs() collectors := getCollectors() - err = PerformRollingUpgrade(clients, config, deploymentFuncs, collectors, nil) + err = PerformAction(clients, config, deploymentFuncs, collectors, nil, invokeReloadStrategy) if err != nil { - t.Errorf("Rolling upgrade failed for Deployment with Configmap") + t.Errorf("Rolling upgrade failed for %s with %s", deploymentFuncs.ResourceType, envVarPostfix) } logrus.Infof("Verifying deployment update") - updated := testutil.VerifyResourceEnvVarUpdate(clients, config, constants.ConfigmapEnvVarPostfix, deploymentFuncs) + updated := testutil.VerifyResourceEnvVarUpdate(clients, config, envVarPostfix, deploymentFuncs) if updated { t.Errorf("Deployment was updated unexpectedly") } @@ -2271,20 +2403,21 @@ func TestRollingUpgradeForDeploymentWithConfigmapViaSearchAnnotationNotMappedUsi func TestRollingUpgradeForDeploymentWithConfigmapInInitContainerUsingErs(t *testing.T) { options.ReloadStrategy = constants.EnvVarsReloadStrategy + envVarPostfix := constants.ConfigmapEnvVarPostfix shaData := testutil.ConvertResourceToSHA(testutil.ConfigmapResourceType, ersNamespace, ersConfigmapWithInitContainer, "www.stakater.com") - config := getConfigWithAnnotations(constants.ConfigmapEnvVarPostfix, ersConfigmapWithInitContainer, shaData, options.ConfigmapUpdateOnChangeAnnotation, options.ConfigmapReloaderAutoAnnotation) + config := getConfigWithAnnotations(envVarPostfix, ersConfigmapWithInitContainer, shaData, options.ConfigmapUpdateOnChangeAnnotation, options.ConfigmapReloaderAutoAnnotation) deploymentFuncs := GetDeploymentRollingUpgradeFuncs() collectors := getCollectors() - err := PerformRollingUpgrade(clients, config, deploymentFuncs, collectors, nil) + err := PerformAction(clients, config, deploymentFuncs, collectors, nil, invokeReloadStrategy) time.Sleep(5 * time.Second) if err != nil { - t.Errorf("Rolling upgrade failed for Deployment with Configmap") + t.Errorf("Rolling upgrade failed for %s with %s", deploymentFuncs.ResourceType, envVarPostfix) } logrus.Infof("Verifying deployment update") - updated := testutil.VerifyResourceEnvVarUpdate(clients, config, constants.ConfigmapEnvVarPostfix, deploymentFuncs) + updated := testutil.VerifyResourceEnvVarUpdate(clients, config, envVarPostfix, deploymentFuncs) if !updated { t.Errorf("Deployment was not updated") } @@ -2292,24 +2425,27 @@ func TestRollingUpgradeForDeploymentWithConfigmapInInitContainerUsingErs(t *test if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + testRollingUpgradeInvokeDeleteStrategyErs(t, clients, config, deploymentFuncs, collectors, envVarPostfix) } func TestRollingUpgradeForDeploymentWithConfigmapInProjectVolumeInInitContainerUsingErs(t *testing.T) { options.ReloadStrategy = constants.EnvVarsReloadStrategy + envVarPostfix := constants.ConfigmapEnvVarPostfix shaData := testutil.ConvertResourceToSHA(testutil.ConfigmapResourceType, ersNamespace, ersProjectedConfigMapWithInitContainer, "www.stakater.com") - config := getConfigWithAnnotations(constants.ConfigmapEnvVarPostfix, ersProjectedConfigMapWithInitContainer, shaData, options.ConfigmapUpdateOnChangeAnnotation, options.ConfigmapReloaderAutoAnnotation) + config := getConfigWithAnnotations(envVarPostfix, ersProjectedConfigMapWithInitContainer, shaData, options.ConfigmapUpdateOnChangeAnnotation, options.ConfigmapReloaderAutoAnnotation) deploymentFuncs := GetDeploymentRollingUpgradeFuncs() collectors := getCollectors() - err := PerformRollingUpgrade(clients, config, deploymentFuncs, collectors, nil) + err := PerformAction(clients, config, deploymentFuncs, collectors, nil, invokeReloadStrategy) time.Sleep(5 * time.Second) if err != nil { t.Errorf("Rolling upgrade failed for Deployment with Configmap in projected volume") } logrus.Infof("Verifying deployment update") - updated := testutil.VerifyResourceEnvVarUpdate(clients, config, constants.ConfigmapEnvVarPostfix, deploymentFuncs) + updated := testutil.VerifyResourceEnvVarUpdate(clients, config, envVarPostfix, deploymentFuncs) if !updated { t.Errorf("Deployment was not updated") } @@ -2317,24 +2453,27 @@ func TestRollingUpgradeForDeploymentWithConfigmapInProjectVolumeInInitContainerU if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + testRollingUpgradeInvokeDeleteStrategyErs(t, clients, config, deploymentFuncs, collectors, envVarPostfix) } func TestRollingUpgradeForDeploymentWithConfigmapAsEnvVarUsingErs(t *testing.T) { options.ReloadStrategy = constants.EnvVarsReloadStrategy + envVarPostfix := constants.ConfigmapEnvVarPostfix shaData := testutil.ConvertResourceToSHA(testutil.ConfigmapResourceType, ersNamespace, ersConfigmapWithEnvName, "www.stakater.com") - config := getConfigWithAnnotations(constants.ConfigmapEnvVarPostfix, ersConfigmapWithEnvName, shaData, options.ReloaderAutoAnnotation, options.ConfigmapReloaderAutoAnnotation) + config := getConfigWithAnnotations(envVarPostfix, ersConfigmapWithEnvName, shaData, options.ReloaderAutoAnnotation, options.ConfigmapReloaderAutoAnnotation) deploymentFuncs := GetDeploymentRollingUpgradeFuncs() collectors := getCollectors() - err := PerformRollingUpgrade(clients, config, deploymentFuncs, collectors, nil) + err := PerformAction(clients, config, deploymentFuncs, collectors, nil, invokeReloadStrategy) time.Sleep(5 * time.Second) if err != nil { t.Errorf("Rolling upgrade failed for Deployment with Configmap used as env var") } logrus.Infof("Verifying deployment update") - updated := testutil.VerifyResourceEnvVarUpdate(clients, config, constants.ConfigmapEnvVarPostfix, deploymentFuncs) + updated := testutil.VerifyResourceEnvVarUpdate(clients, config, envVarPostfix, deploymentFuncs) if !updated { t.Errorf("Deployment was not updated") } @@ -2342,24 +2481,27 @@ func TestRollingUpgradeForDeploymentWithConfigmapAsEnvVarUsingErs(t *testing.T) if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + testRollingUpgradeInvokeDeleteStrategyErs(t, clients, config, deploymentFuncs, collectors, envVarPostfix) } func TestRollingUpgradeForDeploymentWithConfigmapAsEnvVarInInitContainerUsingErs(t *testing.T) { options.ReloadStrategy = constants.EnvVarsReloadStrategy + envVarPostfix := constants.ConfigmapEnvVarPostfix shaData := testutil.ConvertResourceToSHA(testutil.ConfigmapResourceType, ersNamespace, ersConfigmapWithInitEnv, "www.stakater.com") - config := getConfigWithAnnotations(constants.ConfigmapEnvVarPostfix, ersConfigmapWithInitEnv, shaData, options.ReloaderAutoAnnotation, options.ConfigmapReloaderAutoAnnotation) + config := getConfigWithAnnotations(envVarPostfix, ersConfigmapWithInitEnv, shaData, options.ReloaderAutoAnnotation, options.ConfigmapReloaderAutoAnnotation) deploymentFuncs := GetDeploymentRollingUpgradeFuncs() collectors := getCollectors() - err := PerformRollingUpgrade(clients, config, deploymentFuncs, collectors, nil) + err := PerformAction(clients, config, deploymentFuncs, collectors, nil, invokeReloadStrategy) time.Sleep(5 * time.Second) if err != nil { t.Errorf("Rolling upgrade failed for Deployment with Configmap used as env var") } logrus.Infof("Verifying deployment update") - updated := testutil.VerifyResourceEnvVarUpdate(clients, config, constants.ConfigmapEnvVarPostfix, deploymentFuncs) + updated := testutil.VerifyResourceEnvVarUpdate(clients, config, envVarPostfix, deploymentFuncs) if !updated { t.Errorf("Deployment was not updated") } @@ -2367,24 +2509,27 @@ func TestRollingUpgradeForDeploymentWithConfigmapAsEnvVarInInitContainerUsingErs if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + testRollingUpgradeInvokeDeleteStrategyErs(t, clients, config, deploymentFuncs, collectors, envVarPostfix) } func TestRollingUpgradeForDeploymentWithConfigmapAsEnvVarFromUsingErs(t *testing.T) { options.ReloadStrategy = constants.EnvVarsReloadStrategy + envVarPostfix := constants.ConfigmapEnvVarPostfix shaData := testutil.ConvertResourceToSHA(testutil.ConfigmapResourceType, ersNamespace, ersConfigmapWithEnvFromName, "www.stakater.com") - config := getConfigWithAnnotations(constants.ConfigmapEnvVarPostfix, ersConfigmapWithEnvFromName, shaData, options.ReloaderAutoAnnotation, options.ConfigmapReloaderAutoAnnotation) + config := getConfigWithAnnotations(envVarPostfix, ersConfigmapWithEnvFromName, shaData, options.ReloaderAutoAnnotation, options.ConfigmapReloaderAutoAnnotation) deploymentFuncs := GetDeploymentRollingUpgradeFuncs() collectors := getCollectors() - err := PerformRollingUpgrade(clients, config, deploymentFuncs, collectors, nil) + err := PerformAction(clients, config, deploymentFuncs, collectors, nil, invokeReloadStrategy) time.Sleep(5 * time.Second) if err != nil { t.Errorf("Rolling upgrade failed for Deployment with Configmap used as env var") } logrus.Infof("Verifying deployment update") - updated := testutil.VerifyResourceEnvVarUpdate(clients, config, constants.ConfigmapEnvVarPostfix, deploymentFuncs) + updated := testutil.VerifyResourceEnvVarUpdate(clients, config, envVarPostfix, deploymentFuncs) if !updated { t.Errorf("Deployment was not updated") } @@ -2392,24 +2537,27 @@ func TestRollingUpgradeForDeploymentWithConfigmapAsEnvVarFromUsingErs(t *testing if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + testRollingUpgradeInvokeDeleteStrategyErs(t, clients, config, deploymentFuncs, collectors, envVarPostfix) } func TestRollingUpgradeForDeploymentWithSecretUsingErs(t *testing.T) { options.ReloadStrategy = constants.EnvVarsReloadStrategy + envVarPostfix := constants.SecretEnvVarPostfix shaData := testutil.ConvertResourceToSHA(testutil.SecretResourceType, ersNamespace, ersSecretName, "dGVzdFVwZGF0ZWRTZWNyZXRFbmNvZGluZ0ZvclJlbG9hZGVy") - config := getConfigWithAnnotations(constants.SecretEnvVarPostfix, ersSecretName, shaData, options.SecretUpdateOnChangeAnnotation, options.SecretReloaderAutoAnnotation) + config := getConfigWithAnnotations(envVarPostfix, ersSecretName, shaData, options.SecretUpdateOnChangeAnnotation, options.SecretReloaderAutoAnnotation) deploymentFuncs := GetDeploymentRollingUpgradeFuncs() collectors := getCollectors() - err := PerformRollingUpgrade(clients, config, deploymentFuncs, collectors, nil) + err := PerformAction(clients, config, deploymentFuncs, collectors, nil, invokeReloadStrategy) time.Sleep(5 * time.Second) if err != nil { t.Errorf("Rolling upgrade failed for Deployment with Secret") } logrus.Infof("Verifying deployment update") - updated := testutil.VerifyResourceEnvVarUpdate(clients, config, constants.SecretEnvVarPostfix, deploymentFuncs) + updated := testutil.VerifyResourceEnvVarUpdate(clients, config, envVarPostfix, deploymentFuncs) if !updated { t.Errorf("Deployment was not updated") } @@ -2417,24 +2565,27 @@ func TestRollingUpgradeForDeploymentWithSecretUsingErs(t *testing.T) { if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + testRollingUpgradeInvokeDeleteStrategyErs(t, clients, config, deploymentFuncs, collectors, envVarPostfix) } func TestRollingUpgradeForDeploymentWithSecretInProjectedVolumeUsingErs(t *testing.T) { options.ReloadStrategy = constants.EnvVarsReloadStrategy + envVarPostfix := constants.SecretEnvVarPostfix shaData := testutil.ConvertResourceToSHA(testutil.SecretResourceType, ersNamespace, ersProjectedSecretName, "dGVzdFVwZGF0ZWRTZWNyZXRFbmNvZGluZ0ZvclJlbG9hZGVy") - config := getConfigWithAnnotations(constants.SecretEnvVarPostfix, ersProjectedSecretName, shaData, options.SecretUpdateOnChangeAnnotation, options.SecretReloaderAutoAnnotation) + config := getConfigWithAnnotations(envVarPostfix, ersProjectedSecretName, shaData, options.SecretUpdateOnChangeAnnotation, options.SecretReloaderAutoAnnotation) deploymentFuncs := GetDeploymentRollingUpgradeFuncs() collectors := getCollectors() - err := PerformRollingUpgrade(clients, config, deploymentFuncs, collectors, nil) + err := PerformAction(clients, config, deploymentFuncs, collectors, nil, invokeReloadStrategy) time.Sleep(5 * time.Second) if err != nil { t.Errorf("Rolling upgrade failed for Deployment with Secret in projected volume") } logrus.Infof("Verifying deployment update") - updated := testutil.VerifyResourceEnvVarUpdate(clients, config, constants.SecretEnvVarPostfix, deploymentFuncs) + updated := testutil.VerifyResourceEnvVarUpdate(clients, config, envVarPostfix, deploymentFuncs) if !updated { t.Errorf("Deployment was not updated") } @@ -2442,24 +2593,27 @@ func TestRollingUpgradeForDeploymentWithSecretInProjectedVolumeUsingErs(t *testi if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + testRollingUpgradeInvokeDeleteStrategyErs(t, clients, config, deploymentFuncs, collectors, envVarPostfix) } func TestRollingUpgradeForDeploymentWithSecretinInitContainerUsingErs(t *testing.T) { options.ReloadStrategy = constants.EnvVarsReloadStrategy + envVarPostfix := constants.SecretEnvVarPostfix shaData := testutil.ConvertResourceToSHA(testutil.SecretResourceType, ersNamespace, ersSecretWithInitContainer, "dGVzdFVwZGF0ZWRTZWNyZXRFbmNvZGluZ0ZvclJlbG9hZGVy") - config := getConfigWithAnnotations(constants.SecretEnvVarPostfix, ersSecretWithInitContainer, shaData, options.SecretUpdateOnChangeAnnotation, options.SecretReloaderAutoAnnotation) + config := getConfigWithAnnotations(envVarPostfix, ersSecretWithInitContainer, shaData, options.SecretUpdateOnChangeAnnotation, options.SecretReloaderAutoAnnotation) deploymentFuncs := GetDeploymentRollingUpgradeFuncs() collectors := getCollectors() - err := PerformRollingUpgrade(clients, config, deploymentFuncs, collectors, nil) + err := PerformAction(clients, config, deploymentFuncs, collectors, nil, invokeReloadStrategy) time.Sleep(5 * time.Second) if err != nil { t.Errorf("Rolling upgrade failed for Deployment with Secret") } logrus.Infof("Verifying deployment update") - updated := testutil.VerifyResourceEnvVarUpdate(clients, config, constants.SecretEnvVarPostfix, deploymentFuncs) + updated := testutil.VerifyResourceEnvVarUpdate(clients, config, envVarPostfix, deploymentFuncs) if !updated { t.Errorf("Deployment was not updated") } @@ -2467,24 +2621,27 @@ func TestRollingUpgradeForDeploymentWithSecretinInitContainerUsingErs(t *testing if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + testRollingUpgradeInvokeDeleteStrategyErs(t, clients, config, deploymentFuncs, collectors, envVarPostfix) } func TestRollingUpgradeForDeploymentWithSecretInProjectedVolumeinInitContainerUsingErs(t *testing.T) { options.ReloadStrategy = constants.EnvVarsReloadStrategy + envVarPostfix := constants.SecretEnvVarPostfix shaData := testutil.ConvertResourceToSHA(testutil.SecretResourceType, ersNamespace, ersProjectedSecretWithInitContainer, "dGVzdFVwZGF0ZWRTZWNyZXRFbmNvZGluZ0ZvclJlbG9hZGVy") - config := getConfigWithAnnotations(constants.SecretEnvVarPostfix, ersProjectedSecretWithInitContainer, shaData, options.SecretUpdateOnChangeAnnotation, options.SecretReloaderAutoAnnotation) + config := getConfigWithAnnotations(envVarPostfix, ersProjectedSecretWithInitContainer, shaData, options.SecretUpdateOnChangeAnnotation, options.SecretReloaderAutoAnnotation) deploymentFuncs := GetDeploymentRollingUpgradeFuncs() collectors := getCollectors() - err := PerformRollingUpgrade(clients, config, deploymentFuncs, collectors, nil) + err := PerformAction(clients, config, deploymentFuncs, collectors, nil, invokeReloadStrategy) time.Sleep(5 * time.Second) if err != nil { t.Errorf("Rolling upgrade failed for Deployment with Secret in projected volume") } logrus.Infof("Verifying deployment update") - updated := testutil.VerifyResourceEnvVarUpdate(clients, config, constants.SecretEnvVarPostfix, deploymentFuncs) + updated := testutil.VerifyResourceEnvVarUpdate(clients, config, envVarPostfix, deploymentFuncs) if !updated { t.Errorf("Deployment was not updated") } @@ -2492,24 +2649,27 @@ func TestRollingUpgradeForDeploymentWithSecretInProjectedVolumeinInitContainerUs if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + testRollingUpgradeInvokeDeleteStrategyErs(t, clients, config, deploymentFuncs, collectors, envVarPostfix) } func TestRollingUpgradeForDeploymentWithSecretAsEnvVarUsingErs(t *testing.T) { options.ReloadStrategy = constants.EnvVarsReloadStrategy + envVarPostfix := constants.SecretEnvVarPostfix shaData := testutil.ConvertResourceToSHA(testutil.SecretResourceType, ersNamespace, ersSecretWithEnvName, "dGVzdFVwZGF0ZWRTZWNyZXRFbmNvZGluZ0ZvclJlbG9hZGVy") - config := getConfigWithAnnotations(constants.SecretEnvVarPostfix, ersSecretWithEnvName, shaData, options.ReloaderAutoAnnotation, options.SecretReloaderAutoAnnotation) + config := getConfigWithAnnotations(envVarPostfix, ersSecretWithEnvName, shaData, options.ReloaderAutoAnnotation, options.SecretReloaderAutoAnnotation) deploymentFuncs := GetDeploymentRollingUpgradeFuncs() collectors := getCollectors() - err := PerformRollingUpgrade(clients, config, deploymentFuncs, collectors, nil) + err := PerformAction(clients, config, deploymentFuncs, collectors, nil, invokeReloadStrategy) time.Sleep(5 * time.Second) if err != nil { t.Errorf("Rolling upgrade failed for Deployment with Secret") } logrus.Infof("Verifying deployment update") - updated := testutil.VerifyResourceEnvVarUpdate(clients, config, constants.SecretEnvVarPostfix, deploymentFuncs) + updated := testutil.VerifyResourceEnvVarUpdate(clients, config, envVarPostfix, deploymentFuncs) if !updated { t.Errorf("Deployment was not updated") } @@ -2517,24 +2677,27 @@ func TestRollingUpgradeForDeploymentWithSecretAsEnvVarUsingErs(t *testing.T) { if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + testRollingUpgradeInvokeDeleteStrategyErs(t, clients, config, deploymentFuncs, collectors, envVarPostfix) } func TestRollingUpgradeForDeploymentWithSecretAsEnvVarFromUsingErs(t *testing.T) { options.ReloadStrategy = constants.EnvVarsReloadStrategy + envVarPostfix := constants.SecretEnvVarPostfix shaData := testutil.ConvertResourceToSHA(testutil.SecretResourceType, ersNamespace, ersSecretWithEnvFromName, "dGVzdFVwZGF0ZWRTZWNyZXRFbmNvZGluZ0ZvclJlbG9hZGVy") - config := getConfigWithAnnotations(constants.SecretEnvVarPostfix, ersSecretWithEnvFromName, shaData, options.ReloaderAutoAnnotation, options.SecretReloaderAutoAnnotation) + config := getConfigWithAnnotations(envVarPostfix, ersSecretWithEnvFromName, shaData, options.ReloaderAutoAnnotation, options.SecretReloaderAutoAnnotation) deploymentFuncs := GetDeploymentRollingUpgradeFuncs() collectors := getCollectors() - err := PerformRollingUpgrade(clients, config, deploymentFuncs, collectors, nil) + err := PerformAction(clients, config, deploymentFuncs, collectors, nil, invokeReloadStrategy) time.Sleep(5 * time.Second) if err != nil { t.Errorf("Rolling upgrade failed for Deployment with Secret") } logrus.Infof("Verifying deployment update") - updated := testutil.VerifyResourceEnvVarUpdate(clients, config, constants.SecretEnvVarPostfix, deploymentFuncs) + updated := testutil.VerifyResourceEnvVarUpdate(clients, config, envVarPostfix, deploymentFuncs) if !updated { t.Errorf("Deployment was not updated") } @@ -2542,24 +2705,27 @@ func TestRollingUpgradeForDeploymentWithSecretAsEnvVarFromUsingErs(t *testing.T) if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + testRollingUpgradeInvokeDeleteStrategyErs(t, clients, config, deploymentFuncs, collectors, envVarPostfix) } func TestRollingUpgradeForDeploymentWithSecretAsEnvVarInInitContainerUsingErs(t *testing.T) { options.ReloadStrategy = constants.EnvVarsReloadStrategy + envVarPostfix := constants.SecretEnvVarPostfix shaData := testutil.ConvertResourceToSHA(testutil.SecretResourceType, ersNamespace, ersSecretWithInitEnv, "dGVzdFVwZGF0ZWRTZWNyZXRFbmNvZGluZ0ZvclJlbG9hZGVy") - config := getConfigWithAnnotations(constants.SecretEnvVarPostfix, ersSecretWithInitEnv, shaData, options.ReloaderAutoAnnotation, options.SecretReloaderAutoAnnotation) + config := getConfigWithAnnotations(envVarPostfix, ersSecretWithInitEnv, shaData, options.ReloaderAutoAnnotation, options.SecretReloaderAutoAnnotation) deploymentFuncs := GetDeploymentRollingUpgradeFuncs() collectors := getCollectors() - err := PerformRollingUpgrade(clients, config, deploymentFuncs, collectors, nil) + err := PerformAction(clients, config, deploymentFuncs, collectors, nil, invokeReloadStrategy) time.Sleep(5 * time.Second) if err != nil { t.Errorf("Rolling upgrade failed for Deployment with Secret") } logrus.Infof("Verifying deployment update") - updated := testutil.VerifyResourceEnvVarUpdate(clients, config, constants.SecretEnvVarPostfix, deploymentFuncs) + updated := testutil.VerifyResourceEnvVarUpdate(clients, config, envVarPostfix, deploymentFuncs) if !updated { t.Errorf("Deployment was not updated") } @@ -2567,24 +2733,27 @@ func TestRollingUpgradeForDeploymentWithSecretAsEnvVarInInitContainerUsingErs(t if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + testRollingUpgradeInvokeDeleteStrategyErs(t, clients, config, deploymentFuncs, collectors, envVarPostfix) } func TestRollingUpgradeForDeploymentWithSecretAutoAnnotationUsingErs(t *testing.T) { options.ReloadStrategy = constants.EnvVarsReloadStrategy + envVarPostfix := constants.SecretEnvVarPostfix shaData := testutil.ConvertResourceToSHA(testutil.SecretResourceType, ersNamespace, ersSecretWithSecretAutoAnnotation, "dGVzdFVwZGF0ZWRTZWNyZXRFbmNvZGluZ0ZvclJlbG9hZGVy") - config := getConfigWithAnnotations(constants.SecretEnvVarPostfix, ersSecretWithSecretAutoAnnotation, shaData, "", options.SecretReloaderAutoAnnotation) + config := getConfigWithAnnotations(envVarPostfix, ersSecretWithSecretAutoAnnotation, shaData, "", options.SecretReloaderAutoAnnotation) deploymentFuncs := GetDeploymentRollingUpgradeFuncs() collectors := getCollectors() - err := PerformRollingUpgrade(clients, config, deploymentFuncs, collectors, nil) + err := PerformAction(clients, config, deploymentFuncs, collectors, nil, invokeReloadStrategy) time.Sleep(5 * time.Second) if err != nil { t.Errorf("Rolling upgrade failed for Deployment with Secret") } logrus.Infof("Verifying deployment update") - updated := testutil.VerifyResourceEnvVarUpdate(clients, config, constants.SecretEnvVarPostfix, deploymentFuncs) + updated := testutil.VerifyResourceEnvVarUpdate(clients, config, envVarPostfix, deploymentFuncs) if !updated { t.Errorf("Deployment was not updated") } @@ -2592,24 +2761,27 @@ func TestRollingUpgradeForDeploymentWithSecretAutoAnnotationUsingErs(t *testing. if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + testRollingUpgradeInvokeDeleteStrategyErs(t, clients, config, deploymentFuncs, collectors, envVarPostfix) } func TestRollingUpgradeForDeploymentWithConfigMapAutoAnnotationUsingErs(t *testing.T) { options.ReloadStrategy = constants.EnvVarsReloadStrategy + envVarPostfix := constants.ConfigmapEnvVarPostfix shaData := testutil.ConvertResourceToSHA(testutil.ConfigmapResourceType, ersNamespace, ersConfigmapWithConfigMapAutoAnnotation, "www.facebook.com") - config := getConfigWithAnnotations(constants.ConfigmapEnvVarPostfix, ersConfigmapWithConfigMapAutoAnnotation, shaData, "", options.ConfigmapReloaderAutoAnnotation) + config := getConfigWithAnnotations(envVarPostfix, ersConfigmapWithConfigMapAutoAnnotation, shaData, "", options.ConfigmapReloaderAutoAnnotation) deploymentFuncs := GetDeploymentRollingUpgradeFuncs() collectors := getCollectors() - err := PerformRollingUpgrade(clients, config, deploymentFuncs, collectors, nil) + err := PerformAction(clients, config, deploymentFuncs, collectors, nil, invokeReloadStrategy) time.Sleep(5 * time.Second) if err != nil { t.Errorf("Rolling upgrade failed for Deployment with ConfigMap") } logrus.Infof("Verifying deployment update") - updated := testutil.VerifyResourceEnvVarUpdate(clients, config, constants.ConfigmapEnvVarPostfix, deploymentFuncs) + updated := testutil.VerifyResourceEnvVarUpdate(clients, config, envVarPostfix, deploymentFuncs) if !updated { t.Errorf("Deployment was not updated") } @@ -2617,24 +2789,27 @@ func TestRollingUpgradeForDeploymentWithConfigMapAutoAnnotationUsingErs(t *testi if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + testRollingUpgradeInvokeDeleteStrategyErs(t, clients, config, deploymentFuncs, collectors, envVarPostfix) } func TestRollingUpgradeForDaemonSetWithConfigmapUsingErs(t *testing.T) { options.ReloadStrategy = constants.EnvVarsReloadStrategy + envVarPostfix := constants.ConfigmapEnvVarPostfix shaData := testutil.ConvertResourceToSHA(testutil.ConfigmapResourceType, ersNamespace, ersConfigmapName, "www.facebook.com") - config := getConfigWithAnnotations(constants.ConfigmapEnvVarPostfix, ersConfigmapName, shaData, options.ConfigmapUpdateOnChangeAnnotation, options.ConfigmapReloaderAutoAnnotation) + config := getConfigWithAnnotations(envVarPostfix, ersConfigmapName, shaData, options.ConfigmapUpdateOnChangeAnnotation, options.ConfigmapReloaderAutoAnnotation) daemonSetFuncs := GetDaemonSetRollingUpgradeFuncs() collectors := getCollectors() - err := PerformRollingUpgrade(clients, config, daemonSetFuncs, collectors, nil) + err := PerformAction(clients, config, daemonSetFuncs, collectors, nil, invokeReloadStrategy) time.Sleep(5 * time.Second) if err != nil { t.Errorf("Rolling upgrade failed for DaemonSet with configmap") } logrus.Infof("Verifying daemonSet update") - updated := testutil.VerifyResourceEnvVarUpdate(clients, config, constants.ConfigmapEnvVarPostfix, daemonSetFuncs) + updated := testutil.VerifyResourceEnvVarUpdate(clients, config, envVarPostfix, daemonSetFuncs) if !updated { t.Errorf("DaemonSet was not updated") } @@ -2642,24 +2817,27 @@ func TestRollingUpgradeForDaemonSetWithConfigmapUsingErs(t *testing.T) { if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + testRollingUpgradeInvokeDeleteStrategyErs(t, clients, config, daemonSetFuncs, collectors, envVarPostfix) } func TestRollingUpgradeForDaemonSetWithConfigmapInProjectedVolumeUsingErs(t *testing.T) { options.ReloadStrategy = constants.EnvVarsReloadStrategy + envVarPostfix := constants.ConfigmapEnvVarPostfix shaData := testutil.ConvertResourceToSHA(testutil.ConfigmapResourceType, ersNamespace, ersProjectedConfigMapName, "www.facebook.com") - config := getConfigWithAnnotations(constants.ConfigmapEnvVarPostfix, ersProjectedConfigMapName, shaData, options.ConfigmapUpdateOnChangeAnnotation, options.ConfigmapReloaderAutoAnnotation) + config := getConfigWithAnnotations(envVarPostfix, ersProjectedConfigMapName, shaData, options.ConfigmapUpdateOnChangeAnnotation, options.ConfigmapReloaderAutoAnnotation) daemonSetFuncs := GetDaemonSetRollingUpgradeFuncs() collectors := getCollectors() - err := PerformRollingUpgrade(clients, config, daemonSetFuncs, collectors, nil) + err := PerformAction(clients, config, daemonSetFuncs, collectors, nil, invokeReloadStrategy) time.Sleep(5 * time.Second) if err != nil { t.Errorf("Rolling upgrade failed for DaemonSet with configmap in projected volume") } logrus.Infof("Verifying daemonSet update") - updated := testutil.VerifyResourceEnvVarUpdate(clients, config, constants.ConfigmapEnvVarPostfix, daemonSetFuncs) + updated := testutil.VerifyResourceEnvVarUpdate(clients, config, envVarPostfix, daemonSetFuncs) if !updated { t.Errorf("DaemonSet was not updated") } @@ -2667,24 +2845,27 @@ func TestRollingUpgradeForDaemonSetWithConfigmapInProjectedVolumeUsingErs(t *tes if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + testRollingUpgradeInvokeDeleteStrategyErs(t, clients, config, daemonSetFuncs, collectors, envVarPostfix) } func TestRollingUpgradeForDaemonSetWithConfigmapAsEnvVarUsingErs(t *testing.T) { options.ReloadStrategy = constants.EnvVarsReloadStrategy + envVarPostfix := constants.ConfigmapEnvVarPostfix shaData := testutil.ConvertResourceToSHA(testutil.ConfigmapResourceType, ersNamespace, ersConfigmapWithEnvName, "www.facebook.com") - config := getConfigWithAnnotations(constants.ConfigmapEnvVarPostfix, ersConfigmapWithEnvName, shaData, options.ReloaderAutoAnnotation, options.ConfigmapReloaderAutoAnnotation) + config := getConfigWithAnnotations(envVarPostfix, ersConfigmapWithEnvName, shaData, options.ReloaderAutoAnnotation, options.ConfigmapReloaderAutoAnnotation) daemonSetFuncs := GetDaemonSetRollingUpgradeFuncs() collectors := getCollectors() - err := PerformRollingUpgrade(clients, config, daemonSetFuncs, collectors, nil) + err := PerformAction(clients, config, daemonSetFuncs, collectors, nil, invokeReloadStrategy) time.Sleep(5 * time.Second) if err != nil { t.Errorf("Rolling upgrade failed for DaemonSet with configmap used as env var") } logrus.Infof("Verifying daemonSet update") - updated := testutil.VerifyResourceEnvVarUpdate(clients, config, constants.ConfigmapEnvVarPostfix, daemonSetFuncs) + updated := testutil.VerifyResourceEnvVarUpdate(clients, config, envVarPostfix, daemonSetFuncs) if !updated { t.Errorf("DaemonSet was not updated") } @@ -2692,24 +2873,27 @@ func TestRollingUpgradeForDaemonSetWithConfigmapAsEnvVarUsingErs(t *testing.T) { if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + testRollingUpgradeInvokeDeleteStrategyErs(t, clients, config, daemonSetFuncs, collectors, envVarPostfix) } func TestRollingUpgradeForDaemonSetWithSecretUsingErs(t *testing.T) { options.ReloadStrategy = constants.EnvVarsReloadStrategy + envVarPostfix := constants.SecretEnvVarPostfix shaData := testutil.ConvertResourceToSHA(testutil.SecretResourceType, ersNamespace, ersSecretName, "d3d3LmZhY2Vib29rLmNvbQ==") - config := getConfigWithAnnotations(constants.SecretEnvVarPostfix, ersSecretName, shaData, options.SecretUpdateOnChangeAnnotation, options.SecretReloaderAutoAnnotation) + config := getConfigWithAnnotations(envVarPostfix, ersSecretName, shaData, options.SecretUpdateOnChangeAnnotation, options.SecretReloaderAutoAnnotation) daemonSetFuncs := GetDaemonSetRollingUpgradeFuncs() collectors := getCollectors() - err := PerformRollingUpgrade(clients, config, daemonSetFuncs, collectors, nil) + err := PerformAction(clients, config, daemonSetFuncs, collectors, nil, invokeReloadStrategy) time.Sleep(5 * time.Second) if err != nil { t.Errorf("Rolling upgrade failed for DaemonSet with secret") } logrus.Infof("Verifying daemonSet update") - updated := testutil.VerifyResourceEnvVarUpdate(clients, config, constants.SecretEnvVarPostfix, daemonSetFuncs) + updated := testutil.VerifyResourceEnvVarUpdate(clients, config, envVarPostfix, daemonSetFuncs) if !updated { t.Errorf("DaemonSet was not updated") } @@ -2717,24 +2901,27 @@ func TestRollingUpgradeForDaemonSetWithSecretUsingErs(t *testing.T) { if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + testRollingUpgradeInvokeDeleteStrategyErs(t, clients, config, daemonSetFuncs, collectors, envVarPostfix) } func TestRollingUpgradeForDaemonSetWithSecretInProjectedVolumeUsingErs(t *testing.T) { options.ReloadStrategy = constants.EnvVarsReloadStrategy + envVarPostfix := constants.SecretEnvVarPostfix shaData := testutil.ConvertResourceToSHA(testutil.SecretResourceType, ersNamespace, ersProjectedSecretName, "d3d3LmZhY2Vib29rLmNvbQ==") - config := getConfigWithAnnotations(constants.SecretEnvVarPostfix, ersProjectedSecretName, shaData, options.SecretUpdateOnChangeAnnotation, options.SecretReloaderAutoAnnotation) + config := getConfigWithAnnotations(envVarPostfix, ersProjectedSecretName, shaData, options.SecretUpdateOnChangeAnnotation, options.SecretReloaderAutoAnnotation) daemonSetFuncs := GetDaemonSetRollingUpgradeFuncs() collectors := getCollectors() - err := PerformRollingUpgrade(clients, config, daemonSetFuncs, collectors, nil) + err := PerformAction(clients, config, daemonSetFuncs, collectors, nil, invokeReloadStrategy) time.Sleep(5 * time.Second) if err != nil { t.Errorf("Rolling upgrade failed for DaemonSet with secret in projected volume") } logrus.Infof("Verifying daemonSet update") - updated := testutil.VerifyResourceEnvVarUpdate(clients, config, constants.SecretEnvVarPostfix, daemonSetFuncs) + updated := testutil.VerifyResourceEnvVarUpdate(clients, config, envVarPostfix, daemonSetFuncs) if !updated { t.Errorf("DaemonSet was not updated") } @@ -2742,24 +2929,27 @@ func TestRollingUpgradeForDaemonSetWithSecretInProjectedVolumeUsingErs(t *testin if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + testRollingUpgradeInvokeDeleteStrategyErs(t, clients, config, daemonSetFuncs, collectors, envVarPostfix) } func TestRollingUpgradeForStatefulSetWithConfigmapUsingErs(t *testing.T) { options.ReloadStrategy = constants.EnvVarsReloadStrategy + envVarPostfix := constants.ConfigmapEnvVarPostfix shaData := testutil.ConvertResourceToSHA(testutil.ConfigmapResourceType, ersNamespace, ersConfigmapName, "www.twitter.com") - config := getConfigWithAnnotations(constants.ConfigmapEnvVarPostfix, ersConfigmapName, shaData, options.ConfigmapUpdateOnChangeAnnotation, options.ConfigmapReloaderAutoAnnotation) + config := getConfigWithAnnotations(envVarPostfix, ersConfigmapName, shaData, options.ConfigmapUpdateOnChangeAnnotation, options.ConfigmapReloaderAutoAnnotation) statefulSetFuncs := GetStatefulSetRollingUpgradeFuncs() collectors := getCollectors() - err := PerformRollingUpgrade(clients, config, statefulSetFuncs, collectors, nil) + err := PerformAction(clients, config, statefulSetFuncs, collectors, nil, invokeReloadStrategy) time.Sleep(5 * time.Second) if err != nil { t.Errorf("Rolling upgrade failed for StatefulSet with configmap") } logrus.Infof("Verifying statefulSet update") - updated := testutil.VerifyResourceEnvVarUpdate(clients, config, constants.ConfigmapEnvVarPostfix, statefulSetFuncs) + updated := testutil.VerifyResourceEnvVarUpdate(clients, config, envVarPostfix, statefulSetFuncs) if !updated { t.Errorf("StatefulSet was not updated") } @@ -2767,24 +2957,27 @@ func TestRollingUpgradeForStatefulSetWithConfigmapUsingErs(t *testing.T) { if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + testRollingUpgradeInvokeDeleteStrategyErs(t, clients, config, statefulSetFuncs, collectors, envVarPostfix) } func TestRollingUpgradeForStatefulSetWithConfigmapInProjectedVolumeUsingErs(t *testing.T) { options.ReloadStrategy = constants.EnvVarsReloadStrategy + envVarPostfix := constants.ConfigmapEnvVarPostfix shaData := testutil.ConvertResourceToSHA(testutil.ConfigmapResourceType, ersNamespace, ersProjectedConfigMapName, "www.twitter.com") - config := getConfigWithAnnotations(constants.ConfigmapEnvVarPostfix, ersProjectedConfigMapName, shaData, options.ConfigmapUpdateOnChangeAnnotation, options.ConfigmapReloaderAutoAnnotation) + config := getConfigWithAnnotations(envVarPostfix, ersProjectedConfigMapName, shaData, options.ConfigmapUpdateOnChangeAnnotation, options.ConfigmapReloaderAutoAnnotation) statefulSetFuncs := GetStatefulSetRollingUpgradeFuncs() collectors := getCollectors() - err := PerformRollingUpgrade(clients, config, statefulSetFuncs, collectors, nil) + err := PerformAction(clients, config, statefulSetFuncs, collectors, nil, invokeReloadStrategy) time.Sleep(5 * time.Second) if err != nil { t.Errorf("Rolling upgrade failed for StatefulSet with configmap in projected volume") } logrus.Infof("Verifying statefulSet update") - updated := testutil.VerifyResourceEnvVarUpdate(clients, config, constants.ConfigmapEnvVarPostfix, statefulSetFuncs) + updated := testutil.VerifyResourceEnvVarUpdate(clients, config, envVarPostfix, statefulSetFuncs) if !updated { t.Errorf("StatefulSet was not updated") } @@ -2792,24 +2985,27 @@ func TestRollingUpgradeForStatefulSetWithConfigmapInProjectedVolumeUsingErs(t *t if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + testRollingUpgradeInvokeDeleteStrategyErs(t, clients, config, statefulSetFuncs, collectors, envVarPostfix) } func TestRollingUpgradeForStatefulSetWithSecretUsingErs(t *testing.T) { options.ReloadStrategy = constants.EnvVarsReloadStrategy + envVarPostfix := constants.SecretEnvVarPostfix shaData := testutil.ConvertResourceToSHA(testutil.SecretResourceType, ersNamespace, ersSecretName, "d3d3LnR3aXR0ZXIuY29t") - config := getConfigWithAnnotations(constants.SecretEnvVarPostfix, ersSecretName, shaData, options.SecretUpdateOnChangeAnnotation, options.SecretReloaderAutoAnnotation) + config := getConfigWithAnnotations(envVarPostfix, ersSecretName, shaData, options.SecretUpdateOnChangeAnnotation, options.SecretReloaderAutoAnnotation) statefulSetFuncs := GetStatefulSetRollingUpgradeFuncs() collectors := getCollectors() - err := PerformRollingUpgrade(clients, config, statefulSetFuncs, collectors, nil) + err := PerformAction(clients, config, statefulSetFuncs, collectors, nil, invokeReloadStrategy) time.Sleep(5 * time.Second) if err != nil { t.Errorf("Rolling upgrade failed for StatefulSet with secret") } logrus.Infof("Verifying statefulSet update") - updated := testutil.VerifyResourceEnvVarUpdate(clients, config, constants.SecretEnvVarPostfix, statefulSetFuncs) + updated := testutil.VerifyResourceEnvVarUpdate(clients, config, envVarPostfix, statefulSetFuncs) if !updated { t.Errorf("StatefulSet was not updated") } @@ -2817,24 +3013,27 @@ func TestRollingUpgradeForStatefulSetWithSecretUsingErs(t *testing.T) { if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + testRollingUpgradeInvokeDeleteStrategyErs(t, clients, config, statefulSetFuncs, collectors, envVarPostfix) } func TestRollingUpgradeForStatefulSetWithSecretInProjectedVolumeUsingErs(t *testing.T) { options.ReloadStrategy = constants.EnvVarsReloadStrategy + envVarPostfix := constants.SecretEnvVarPostfix shaData := testutil.ConvertResourceToSHA(testutil.SecretResourceType, ersNamespace, ersProjectedSecretName, "d3d3LnR3aXR0ZXIuY29t") - config := getConfigWithAnnotations(constants.SecretEnvVarPostfix, ersProjectedSecretName, shaData, options.SecretUpdateOnChangeAnnotation, options.SecretReloaderAutoAnnotation) + config := getConfigWithAnnotations(envVarPostfix, ersProjectedSecretName, shaData, options.SecretUpdateOnChangeAnnotation, options.SecretReloaderAutoAnnotation) statefulSetFuncs := GetStatefulSetRollingUpgradeFuncs() collectors := getCollectors() - err := PerformRollingUpgrade(clients, config, statefulSetFuncs, collectors, nil) + err := PerformAction(clients, config, statefulSetFuncs, collectors, nil, invokeReloadStrategy) time.Sleep(5 * time.Second) if err != nil { t.Errorf("Rolling upgrade failed for StatefulSet with secret in projected volume") } logrus.Infof("Verifying statefulSet update") - updated := testutil.VerifyResourceEnvVarUpdate(clients, config, constants.SecretEnvVarPostfix, statefulSetFuncs) + updated := testutil.VerifyResourceEnvVarUpdate(clients, config, envVarPostfix, statefulSetFuncs) if !updated { t.Errorf("StatefulSet was not updated") } @@ -2842,24 +3041,27 @@ func TestRollingUpgradeForStatefulSetWithSecretInProjectedVolumeUsingErs(t *test if promtestutil.ToFloat64(collectors.Reloaded.With(labelSucceeded)) != 1 { t.Errorf("Counter was not increased") } + + testRollingUpgradeInvokeDeleteStrategyErs(t, clients, config, statefulSetFuncs, collectors, envVarPostfix) } func TestRollingUpgradeForDeploymentWithPodAnnotationsUsingErs(t *testing.T) { options.ReloadStrategy = constants.EnvVarsReloadStrategy + envVarPostfix := constants.ConfigmapEnvVarPostfix shaData := testutil.ConvertResourceToSHA(testutil.ConfigmapResourceType, ersNamespace, ersConfigmapWithPodAnnotations, "www.stakater.com") - config := getConfigWithAnnotations(constants.ConfigmapEnvVarPostfix, ersConfigmapWithPodAnnotations, shaData, options.ConfigmapUpdateOnChangeAnnotation, options.ConfigmapReloaderAutoAnnotation) + config := getConfigWithAnnotations(envVarPostfix, ersConfigmapWithPodAnnotations, shaData, options.ConfigmapUpdateOnChangeAnnotation, options.ConfigmapReloaderAutoAnnotation) deploymentFuncs := GetDeploymentRollingUpgradeFuncs() collectors := getCollectors() - err := PerformRollingUpgrade(clients, config, deploymentFuncs, collectors, nil) + err := PerformAction(clients, config, deploymentFuncs, collectors, nil, invokeReloadStrategy) time.Sleep(5 * time.Second) if err != nil { t.Errorf("Rolling upgrade failed for Deployment with pod annotations") } logrus.Infof("Verifying deployment update") - envName := constants.EnvVarPrefix + util.ConvertToEnvVarName(config.ResourceName) + "_" + constants.ConfigmapEnvVarPostfix + envName := constants.EnvVarPrefix + util.ConvertToEnvVarName(config.ResourceName) + "_" + envVarPostfix items := deploymentFuncs.ItemsFunc(clients, config.Namespace) var foundPod, foundBoth bool for _, i := range items { @@ -2899,16 +3101,17 @@ func TestRollingUpgradeForDeploymentWithPodAnnotationsUsingErs(t *testing.T) { func TestFailedRollingUpgradeUsingErs(t *testing.T) { options.ReloadStrategy = constants.EnvVarsReloadStrategy + envVarPostfix := constants.ConfigmapEnvVarPostfix shaData := testutil.ConvertResourceToSHA(testutil.ConfigmapResourceType, ersNamespace, ersConfigmapName, "fail.stakater.com") - config := getConfigWithAnnotations(constants.ConfigmapEnvVarPostfix, ersConfigmapName, shaData, options.ConfigmapUpdateOnChangeAnnotation, options.ConfigmapReloaderAutoAnnotation) + config := getConfigWithAnnotations(envVarPostfix, ersConfigmapName, shaData, options.ConfigmapUpdateOnChangeAnnotation, options.ConfigmapReloaderAutoAnnotation) deploymentFuncs := GetDeploymentRollingUpgradeFuncs() deploymentFuncs.UpdateFunc = func(_ kube.Clients, _ string, _ runtime.Object) error { return fmt.Errorf("error") } collectors := getCollectors() - _ = PerformRollingUpgrade(clients, config, deploymentFuncs, collectors, nil) + _ = PerformAction(clients, config, deploymentFuncs, collectors, nil, invokeReloadStrategy) if promtestutil.ToFloat64(collectors.Reloaded.With(labelFailed)) != 1 { t.Errorf("Counter was not increased") diff --git a/internal/pkg/options/flags.go b/internal/pkg/options/flags.go index 0e39424f..a1ae090e 100644 --- a/internal/pkg/options/flags.go +++ b/internal/pkg/options/flags.go @@ -32,7 +32,9 @@ var ( // ReloadStrategy Specify the update strategy ReloadStrategy = constants.EnvVarsReloadStrategy // ReloadOnCreate Adds support to watch create events - ReloadOnCreate = "false" + ReloadOnCreate = "false" + // ReloadOnDelete Adds support to watch delete events + ReloadOnDelete = "false" SyncAfterRestart = false // EnableHA adds support for running multiple replicas via leadership election EnableHA = false diff --git a/internal/pkg/testutil/kube.go b/internal/pkg/testutil/kube.go index 233f61ed..52780d1e 100644 --- a/internal/pkg/testutil/kube.go +++ b/internal/pkg/testutil/kube.go @@ -934,6 +934,55 @@ func VerifyResourceEnvVarUpdate(clients kube.Clients, config util.Config, envVar return false } +// VerifyResourceEnvVarRemoved verifies whether the rolling upgrade happened or not and all Envvars SKAKATER_name_CONFIGMAP/SECRET are removed +func VerifyResourceEnvVarRemoved(clients kube.Clients, config util.Config, envVarPostfix string, upgradeFuncs callbacks.RollingUpgradeFuncs) bool { + items := upgradeFuncs.ItemsFunc(clients, config.Namespace) + for _, i := range items { + containers := upgradeFuncs.ContainersFunc(i) + accessor, err := meta.Accessor(i) + if err != nil { + return false + } + + annotations := accessor.GetAnnotations() + // match statefulsets with the correct annotation + + annotationValue := annotations[config.Annotation] + searchAnnotationValue := annotations[options.AutoSearchAnnotation] + reloaderEnabledValue := annotations[options.ReloaderAutoAnnotation] + typedAutoAnnotationEnabledValue := annotations[config.TypedAutoAnnotation] + reloaderEnabled, err := strconv.ParseBool(reloaderEnabledValue) + typedAutoAnnotationEnabled, errTyped := strconv.ParseBool(typedAutoAnnotationEnabledValue) + + matches := false + if err == nil && reloaderEnabled || errTyped == nil && typedAutoAnnotationEnabled { + matches = true + } else if annotationValue != "" { + values := strings.Split(annotationValue, ",") + for _, value := range values { + value = strings.Trim(value, " ") + if value == config.ResourceName { + matches = true + break + } + } + } else if searchAnnotationValue == "true" { + if config.ResourceAnnotations[options.SearchMatchAnnotation] == "true" { + matches = true + } + } + + if matches { + envName := constants.EnvVarPrefix + util.ConvertToEnvVarName(config.ResourceName) + "_" + envVarPostfix + value := GetResourceSHAFromEnvVar(containers, envName) + if value == "" { + return true + } + } + } + return false +} + // VerifyResourceAnnotationUpdate verifies whether the rolling upgrade happened or not func VerifyResourceAnnotationUpdate(clients kube.Clients, config util.Config, upgradeFuncs callbacks.RollingUpgradeFuncs) bool { items := upgradeFuncs.ItemsFunc(clients, config.Namespace) @@ -978,3 +1027,7 @@ func VerifyResourceAnnotationUpdate(clients kube.Clients, config util.Config, up } return false } + +func GetSHAfromEmptyData() string { + return crypto.GenerateSHA("") +} From 757f76c739b4a30f78f7b5e9fb2ab4a4a14cb093 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 19 Jun 2024 08:03:50 +0000 Subject: [PATCH 09/29] chore(deps): update stakater/.github action to v0.0.82 --- .github/workflows/pull_request.yaml | 2 +- .github/workflows/pull_request_docs.yaml | 4 ++-- .github/workflows/push_docs.yaml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index 2242fb9e..71e29e5f 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -23,7 +23,7 @@ env: jobs: qa: - uses: stakater/.github/.github/workflows/pull_request_doc_qa.yaml@v0.0.79 + uses: stakater/.github/.github/workflows/pull_request_doc_qa.yaml@v0.0.82 with: MD_CONFIG: .github/md_config.json DOC_SRC: README.md diff --git a/.github/workflows/pull_request_docs.yaml b/.github/workflows/pull_request_docs.yaml index 150ce4c4..10f5cee7 100644 --- a/.github/workflows/pull_request_docs.yaml +++ b/.github/workflows/pull_request_docs.yaml @@ -15,13 +15,13 @@ on: jobs: qa: - uses: stakater/.github/.github/workflows/pull_request_doc_qa.yaml@v0.0.79 + uses: stakater/.github/.github/workflows/pull_request_doc_qa.yaml@v0.0.82 with: MD_CONFIG: .github/md_config.json DOC_SRC: docs MD_LINT_CONFIG: .markdownlint.yaml build: - uses: stakater/.github/.github/workflows/pull_request_container_build.yaml@v0.0.79 + uses: stakater/.github/.github/workflows/pull_request_container_build.yaml@v0.0.82 with: DOCKER_FILE_PATH: Dockerfile-docs secrets: diff --git a/.github/workflows/push_docs.yaml b/.github/workflows/push_docs.yaml index aa913f04..b778ed8f 100644 --- a/.github/workflows/push_docs.yaml +++ b/.github/workflows/push_docs.yaml @@ -16,7 +16,7 @@ on: jobs: push: - uses: stakater/.github/.github/workflows/push_container.yaml@v0.0.79 + uses: stakater/.github/.github/workflows/push_container.yaml@v0.0.82 with: DOCKER_FILE_PATH: Dockerfile-docs RELEASE_BRANCH: master From 1e285cbc11bceb60ddbb8ced32d0ed1d6c0dfd42 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 19 Jun 2024 08:14:30 +0000 Subject: [PATCH 10/29] fix(deps): update module github.com/argoproj/argo-rollouts to v1.7.0 --- go.mod | 32 ++++++++++++++++---------------- go.sum | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 16 deletions(-) diff --git a/go.mod b/go.mod index 5055086f..07c52040 100644 --- a/go.mod +++ b/go.mod @@ -3,17 +3,17 @@ module github.com/stakater/Reloader go 1.21 require ( - github.com/argoproj/argo-rollouts v1.6.6 + github.com/argoproj/argo-rollouts v1.7.0 github.com/openshift/api v3.9.0+incompatible github.com/openshift/client-go v0.0.0-20231110140829-a6ca51f6d5ba github.com/parnurzeal/gorequest v0.2.16 github.com/prometheus/client_golang v1.19.1 github.com/sirupsen/logrus v1.9.3 github.com/spf13/cobra v1.8.1 - k8s.io/api v0.28.4 - k8s.io/apimachinery v0.28.4 - k8s.io/client-go v0.28.4 - k8s.io/kubectl v0.28.4 + k8s.io/api v0.29.3 + k8s.io/apimachinery v0.29.3 + k8s.io/client-go v0.29.3 + k8s.io/kubectl v0.29.3 k8s.io/utils v0.0.0-20240423183400-0849a56e8f22 ) @@ -22,19 +22,19 @@ require ( github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/elazarl/goproxy v0.0.0-20221015165544-a0805db90819 // indirect - github.com/emicklei/go-restful/v3 v3.10.1 // indirect + github.com/emicklei/go-restful/v3 v3.11.0 // indirect github.com/evanphx/json-patch v5.6.0+incompatible // indirect - github.com/go-logr/logr v1.2.4 // indirect + github.com/go-logr/logr v1.3.0 // indirect github.com/go-openapi/jsonpointer v0.19.6 // indirect github.com/go-openapi/jsonreference v0.20.2 // indirect github.com/go-openapi/swag v0.22.3 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect - github.com/golang/protobuf v1.5.3 // indirect + github.com/golang/protobuf v1.5.4 // indirect github.com/google/gnostic-models v0.6.8 // indirect github.com/google/go-cmp v0.6.0 // indirect github.com/google/gofuzz v1.2.0 // indirect - github.com/google/uuid v1.3.0 // indirect + github.com/google/uuid v1.6.0 // indirect github.com/imdario/mergo v0.3.13 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/josharian/intern v1.0.0 // indirect @@ -44,28 +44,28 @@ require ( github.com/modern-go/reflect2 v1.0.2 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/pkg/errors v0.9.1 // indirect - github.com/prometheus/client_model v0.5.0 // indirect + github.com/prometheus/client_model v0.6.0 // indirect github.com/prometheus/common v0.48.0 // indirect github.com/prometheus/procfs v0.12.0 // indirect github.com/smartystreets/goconvey v1.7.2 // indirect github.com/spf13/pflag v1.0.5 // indirect golang.org/x/net v0.25.0 // indirect - golang.org/x/oauth2 v0.16.0 // indirect + golang.org/x/oauth2 v0.18.0 // indirect golang.org/x/sys v0.20.0 // indirect golang.org/x/term v0.20.0 // indirect golang.org/x/text v0.15.0 // indirect golang.org/x/time v0.3.0 // indirect - google.golang.org/appengine v1.6.7 // indirect + google.golang.org/appengine v1.6.8 // indirect google.golang.org/protobuf v1.33.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - k8s.io/klog/v2 v2.100.1 // indirect - k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9 // indirect + k8s.io/klog/v2 v2.110.1 // indirect + k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect moul.io/http2curl v1.0.0 // indirect sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect - sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect - sigs.k8s.io/yaml v1.3.0 // indirect + sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect + sigs.k8s.io/yaml v1.4.0 // indirect ) // Replacements for argo-rollouts diff --git a/go.sum b/go.sum index a9d3b0e2..c22ba691 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,7 @@ github.com/argoproj/argo-rollouts v1.6.6 h1:JCJ0cGAwWkh2xCAHZ1OQmrobysRjCatmG9IZaLJpS1g= github.com/argoproj/argo-rollouts v1.6.6/go.mod h1:X2kTiBaYCSounmw1kmONdIZTwJNzNQYC0SrXUgSw9UI= +github.com/argoproj/argo-rollouts v1.7.0 h1:3Hv8MUwGIWuZe50+yyS/4X21t4jT4shdGvgDe0lG6aw= +github.com/argoproj/argo-rollouts v1.7.0/go.mod h1:Te4HrUELxKiBpK8lgk77o4gTa3mv8pXCd8xdPprKrbs= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= @@ -15,11 +17,15 @@ github.com/elazarl/goproxy v0.0.0-20221015165544-a0805db90819/go.mod h1:Ro8st/El github.com/elazarl/goproxy/ext v0.0.0-20190711103511-473e67f1d7d2/go.mod h1:gNh8nYJoAm43RfaxurUnxr+N1PwuFV3ZMl/efxlIlY8= github.com/emicklei/go-restful/v3 v3.10.1 h1:rc42Y5YTp7Am7CS630D7JmhRjq4UlEUuEKfrDac4bSQ= github.com/emicklei/go-restful/v3 v3.10.1/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= +github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxERmMY4rD+g= +github.com/emicklei/go-restful/v3 v3.11.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= github.com/evanphx/json-patch v5.6.0+incompatible h1:jBYDEEiFBPxA0v50tFdvOzQQTCvpL6mnFh5mB2/l16U= github.com/evanphx/json-patch v5.6.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.3.0 h1:2y3SDp0ZXuc6/cjLSZ+Q3ir+QB9T/iG5yYRXqsagWSY= +github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-openapi/jsonpointer v0.19.6 h1:eCs3fxoIi3Wh6vtgmLTOjdhSpiqphQ+DaPn38N2ZdrE= github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs= github.com/go-openapi/jsonreference v0.20.2 h1:3sVjiK66+uXK/6oQ8xgcRKcFgQ5KXa2KvnJRumpMGbE= @@ -34,11 +40,15 @@ github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/gnostic-models v0.6.8 h1:yo/ABAfM5IMRsS1VnXjTBvUb61tFIHozhlYvRgGre9I= github.com/google/gnostic-models v0.6.8/go.mod h1:5n7qKqH0f5wFt+aWF8CW6pZLLNOfYuF5OpfBSENuI8U= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= @@ -48,6 +58,8 @@ github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 h1:K6RDEckDVWvDI9JAJY github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk= @@ -96,6 +108,8 @@ github.com/prometheus/client_golang v1.19.1 h1:wZWJDwK+NameRJuPGDhlnFgx8e8HN3XHQ github.com/prometheus/client_golang v1.19.1/go.mod h1:mP78NwGzrVks5S2H6ab8+ZZGJLZUq1hoULYBAYBw1Ho= github.com/prometheus/client_model v0.5.0 h1:VQw1hfvPvk3Uv6Qf29VrPF32JB6rtbgI6cYPYQjL0Qw= github.com/prometheus/client_model v0.5.0/go.mod h1:dTiFglRmd66nLR9Pv9f0mZi7B7fk5Pm3gvsjB5tr+kI= +github.com/prometheus/client_model v0.6.0 h1:k1v3CzpSRUTrKMppY35TLwPvxHqBu0bYgxZzqGIgaos= +github.com/prometheus/client_model v0.6.0/go.mod h1:NTQHnmxFpouOD0DpvP4XujX3CdOAGQPoaGhyTchlyt8= github.com/prometheus/common v0.48.0 h1:QO8U2CdOzSn1BBsmXJXduaaW+dY/5QLjfB8svtSzKKE= github.com/prometheus/common v0.48.0/go.mod h1:0/KsvlIEfPQCQ5I2iNSAWKPZziNCvRs5EC6ILDTlAPc= github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= @@ -128,35 +142,51 @@ github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcU github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac= golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= golang.org/x/oauth2 v0.16.0 h1:aDkGMBSYxElaoP81NpoUoz2oo2R2wHdZpGToUxfyQrQ= golang.org/x/oauth2 v0.16.0/go.mod h1:hqZ+0LWXsiVoZpeld6jVt06P3adbS2Uu911W1SsJv2o= +golang.org/x/oauth2 v0.18.0 h1:09qnuIAgzdx1XplqJvW6CQqMCtGZykZWcXzPMPUusvI= +golang.org/x/oauth2 v0.18.0/go.mod h1:Wf7knwG0MPoWIMMBgFlEaSUDaKskp0dCfrlJRJXbBi8= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y= golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.20.0 h1:VnkxpohqXaOBYJtBmEppKUG6mXpi+4O6purfc2+sMhw= golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk= golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= @@ -166,6 +196,7 @@ golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3 golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.8.0 h1:vSDcovVPld282ceKgDimkRSC8kpaH1dgyc9UMzlt84Y= golang.org/x/tools v0.8.0/go.mod h1:JxBZ99ISMI5ViVkT1tr6tdNmXeTrcpVSD3vZ1RsRdN4= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -174,6 +205,8 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM= +google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= @@ -192,16 +225,28 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= k8s.io/api v0.28.4 h1:8ZBrLjwosLl/NYgv1P7EQLqoO8MGQApnbgH8tu3BMzY= k8s.io/api v0.28.4/go.mod h1:axWTGrY88s/5YE+JSt4uUi6NMM+gur1en2REMR7IRj0= +k8s.io/api v0.29.3 h1:2ORfZ7+bGC3YJqGpV0KSDDEVf8hdGQ6A03/50vj8pmw= +k8s.io/api v0.29.3/go.mod h1:y2yg2NTyHUUkIoTC+phinTnEa3KFM6RZ3szxt014a80= k8s.io/apimachinery v0.28.4 h1:zOSJe1mc+GxuMnFzD4Z/U1wst50X28ZNsn5bhgIIao8= k8s.io/apimachinery v0.28.4/go.mod h1:wI37ncBvfAoswfq626yPTe6Bz1c22L7uaJ8dho83mgg= +k8s.io/apimachinery v0.29.3 h1:2tbx+5L7RNvqJjn7RIuIKu9XTsIZ9Z5wX2G22XAa5EU= +k8s.io/apimachinery v0.29.3/go.mod h1:hx/S4V2PNW4OMg3WizRrHutyB5la0iCUbZym+W0EQIU= k8s.io/client-go v0.28.4 h1:Np5ocjlZcTrkyRJ3+T3PkXDpe4UpatQxj85+xjaD2wY= k8s.io/client-go v0.28.4/go.mod h1:0VDZFpgoZfelyP5Wqu0/r/TRYcLYuJ2U1KEeoaPa1N4= +k8s.io/client-go v0.29.3 h1:R/zaZbEAxqComZ9FHeQwOh3Y1ZUs7FaHKZdQtIc2WZg= +k8s.io/client-go v0.29.3/go.mod h1:tkDisCvgPfiRpxGnOORfkljmS+UrW+WtXAy2fTvXJB0= k8s.io/klog/v2 v2.100.1 h1:7WCHKK6K8fNhTqfBhISHQ97KrnJNFZMcQvKp7gP/tmg= k8s.io/klog/v2 v2.100.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= +k8s.io/klog/v2 v2.110.1 h1:U/Af64HJf7FcwMcXyKm2RPM22WZzyR7OSpYj5tg3cL0= +k8s.io/klog/v2 v2.110.1/go.mod h1:YGtd1984u+GgbuZ7e08/yBuAfKLSO0+uR1Fhi6ExXjo= k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9 h1:LyMgNKD2P8Wn1iAwQU5OhxCKlKJy0sHc+PcDwFB24dQ= k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9/go.mod h1:wZK2AVp1uHCp4VamDVgBP2COHZjqD1T68Rf0CM3YjSM= +k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 h1:aVUu9fTY98ivBPKR9Y5w/AuzbMm96cd3YHRTU83I780= +k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00/go.mod h1:AsvuZPBlUDVuCdzJ87iajxtXuR9oktsTctW/R9wwouA= k8s.io/kubectl v0.28.4 h1:gWpUXW/T7aFne+rchYeHkyB8eVDl5UZce8G4X//kjUQ= k8s.io/kubectl v0.28.4/go.mod h1:CKOccVx3l+3MmDbkXtIUtibq93nN2hkDR99XDCn7c/c= +k8s.io/kubectl v0.29.3 h1:RuwyyIU42MAISRIePaa8Q7A3U74Q9P4MoJbDFz9o3us= +k8s.io/kubectl v0.29.3/go.mod h1:yCxfY1dbwgVdEt2zkJ6d5NNLOhhWgTyrqACIoFhpdd4= k8s.io/utils v0.0.0-20240423183400-0849a56e8f22 h1:ao5hUqGhsqdm+bYbjH/pRkCs0unBGe9UyDahzs9zQzQ= k8s.io/utils v0.0.0-20240423183400-0849a56e8f22/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= moul.io/http2curl v1.0.0 h1:6XwpyZOYsgZJrU8exnG87ncVkU1FVCcTRpwzOkTDUi8= @@ -210,5 +255,9 @@ sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMm sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= sigs.k8s.io/structured-merge-diff/v4 v4.2.3 h1:PRbqxJClWWYMNV1dhaG4NsibJbArud9kFxnAMREiWFE= sigs.k8s.io/structured-merge-diff/v4 v4.2.3/go.mod h1:qjx8mGObPmV2aSZepjQjbmb2ihdVs8cGKBraizNC69E= +sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+sGiqlzvrtq4= +sigs.k8s.io/structured-merge-diff/v4 v4.4.1/go.mod h1:N8hJocpFajUSSeSJ9bOZ77VzejKZaXsTtZo4/u7Io08= sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8= +sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= +sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= From fb9748eae763630f9580c40680e6141bf95d6554 Mon Sep 17 00:00:00 2001 From: stakater-user Date: Wed, 19 Jun 2024 09:50:00 +0000 Subject: [PATCH 11/29] [skip-ci] Update artifacts --- deployments/kubernetes/chart/reloader/Chart.yaml | 4 ++-- .../kubernetes/chart/reloader/values.yaml | 4 ++-- deployments/kubernetes/manifests/deployment.yaml | 2 +- deployments/kubernetes/reloader.yaml | 16 ++++++++-------- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/deployments/kubernetes/chart/reloader/Chart.yaml b/deployments/kubernetes/chart/reloader/Chart.yaml index 53429f3f..92eeae0d 100644 --- a/deployments/kubernetes/chart/reloader/Chart.yaml +++ b/deployments/kubernetes/chart/reloader/Chart.yaml @@ -3,8 +3,8 @@ apiVersion: v1 name: reloader description: Reloader chart that runs on kubernetes -version: 1.0.107 -appVersion: v1.0.107 +version: 1.0.108 +appVersion: v1.0.108 keywords: - Reloader - kubernetes diff --git a/deployments/kubernetes/chart/reloader/values.yaml b/deployments/kubernetes/chart/reloader/values.yaml index eed307c4..757052ac 100644 --- a/deployments/kubernetes/chart/reloader/values.yaml +++ b/deployments/kubernetes/chart/reloader/values.yaml @@ -89,10 +89,10 @@ reloader: labels: provider: stakater group: com.stakater.platform - version: v1.0.107 + version: v1.0.108 image: name: ghcr.io/stakater/reloader - tag: v1.0.107 + tag: v1.0.108 pullPolicy: IfNotPresent # Support for extra environment variables. env: diff --git a/deployments/kubernetes/manifests/deployment.yaml b/deployments/kubernetes/manifests/deployment.yaml index 23751769..bf5e0871 100644 --- a/deployments/kubernetes/manifests/deployment.yaml +++ b/deployments/kubernetes/manifests/deployment.yaml @@ -17,7 +17,7 @@ spec: app: reloader-reloader spec: containers: - - image: "ghcr.io/stakater/reloader:v1.0.107" + - image: "ghcr.io/stakater/reloader:v1.0.108" imagePullPolicy: IfNotPresent name: reloader-reloader ports: diff --git a/deployments/kubernetes/reloader.yaml b/deployments/kubernetes/reloader.yaml index a687c566..81f8a62a 100644 --- a/deployments/kubernetes/reloader.yaml +++ b/deployments/kubernetes/reloader.yaml @@ -8,7 +8,7 @@ metadata: meta.helm.sh/release-name: "reloader" labels: app: reloader-reloader - chart: "reloader-1.0.107" + chart: "reloader-1.0.108" release: "reloader" heritage: "Helm" app.kubernetes.io/managed-by: "Helm" @@ -25,7 +25,7 @@ metadata: meta.helm.sh/release-name: "reloader" labels: app: reloader-reloader - chart: "reloader-1.0.107" + chart: "reloader-1.0.108" release: "reloader" heritage: "Helm" app.kubernetes.io/managed-by: "Helm" @@ -92,7 +92,7 @@ metadata: meta.helm.sh/release-name: "reloader" labels: app: reloader-reloader - chart: "reloader-1.0.107" + chart: "reloader-1.0.108" release: "reloader" heritage: "Helm" app.kubernetes.io/managed-by: "Helm" @@ -115,13 +115,13 @@ metadata: meta.helm.sh/release-name: "reloader" labels: app: reloader-reloader - chart: "reloader-1.0.107" + chart: "reloader-1.0.108" release: "reloader" heritage: "Helm" app.kubernetes.io/managed-by: "Helm" group: com.stakater.platform provider: stakater - version: v1.0.107 + version: v1.0.108 name: reloader-reloader namespace: default spec: @@ -135,16 +135,16 @@ spec: metadata: labels: app: reloader-reloader - chart: "reloader-1.0.107" + chart: "reloader-1.0.108" release: "reloader" heritage: "Helm" app.kubernetes.io/managed-by: "Helm" group: com.stakater.platform provider: stakater - version: v1.0.107 + version: v1.0.108 spec: containers: - - image: "ghcr.io/stakater/reloader:v1.0.107" + - image: "ghcr.io/stakater/reloader:v1.0.108" imagePullPolicy: IfNotPresent name: reloader-reloader From e718be07c24ef52bdc338091b96ab81ba6097377 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 19 Jun 2024 09:51:03 +0000 Subject: [PATCH 12/29] chore(deps): update dependency stakater/vale-package to v0.0.27 --- .vale.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.vale.ini b/.vale.ini index b0cc1073..d57ca4f3 100644 --- a/.vale.ini +++ b/.vale.ini @@ -1,7 +1,7 @@ StylesPath = styles MinAlertLevel = warning -Packages = https://github.com/stakater/vale-package/releases/download/v0.0.25/Stakater.zip +Packages = https://github.com/stakater/vale-package/releases/download/v0.0.27/Stakater.zip Vocab = Stakater # Only check MarkDown files From 2e68364298abc3f23dbd9bea47948ad7291fe001 Mon Sep 17 00:00:00 2001 From: Kunj Bosamia <135578521+kunj-bosamia@users.noreply.github.com> Date: Fri, 21 Jun 2024 19:15:24 +0530 Subject: [PATCH 13/29] [ENHANCE] #639 , Add resources to the Reloader deployment. (#692) * issue-639 , adding Resources to the values.yaml * revert old change * adding resources in helm template command * add resources to reloader.yaml file only * Update readme about the default resource limit and request values * fix lint error * fix lint error --- .github/workflows/push.yaml | 7 ++++++- README.md | 12 +++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/.github/workflows/push.yaml b/.github/workflows/push.yaml index 82f32f45..2873cf80 100644 --- a/.github/workflows/push.yaml +++ b/.github/workflows/push.yaml @@ -211,7 +211,12 @@ jobs: - name: Helm Template run: | - helm template reloader deployments/kubernetes/chart/reloader/ > deployments/kubernetes/reloader.yaml + helm template reloader deployments/kubernetes/chart/reloader/ \ + --set reloader.deployment.resources.limits.cpu=150m \ + --set reloader.deployment.resources.limits.memory=512Mi \ + --set reloader.deployment.resources.requests.cpu=10m \ + --set reloader.deployment.resources.requests.memory=128Mi > deployments/kubernetes/reloader.yaml + helm template reloader deployments/kubernetes/chart/reloader/ --output-dir deployments/kubernetes/manifests && mv deployments/kubernetes/manifests/reloader/templates/* deployments/kubernetes/manifests/ && rm -r deployments/kubernetes/manifests/reloader - name: Remove labels and annotations from manifests diff --git a/README.md b/README.md index 7c4a3edb..d325427f 100644 --- a/README.md +++ b/README.md @@ -190,7 +190,17 @@ You can apply vanilla manifests by changing `RELEASE-NAME` placeholder provided kubectl apply -f https://raw.githubusercontent.com/stakater/Reloader/master/deployments/kubernetes/reloader.yaml ``` -By default, Reloader gets deployed in `default` namespace and watches changes `secrets` and `configmaps` in all namespaces. +By default, Reloader gets deployed in `default` namespace and watches changes `secrets` and `configmaps` in all namespaces.Additionally, in the default Reloader deployment, the following resource limits and requests are set: + +```yaml +resources: + limits: + cpu: 150m + memory: 512Mi + requests: + cpu: 10m + memory: 128Mi +``` Reloader can be configured to ignore the resources `secrets` and `configmaps` by passing the following arguments (`spec.template.spec.containers.args`) to its container : From b73b04d9aeca86d7230e0f9ab146baeb576ed54f Mon Sep 17 00:00:00 2001 From: stakater-user Date: Fri, 21 Jun 2024 13:50:22 +0000 Subject: [PATCH 14/29] [skip-ci] Update artifacts --- .../kubernetes/chart/reloader/Chart.yaml | 4 ++-- .../kubernetes/chart/reloader/values.yaml | 4 ++-- .../kubernetes/manifests/deployment.yaml | 2 +- deployments/kubernetes/reloader.yaml | 23 ++++++++++++------- 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/deployments/kubernetes/chart/reloader/Chart.yaml b/deployments/kubernetes/chart/reloader/Chart.yaml index 92eeae0d..6f0cff6d 100644 --- a/deployments/kubernetes/chart/reloader/Chart.yaml +++ b/deployments/kubernetes/chart/reloader/Chart.yaml @@ -3,8 +3,8 @@ apiVersion: v1 name: reloader description: Reloader chart that runs on kubernetes -version: 1.0.108 -appVersion: v1.0.108 +version: v1.0.110 +appVersion: vv1.0.110 keywords: - Reloader - kubernetes diff --git a/deployments/kubernetes/chart/reloader/values.yaml b/deployments/kubernetes/chart/reloader/values.yaml index 757052ac..4b09926d 100644 --- a/deployments/kubernetes/chart/reloader/values.yaml +++ b/deployments/kubernetes/chart/reloader/values.yaml @@ -89,10 +89,10 @@ reloader: labels: provider: stakater group: com.stakater.platform - version: v1.0.108 + version: vv1.0.110 image: name: ghcr.io/stakater/reloader - tag: v1.0.108 + tag: vv1.0.110 pullPolicy: IfNotPresent # Support for extra environment variables. env: diff --git a/deployments/kubernetes/manifests/deployment.yaml b/deployments/kubernetes/manifests/deployment.yaml index bf5e0871..7e53420e 100644 --- a/deployments/kubernetes/manifests/deployment.yaml +++ b/deployments/kubernetes/manifests/deployment.yaml @@ -17,7 +17,7 @@ spec: app: reloader-reloader spec: containers: - - image: "ghcr.io/stakater/reloader:v1.0.108" + - image: "ghcr.io/stakater/reloader:vv1.0.110" imagePullPolicy: IfNotPresent name: reloader-reloader ports: diff --git a/deployments/kubernetes/reloader.yaml b/deployments/kubernetes/reloader.yaml index 81f8a62a..87ce330b 100644 --- a/deployments/kubernetes/reloader.yaml +++ b/deployments/kubernetes/reloader.yaml @@ -8,7 +8,7 @@ metadata: meta.helm.sh/release-name: "reloader" labels: app: reloader-reloader - chart: "reloader-1.0.108" + chart: "reloader-v1.0.110" release: "reloader" heritage: "Helm" app.kubernetes.io/managed-by: "Helm" @@ -25,7 +25,7 @@ metadata: meta.helm.sh/release-name: "reloader" labels: app: reloader-reloader - chart: "reloader-1.0.108" + chart: "reloader-v1.0.110" release: "reloader" heritage: "Helm" app.kubernetes.io/managed-by: "Helm" @@ -92,7 +92,7 @@ metadata: meta.helm.sh/release-name: "reloader" labels: app: reloader-reloader - chart: "reloader-1.0.108" + chart: "reloader-v1.0.110" release: "reloader" heritage: "Helm" app.kubernetes.io/managed-by: "Helm" @@ -115,13 +115,13 @@ metadata: meta.helm.sh/release-name: "reloader" labels: app: reloader-reloader - chart: "reloader-1.0.108" + chart: "reloader-v1.0.110" release: "reloader" heritage: "Helm" app.kubernetes.io/managed-by: "Helm" group: com.stakater.platform provider: stakater - version: v1.0.108 + version: vv1.0.110 name: reloader-reloader namespace: default spec: @@ -135,16 +135,16 @@ spec: metadata: labels: app: reloader-reloader - chart: "reloader-1.0.108" + chart: "reloader-v1.0.110" release: "reloader" heritage: "Helm" app.kubernetes.io/managed-by: "Helm" group: com.stakater.platform provider: stakater - version: v1.0.108 + version: vv1.0.110 spec: containers: - - image: "ghcr.io/stakater/reloader:v1.0.108" + - image: "ghcr.io/stakater/reloader:vv1.0.110" imagePullPolicy: IfNotPresent name: reloader-reloader @@ -172,6 +172,13 @@ spec: securityContext: {} + resources: + limits: + cpu: 150m + memory: 512Mi + requests: + cpu: 10m + memory: 128Mi securityContext: runAsNonRoot: true runAsUser: 65534 From ac7e9653266642ba5d976a70d913899c0847b7b9 Mon Sep 17 00:00:00 2001 From: stakater-user Date: Fri, 21 Jun 2024 15:12:42 +0000 Subject: [PATCH 15/29] [skip-ci] Update artifacts --- deployments/kubernetes/chart/reloader/Chart.yaml | 4 ++-- .../kubernetes/chart/reloader/values.yaml | 4 ++-- deployments/kubernetes/manifests/deployment.yaml | 2 +- deployments/kubernetes/reloader.yaml | 16 ++++++++-------- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/deployments/kubernetes/chart/reloader/Chart.yaml b/deployments/kubernetes/chart/reloader/Chart.yaml index 6f0cff6d..9b57de51 100644 --- a/deployments/kubernetes/chart/reloader/Chart.yaml +++ b/deployments/kubernetes/chart/reloader/Chart.yaml @@ -3,8 +3,8 @@ apiVersion: v1 name: reloader description: Reloader chart that runs on kubernetes -version: v1.0.110 -appVersion: vv1.0.110 +version: v1.0.112 +appVersion: vv1.0.112 keywords: - Reloader - kubernetes diff --git a/deployments/kubernetes/chart/reloader/values.yaml b/deployments/kubernetes/chart/reloader/values.yaml index 29198ce1..a9785637 100644 --- a/deployments/kubernetes/chart/reloader/values.yaml +++ b/deployments/kubernetes/chart/reloader/values.yaml @@ -91,10 +91,10 @@ reloader: labels: provider: stakater group: com.stakater.platform - version: vv1.0.110 + version: vv1.0.112 image: name: ghcr.io/stakater/reloader - tag: vv1.0.110 + tag: vv1.0.112 pullPolicy: IfNotPresent # Support for extra environment variables. env: diff --git a/deployments/kubernetes/manifests/deployment.yaml b/deployments/kubernetes/manifests/deployment.yaml index 7e53420e..479733db 100644 --- a/deployments/kubernetes/manifests/deployment.yaml +++ b/deployments/kubernetes/manifests/deployment.yaml @@ -17,7 +17,7 @@ spec: app: reloader-reloader spec: containers: - - image: "ghcr.io/stakater/reloader:vv1.0.110" + - image: "ghcr.io/stakater/reloader:vv1.0.112" imagePullPolicy: IfNotPresent name: reloader-reloader ports: diff --git a/deployments/kubernetes/reloader.yaml b/deployments/kubernetes/reloader.yaml index 87ce330b..ff93d895 100644 --- a/deployments/kubernetes/reloader.yaml +++ b/deployments/kubernetes/reloader.yaml @@ -8,7 +8,7 @@ metadata: meta.helm.sh/release-name: "reloader" labels: app: reloader-reloader - chart: "reloader-v1.0.110" + chart: "reloader-v1.0.112" release: "reloader" heritage: "Helm" app.kubernetes.io/managed-by: "Helm" @@ -25,7 +25,7 @@ metadata: meta.helm.sh/release-name: "reloader" labels: app: reloader-reloader - chart: "reloader-v1.0.110" + chart: "reloader-v1.0.112" release: "reloader" heritage: "Helm" app.kubernetes.io/managed-by: "Helm" @@ -92,7 +92,7 @@ metadata: meta.helm.sh/release-name: "reloader" labels: app: reloader-reloader - chart: "reloader-v1.0.110" + chart: "reloader-v1.0.112" release: "reloader" heritage: "Helm" app.kubernetes.io/managed-by: "Helm" @@ -115,13 +115,13 @@ metadata: meta.helm.sh/release-name: "reloader" labels: app: reloader-reloader - chart: "reloader-v1.0.110" + chart: "reloader-v1.0.112" release: "reloader" heritage: "Helm" app.kubernetes.io/managed-by: "Helm" group: com.stakater.platform provider: stakater - version: vv1.0.110 + version: vv1.0.112 name: reloader-reloader namespace: default spec: @@ -135,16 +135,16 @@ spec: metadata: labels: app: reloader-reloader - chart: "reloader-v1.0.110" + chart: "reloader-v1.0.112" release: "reloader" heritage: "Helm" app.kubernetes.io/managed-by: "Helm" group: com.stakater.platform provider: stakater - version: vv1.0.110 + version: vv1.0.112 spec: containers: - - image: "ghcr.io/stakater/reloader:vv1.0.110" + - image: "ghcr.io/stakater/reloader:vv1.0.112" imagePullPolicy: IfNotPresent name: reloader-reloader From fc955f72c8956e601752bfcfab1c72bca9120523 Mon Sep 17 00:00:00 2001 From: stakater-user Date: Fri, 21 Jun 2024 16:04:02 +0000 Subject: [PATCH 16/29] [skip-ci] Update artifacts --- deployments/kubernetes/chart/reloader/Chart.yaml | 4 ++-- .../kubernetes/chart/reloader/values.yaml | 4 ++-- deployments/kubernetes/manifests/deployment.yaml | 2 +- deployments/kubernetes/reloader.yaml | 16 ++++++++-------- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/deployments/kubernetes/chart/reloader/Chart.yaml b/deployments/kubernetes/chart/reloader/Chart.yaml index 9b57de51..8473c3af 100644 --- a/deployments/kubernetes/chart/reloader/Chart.yaml +++ b/deployments/kubernetes/chart/reloader/Chart.yaml @@ -3,8 +3,8 @@ apiVersion: v1 name: reloader description: Reloader chart that runs on kubernetes -version: v1.0.112 -appVersion: vv1.0.112 +version: 1.0.114 +appVersion: v1.0.114 keywords: - Reloader - kubernetes diff --git a/deployments/kubernetes/chart/reloader/values.yaml b/deployments/kubernetes/chart/reloader/values.yaml index a9785637..be585ddb 100644 --- a/deployments/kubernetes/chart/reloader/values.yaml +++ b/deployments/kubernetes/chart/reloader/values.yaml @@ -91,10 +91,10 @@ reloader: labels: provider: stakater group: com.stakater.platform - version: vv1.0.112 + version: v1.0.114 image: name: ghcr.io/stakater/reloader - tag: vv1.0.112 + tag: v1.0.114 pullPolicy: IfNotPresent # Support for extra environment variables. env: diff --git a/deployments/kubernetes/manifests/deployment.yaml b/deployments/kubernetes/manifests/deployment.yaml index 479733db..f19bf5a3 100644 --- a/deployments/kubernetes/manifests/deployment.yaml +++ b/deployments/kubernetes/manifests/deployment.yaml @@ -17,7 +17,7 @@ spec: app: reloader-reloader spec: containers: - - image: "ghcr.io/stakater/reloader:vv1.0.112" + - image: "ghcr.io/stakater/reloader:v1.0.114" imagePullPolicy: IfNotPresent name: reloader-reloader ports: diff --git a/deployments/kubernetes/reloader.yaml b/deployments/kubernetes/reloader.yaml index ff93d895..8f2aea06 100644 --- a/deployments/kubernetes/reloader.yaml +++ b/deployments/kubernetes/reloader.yaml @@ -8,7 +8,7 @@ metadata: meta.helm.sh/release-name: "reloader" labels: app: reloader-reloader - chart: "reloader-v1.0.112" + chart: "reloader-1.0.114" release: "reloader" heritage: "Helm" app.kubernetes.io/managed-by: "Helm" @@ -25,7 +25,7 @@ metadata: meta.helm.sh/release-name: "reloader" labels: app: reloader-reloader - chart: "reloader-v1.0.112" + chart: "reloader-1.0.114" release: "reloader" heritage: "Helm" app.kubernetes.io/managed-by: "Helm" @@ -92,7 +92,7 @@ metadata: meta.helm.sh/release-name: "reloader" labels: app: reloader-reloader - chart: "reloader-v1.0.112" + chart: "reloader-1.0.114" release: "reloader" heritage: "Helm" app.kubernetes.io/managed-by: "Helm" @@ -115,13 +115,13 @@ metadata: meta.helm.sh/release-name: "reloader" labels: app: reloader-reloader - chart: "reloader-v1.0.112" + chart: "reloader-1.0.114" release: "reloader" heritage: "Helm" app.kubernetes.io/managed-by: "Helm" group: com.stakater.platform provider: stakater - version: vv1.0.112 + version: v1.0.114 name: reloader-reloader namespace: default spec: @@ -135,16 +135,16 @@ spec: metadata: labels: app: reloader-reloader - chart: "reloader-v1.0.112" + chart: "reloader-1.0.114" release: "reloader" heritage: "Helm" app.kubernetes.io/managed-by: "Helm" group: com.stakater.platform provider: stakater - version: vv1.0.112 + version: v1.0.114 spec: containers: - - image: "ghcr.io/stakater/reloader:vv1.0.112" + - image: "ghcr.io/stakater/reloader:v1.0.114" imagePullPolicy: IfNotPresent name: reloader-reloader From ab7e4ddca73d432e9990963fe5354f6c42dfa4e4 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 26 Jun 2024 13:41:38 +0530 Subject: [PATCH 17/29] fix(deps): update module github.com/argoproj/argo-rollouts to v1.7.1 (#702) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 07c52040..8ed920f9 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/stakater/Reloader go 1.21 require ( - github.com/argoproj/argo-rollouts v1.7.0 + github.com/argoproj/argo-rollouts v1.7.1 github.com/openshift/api v3.9.0+incompatible github.com/openshift/client-go v0.0.0-20231110140829-a6ca51f6d5ba github.com/parnurzeal/gorequest v0.2.16 diff --git a/go.sum b/go.sum index c22ba691..3bfd932b 100644 --- a/go.sum +++ b/go.sum @@ -2,6 +2,8 @@ github.com/argoproj/argo-rollouts v1.6.6 h1:JCJ0cGAwWkh2xCAHZ1OQmrobysRjCatmG9IZ github.com/argoproj/argo-rollouts v1.6.6/go.mod h1:X2kTiBaYCSounmw1kmONdIZTwJNzNQYC0SrXUgSw9UI= github.com/argoproj/argo-rollouts v1.7.0 h1:3Hv8MUwGIWuZe50+yyS/4X21t4jT4shdGvgDe0lG6aw= github.com/argoproj/argo-rollouts v1.7.0/go.mod h1:Te4HrUELxKiBpK8lgk77o4gTa3mv8pXCd8xdPprKrbs= +github.com/argoproj/argo-rollouts v1.7.1 h1:KWStvHPRrNTbDTclogiYC/s4eKbdS45KkgXiorDzKG0= +github.com/argoproj/argo-rollouts v1.7.1/go.mod h1:Te4HrUELxKiBpK8lgk77o4gTa3mv8pXCd8xdPprKrbs= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= From 9f5211b7305e85cf49cca64b3952c47d335ad721 Mon Sep 17 00:00:00 2001 From: stakater-user Date: Wed, 26 Jun 2024 08:16:23 +0000 Subject: [PATCH 18/29] [skip-ci] Update artifacts --- deployments/kubernetes/chart/reloader/Chart.yaml | 4 ++-- .../kubernetes/chart/reloader/values.yaml | 4 ++-- deployments/kubernetes/manifests/deployment.yaml | 2 +- deployments/kubernetes/reloader.yaml | 16 ++++++++-------- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/deployments/kubernetes/chart/reloader/Chart.yaml b/deployments/kubernetes/chart/reloader/Chart.yaml index 8473c3af..ac6673da 100644 --- a/deployments/kubernetes/chart/reloader/Chart.yaml +++ b/deployments/kubernetes/chart/reloader/Chart.yaml @@ -3,8 +3,8 @@ apiVersion: v1 name: reloader description: Reloader chart that runs on kubernetes -version: 1.0.114 -appVersion: v1.0.114 +version: 1.0.115 +appVersion: v1.0.115 keywords: - Reloader - kubernetes diff --git a/deployments/kubernetes/chart/reloader/values.yaml b/deployments/kubernetes/chart/reloader/values.yaml index be585ddb..2644ec0d 100644 --- a/deployments/kubernetes/chart/reloader/values.yaml +++ b/deployments/kubernetes/chart/reloader/values.yaml @@ -91,10 +91,10 @@ reloader: labels: provider: stakater group: com.stakater.platform - version: v1.0.114 + version: v1.0.115 image: name: ghcr.io/stakater/reloader - tag: v1.0.114 + tag: v1.0.115 pullPolicy: IfNotPresent # Support for extra environment variables. env: diff --git a/deployments/kubernetes/manifests/deployment.yaml b/deployments/kubernetes/manifests/deployment.yaml index f19bf5a3..8106f129 100644 --- a/deployments/kubernetes/manifests/deployment.yaml +++ b/deployments/kubernetes/manifests/deployment.yaml @@ -17,7 +17,7 @@ spec: app: reloader-reloader spec: containers: - - image: "ghcr.io/stakater/reloader:v1.0.114" + - image: "ghcr.io/stakater/reloader:v1.0.115" imagePullPolicy: IfNotPresent name: reloader-reloader ports: diff --git a/deployments/kubernetes/reloader.yaml b/deployments/kubernetes/reloader.yaml index 8f2aea06..882cc890 100644 --- a/deployments/kubernetes/reloader.yaml +++ b/deployments/kubernetes/reloader.yaml @@ -8,7 +8,7 @@ metadata: meta.helm.sh/release-name: "reloader" labels: app: reloader-reloader - chart: "reloader-1.0.114" + chart: "reloader-1.0.115" release: "reloader" heritage: "Helm" app.kubernetes.io/managed-by: "Helm" @@ -25,7 +25,7 @@ metadata: meta.helm.sh/release-name: "reloader" labels: app: reloader-reloader - chart: "reloader-1.0.114" + chart: "reloader-1.0.115" release: "reloader" heritage: "Helm" app.kubernetes.io/managed-by: "Helm" @@ -92,7 +92,7 @@ metadata: meta.helm.sh/release-name: "reloader" labels: app: reloader-reloader - chart: "reloader-1.0.114" + chart: "reloader-1.0.115" release: "reloader" heritage: "Helm" app.kubernetes.io/managed-by: "Helm" @@ -115,13 +115,13 @@ metadata: meta.helm.sh/release-name: "reloader" labels: app: reloader-reloader - chart: "reloader-1.0.114" + chart: "reloader-1.0.115" release: "reloader" heritage: "Helm" app.kubernetes.io/managed-by: "Helm" group: com.stakater.platform provider: stakater - version: v1.0.114 + version: v1.0.115 name: reloader-reloader namespace: default spec: @@ -135,16 +135,16 @@ spec: metadata: labels: app: reloader-reloader - chart: "reloader-1.0.114" + chart: "reloader-1.0.115" release: "reloader" heritage: "Helm" app.kubernetes.io/managed-by: "Helm" group: com.stakater.platform provider: stakater - version: v1.0.114 + version: v1.0.115 spec: containers: - - image: "ghcr.io/stakater/reloader:v1.0.114" + - image: "ghcr.io/stakater/reloader:v1.0.115" imagePullPolicy: IfNotPresent name: reloader-reloader From 074a42d8ce814ba5e3f1e4d98c96888bb16cb564 Mon Sep 17 00:00:00 2001 From: DESCHMIH Date: Mon, 8 Jul 2024 08:28:38 +0200 Subject: [PATCH 19/29] feature reload-on-delete removed from doc --- README.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/README.md b/README.md index d059691a..7a5d7ad3 100644 --- a/README.md +++ b/README.md @@ -327,7 +327,6 @@ helm uninstall {{RELEASE_NAME}} -n {{NAMESPACE}} | `reloader.ignoreSecrets` | To ignore secrets. Valid value are either `true` or `false`. Either `ignoreSecrets` or `ignoreConfigMaps` can be ignored, not both at the same time | boolean | `false` | | `reloader.ignoreConfigMaps` | To ignore configMaps. Valid value are either `true` or `false` | boolean | `false` | | `reloader.reloadOnCreate` | Enable reload on create events. Valid value are either `true` or `false` | boolean | `false` | -| `reloader.reloadOnDelete` | Enable reload on delete events. Valid value are either `true` or `false` | boolean | `false` | | `reloader.syncAfterRestart` | Enable sync after Reloader restarts for **Add** events, works only when reloadOnCreate is `true`. Valid value are either `true` or `false` | boolean | `false` | | `reloader.reloadStrategy` | Strategy to trigger resource restart, set to either `default`, `env-vars` or `annotations` | enumeration | `default` | | `reloader.ignoreNamespaces` | List of comma separated namespaces to ignore, if multiple are provided, they are combined with the AND operator | string | `""` | @@ -389,14 +388,10 @@ helm uninstall {{RELEASE_NAME}} -n {{NAMESPACE}} 1. Configmaps/secrets being added to the cache will cause Reloader to perform a rolling update of the associated workload 1. When applications are deployed for the first time, Reloader will perform a rolling update of the associated workload 1. If you are running Reloader in HA mode all workloads will have a rolling update performed when a new leader is elected -- `reloadOnDelete` controls how Reloader handles secrets being deleted. If `reloadOnDelete` is set to true: - 1. Configmaps/secrets being deleted will cause Reloader to perform a rolling update of the associated workload - `serviceMonitor` will be removed in future releases of Reloader in favour of Pod monitor - If `reloadOnCreate` is set to false: 1. Updates to configmaps/secrets that occur while there is no leader will not be picked up by the new leader until a subsequent update of the configmap/secret occurs 1. In the worst case the window in which there can be no leader is 15s as this is the LeaseDuration -- If `reloadOnDelete` is set to false: - 1. Deleting of configmaps/secrets has no effect to pods that references these resources. - By default, `reloadOnCreate`, `reloadOnDelete` and `syncAfterRestart` are all set to false. All need to be enabled explicitly ## Help From cda9fa9bf03acff297a61da50026a5f8f9f84d79 Mon Sep 17 00:00:00 2001 From: DESCHMIH Date: Mon, 8 Jul 2024 08:28:38 +0200 Subject: [PATCH 20/29] feature reload-on-delete removed from doc --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7a5d7ad3..3f6f9d3f 100644 --- a/README.md +++ b/README.md @@ -392,7 +392,7 @@ helm uninstall {{RELEASE_NAME}} -n {{NAMESPACE}} - If `reloadOnCreate` is set to false: 1. Updates to configmaps/secrets that occur while there is no leader will not be picked up by the new leader until a subsequent update of the configmap/secret occurs 1. In the worst case the window in which there can be no leader is 15s as this is the LeaseDuration -- By default, `reloadOnCreate`, `reloadOnDelete` and `syncAfterRestart` are all set to false. All need to be enabled explicitly +- By default, `reloadOnCreate` and `syncAfterRestart` are both set to false. Both need to be enabled explicitly ## Help From 49997ac248ce4a3e0e32d1b8298fecd5dac3f1c3 Mon Sep 17 00:00:00 2001 From: stakater-user Date: Mon, 8 Jul 2024 07:06:27 +0000 Subject: [PATCH 21/29] [skip-ci] Update artifacts --- deployments/kubernetes/chart/reloader/Chart.yaml | 4 ++-- .../kubernetes/chart/reloader/values.yaml | 4 ++-- deployments/kubernetes/manifests/deployment.yaml | 2 +- deployments/kubernetes/reloader.yaml | 16 ++++++++-------- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/deployments/kubernetes/chart/reloader/Chart.yaml b/deployments/kubernetes/chart/reloader/Chart.yaml index ac6673da..6a40f4cf 100644 --- a/deployments/kubernetes/chart/reloader/Chart.yaml +++ b/deployments/kubernetes/chart/reloader/Chart.yaml @@ -3,8 +3,8 @@ apiVersion: v1 name: reloader description: Reloader chart that runs on kubernetes -version: 1.0.115 -appVersion: v1.0.115 +version: 1.0.116 +appVersion: v1.0.116 keywords: - Reloader - kubernetes diff --git a/deployments/kubernetes/chart/reloader/values.yaml b/deployments/kubernetes/chart/reloader/values.yaml index 292d9b23..20f9c668 100644 --- a/deployments/kubernetes/chart/reloader/values.yaml +++ b/deployments/kubernetes/chart/reloader/values.yaml @@ -92,10 +92,10 @@ reloader: labels: provider: stakater group: com.stakater.platform - version: v1.0.115 + version: v1.0.116 image: name: ghcr.io/stakater/reloader - tag: v1.0.115 + tag: v1.0.116 pullPolicy: IfNotPresent # Support for extra environment variables. env: diff --git a/deployments/kubernetes/manifests/deployment.yaml b/deployments/kubernetes/manifests/deployment.yaml index 8106f129..a02d3919 100644 --- a/deployments/kubernetes/manifests/deployment.yaml +++ b/deployments/kubernetes/manifests/deployment.yaml @@ -17,7 +17,7 @@ spec: app: reloader-reloader spec: containers: - - image: "ghcr.io/stakater/reloader:v1.0.115" + - image: "ghcr.io/stakater/reloader:v1.0.116" imagePullPolicy: IfNotPresent name: reloader-reloader ports: diff --git a/deployments/kubernetes/reloader.yaml b/deployments/kubernetes/reloader.yaml index 882cc890..8905f705 100644 --- a/deployments/kubernetes/reloader.yaml +++ b/deployments/kubernetes/reloader.yaml @@ -8,7 +8,7 @@ metadata: meta.helm.sh/release-name: "reloader" labels: app: reloader-reloader - chart: "reloader-1.0.115" + chart: "reloader-1.0.116" release: "reloader" heritage: "Helm" app.kubernetes.io/managed-by: "Helm" @@ -25,7 +25,7 @@ metadata: meta.helm.sh/release-name: "reloader" labels: app: reloader-reloader - chart: "reloader-1.0.115" + chart: "reloader-1.0.116" release: "reloader" heritage: "Helm" app.kubernetes.io/managed-by: "Helm" @@ -92,7 +92,7 @@ metadata: meta.helm.sh/release-name: "reloader" labels: app: reloader-reloader - chart: "reloader-1.0.115" + chart: "reloader-1.0.116" release: "reloader" heritage: "Helm" app.kubernetes.io/managed-by: "Helm" @@ -115,13 +115,13 @@ metadata: meta.helm.sh/release-name: "reloader" labels: app: reloader-reloader - chart: "reloader-1.0.115" + chart: "reloader-1.0.116" release: "reloader" heritage: "Helm" app.kubernetes.io/managed-by: "Helm" group: com.stakater.platform provider: stakater - version: v1.0.115 + version: v1.0.116 name: reloader-reloader namespace: default spec: @@ -135,16 +135,16 @@ spec: metadata: labels: app: reloader-reloader - chart: "reloader-1.0.115" + chart: "reloader-1.0.116" release: "reloader" heritage: "Helm" app.kubernetes.io/managed-by: "Helm" group: com.stakater.platform provider: stakater - version: v1.0.115 + version: v1.0.116 spec: containers: - - image: "ghcr.io/stakater/reloader:v1.0.115" + - image: "ghcr.io/stakater/reloader:v1.0.116" imagePullPolicy: IfNotPresent name: reloader-reloader From 070355e79dfaefe58e62826f3b86a9412e16b689 Mon Sep 17 00:00:00 2001 From: DESCHMIH Date: Mon, 8 Jul 2024 09:47:54 +0200 Subject: [PATCH 22/29] feature "reload-on-delete" documented in README.md --- README.md | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 3f6f9d3f..aa55a404 100644 --- a/README.md +++ b/README.md @@ -327,6 +327,7 @@ helm uninstall {{RELEASE_NAME}} -n {{NAMESPACE}} | `reloader.ignoreSecrets` | To ignore secrets. Valid value are either `true` or `false`. Either `ignoreSecrets` or `ignoreConfigMaps` can be ignored, not both at the same time | boolean | `false` | | `reloader.ignoreConfigMaps` | To ignore configMaps. Valid value are either `true` or `false` | boolean | `false` | | `reloader.reloadOnCreate` | Enable reload on create events. Valid value are either `true` or `false` | boolean | `false` | +| `reloader.reloadOnDelete` | Enable reload on delete events. Valid value are either `true` or `false` | boolean | `false` | | `reloader.syncAfterRestart` | Enable sync after Reloader restarts for **Add** events, works only when reloadOnCreate is `true`. Valid value are either `true` or `false` | boolean | `false` | | `reloader.reloadStrategy` | Strategy to trigger resource restart, set to either `default`, `env-vars` or `annotations` | enumeration | `default` | | `reloader.ignoreNamespaces` | List of comma separated namespaces to ignore, if multiple are provided, they are combined with the AND operator | string | `""` | @@ -385,14 +386,18 @@ helm uninstall {{RELEASE_NAME}} -n {{NAMESPACE}} - Reloading of OpenShift (DeploymentConfig) and/or Argo `Rollouts` has to be enabled explicitly because it might not be always possible to use it on a cluster with restricted permissions - `isOpenShift` Recent versions of OpenShift (tested on 4.13.3) require the specified user to be in an `uid` range which is dynamically assigned by the namespace. The solution is to unset the runAsUser variable via ``deployment.securityContext.runAsUser=null`` and let OpenShift assign it at install - `reloadOnCreate` controls how Reloader handles secrets being added to the cache for the first time. If `reloadOnCreate` is set to true: - 1. Configmaps/secrets being added to the cache will cause Reloader to perform a rolling update of the associated workload - 1. When applications are deployed for the first time, Reloader will perform a rolling update of the associated workload - 1. If you are running Reloader in HA mode all workloads will have a rolling update performed when a new leader is elected + 1. Configmaps/secrets being added to the cache will cause Reloader to perform a rolling update of the associated workload + 1. When applications are deployed for the first time, Reloader will perform a rolling update of the associated workload + 1. If you are running Reloader in HA mode all workloads will have a rolling update performed when a new leader is elected +- `reloadOnDelete` controls how Reloader handles secrets being deleted. If `reloadOnDelete` is set to true: + 1. Configmaps/secrets being deleted will cause Reloader to perform a rolling update of the associated workload- `serviceMonitor` will be removed in future releases of Reloader in favour of Pod monitor - `serviceMonitor` will be removed in future releases of Reloader in favour of Pod monitor - If `reloadOnCreate` is set to false: - 1. Updates to configmaps/secrets that occur while there is no leader will not be picked up by the new leader until a subsequent update of the configmap/secret occurs - 1. In the worst case the window in which there can be no leader is 15s as this is the LeaseDuration -- By default, `reloadOnCreate` and `syncAfterRestart` are both set to false. Both need to be enabled explicitly + 1. Updates to configmaps/secrets that occur while there is no leader will not be picked up by the new leader until a subsequent update of the configmap/secret occurs + 1. In the worst case the window in which there can be no leader is 15s as this is the LeaseDuration +- If `reloadOnDelete` is set to false: + 1. Deleting of configmaps/secrets has no effect to pods that references these resources. +- By default, `reloadOnCreate`, `reloadOnDelete` and `syncAfterRestart` are all set to false. All need to be enabled explicitly ## Help From 3f49abebb9ee63fb1bfd23d6f79f023218390bd4 Mon Sep 17 00:00:00 2001 From: DESCHMIH Date: Mon, 8 Jul 2024 09:47:54 +0200 Subject: [PATCH 23/29] feature "reload-on-delete" documented in README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index aa55a404..f9c5a948 100644 --- a/README.md +++ b/README.md @@ -390,7 +390,7 @@ helm uninstall {{RELEASE_NAME}} -n {{NAMESPACE}} 1. When applications are deployed for the first time, Reloader will perform a rolling update of the associated workload 1. If you are running Reloader in HA mode all workloads will have a rolling update performed when a new leader is elected - `reloadOnDelete` controls how Reloader handles secrets being deleted. If `reloadOnDelete` is set to true: - 1. Configmaps/secrets being deleted will cause Reloader to perform a rolling update of the associated workload- `serviceMonitor` will be removed in future releases of Reloader in favour of Pod monitor + 1. Configmaps/secrets being deleted will cause Reloader to perform a rolling update of the associated workload - `serviceMonitor` will be removed in future releases of Reloader in favour of Pod monitor - If `reloadOnCreate` is set to false: 1. Updates to configmaps/secrets that occur while there is no leader will not be picked up by the new leader until a subsequent update of the configmap/secret occurs From 55ad4f71613060ef301a4f638a9089661437d8f0 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 10 Jul 2024 13:50:19 +0530 Subject: [PATCH 24/29] chore(deps): update dependency stakater/vale-package to v0.0.29 (#706) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .vale.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.vale.ini b/.vale.ini index d57ca4f3..80cc564d 100644 --- a/.vale.ini +++ b/.vale.ini @@ -1,7 +1,7 @@ StylesPath = styles MinAlertLevel = warning -Packages = https://github.com/stakater/vale-package/releases/download/v0.0.27/Stakater.zip +Packages = https://github.com/stakater/vale-package/releases/download/v0.0.29/Stakater.zip Vocab = Stakater # Only check MarkDown files From ae67d2cd40a151ceee721704933261d25b861940 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 17 Jul 2024 13:47:17 +0530 Subject: [PATCH 25/29] chore(deps): update anothrnick/github-tag-action action to v1.70.0 (#705) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .github/workflows/push.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/push.yaml b/.github/workflows/push.yaml index 2873cf80..3e9524c3 100644 --- a/.github/workflows/push.yaml +++ b/.github/workflows/push.yaml @@ -83,7 +83,7 @@ jobs: - name: Generate Tag id: generate_tag - uses: anothrNick/github-tag-action@1.69.0 + uses: anothrNick/github-tag-action@1.70.0 env: GITHUB_TOKEN: ${{ secrets.STAKATER_GITHUB_TOKEN }} WITH_V: true @@ -196,7 +196,7 @@ jobs: # Generate tag for operator without "v" - name: Generate Operator Tag id: generate_operator_tag - uses: anothrNick/github-tag-action@1.69.0 + uses: anothrNick/github-tag-action@1.70.0 env: GITHUB_TOKEN: ${{ secrets.STAKATER_GITHUB_TOKEN }} WITH_V: false @@ -272,7 +272,7 @@ jobs: branch: ${{ github.ref }} - name: Push Latest Tag - uses: anothrNick/github-tag-action@1.69.0 + uses: anothrNick/github-tag-action@1.70.0 env: GITHUB_TOKEN: ${{ secrets.STAKATER_GITHUB_TOKEN }} WITH_V: true From b6b9bb97e733b2b14fabc6452045b9922a316f2a Mon Sep 17 00:00:00 2001 From: zoha-jamil <92304570+zoha-jamil@users.noreply.github.com> Date: Thu, 18 Jul 2024 17:05:05 +0400 Subject: [PATCH 26/29] added sonar props file (#712) --- sonar-project.properties | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 sonar-project.properties diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 00000000..079f8df6 --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,8 @@ +sonar.projectKey=Reloader +sonar.sources=. +sonar.exclusions=**/*_test.go +sonar.language=go + +sonar.tests=. +sonar.test.inclusions=**/*_test.go +sonar.analysisCache.enabled=false From 6b026468787be04ad3b29ae8b5e55a6c29082366 Mon Sep 17 00:00:00 2001 From: Tim Date: Mon, 29 Jul 2024 14:30:49 +0800 Subject: [PATCH 27/29] Update README.md (#715) A couple small whitespace fixups. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f9c5a948..7c7e6d1e 100644 --- a/README.md +++ b/README.md @@ -190,7 +190,7 @@ You can apply vanilla manifests by changing `RELEASE-NAME` placeholder provided kubectl apply -f https://raw.githubusercontent.com/stakater/Reloader/master/deployments/kubernetes/reloader.yaml ``` -By default, Reloader gets deployed in `default` namespace and watches changes `secrets` and `configmaps` in all namespaces.Additionally, in the default Reloader deployment, the following resource limits and requests are set: +By default, Reloader gets deployed in `default` namespace and watches changes `secrets` and `configmaps` in all namespaces. Additionally, in the default Reloader deployment, the following resource limits and requests are set: ```yaml resources: @@ -202,7 +202,7 @@ resources: memory: 128Mi ``` -Reloader can be configured to ignore the resources `secrets` and `configmaps` by passing the following arguments (`spec.template.spec.containers.args`) to its container : +Reloader can be configured to ignore the resources `secrets` and `configmaps` by passing the following arguments (`spec.template.spec.containers.args`) to its container: | Argument | Description | |----------------------------------|----------------------| From 038f9a8eb8c625cf3ef43af8931c91b8ec637d42 Mon Sep 17 00:00:00 2001 From: AsfaMumtaz Date: Mon, 29 Jul 2024 23:48:26 +0500 Subject: [PATCH 28/29] Reloader Enterprise (#707) * Reloader Enterprise * Update reloader-enterprise.yml --------- Co-authored-by: Karl Johan Grahn <6355577+karl-johan-grahn@users.noreply.github.com> --- .github/workflows/reloader-enterprise.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 .github/workflows/reloader-enterprise.yml diff --git a/.github/workflows/reloader-enterprise.yml b/.github/workflows/reloader-enterprise.yml new file mode 100644 index 00000000..e3ba7074 --- /dev/null +++ b/.github/workflows/reloader-enterprise.yml @@ -0,0 +1,18 @@ +name: Dispatch Event Reloader Enterprise + +on: + push: + branches: + - master + +jobs: + dispatch: + runs-on: ubuntu-latest + steps: + - name: Trigger target repository workflow + run: | + curl -X POST \ + -H "Accept: application/vnd.github.v3+json" \ + -H "Authorization: token ${{ secrets.STAKATER_AB_TOKEN_FOR_RLDR }}" \ + https://api.github.com/repos/stakater-ab/reloader-enterprise/dispatches \ + -d '{"event_type":"trigger-event"}' From 43ea11a73b1836c7a2004e440616e912657e0ce4 Mon Sep 17 00:00:00 2001 From: stakater-user Date: Mon, 29 Jul 2024 18:59:57 +0000 Subject: [PATCH 29/29] [skip-ci] Update artifacts --- deployments/kubernetes/chart/reloader/Chart.yaml | 4 ++-- .../kubernetes/chart/reloader/values.yaml | 4 ++-- deployments/kubernetes/manifests/deployment.yaml | 2 +- deployments/kubernetes/reloader.yaml | 16 ++++++++-------- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/deployments/kubernetes/chart/reloader/Chart.yaml b/deployments/kubernetes/chart/reloader/Chart.yaml index 6a40f4cf..6f411f2e 100644 --- a/deployments/kubernetes/chart/reloader/Chart.yaml +++ b/deployments/kubernetes/chart/reloader/Chart.yaml @@ -3,8 +3,8 @@ apiVersion: v1 name: reloader description: Reloader chart that runs on kubernetes -version: 1.0.116 -appVersion: v1.0.116 +version: 1.0.119 +appVersion: v1.0.119 keywords: - Reloader - kubernetes diff --git a/deployments/kubernetes/chart/reloader/values.yaml b/deployments/kubernetes/chart/reloader/values.yaml index 20f9c668..bb0f55e5 100644 --- a/deployments/kubernetes/chart/reloader/values.yaml +++ b/deployments/kubernetes/chart/reloader/values.yaml @@ -92,10 +92,10 @@ reloader: labels: provider: stakater group: com.stakater.platform - version: v1.0.116 + version: v1.0.119 image: name: ghcr.io/stakater/reloader - tag: v1.0.116 + tag: v1.0.119 pullPolicy: IfNotPresent # Support for extra environment variables. env: diff --git a/deployments/kubernetes/manifests/deployment.yaml b/deployments/kubernetes/manifests/deployment.yaml index a02d3919..422da504 100644 --- a/deployments/kubernetes/manifests/deployment.yaml +++ b/deployments/kubernetes/manifests/deployment.yaml @@ -17,7 +17,7 @@ spec: app: reloader-reloader spec: containers: - - image: "ghcr.io/stakater/reloader:v1.0.116" + - image: "ghcr.io/stakater/reloader:v1.0.119" imagePullPolicy: IfNotPresent name: reloader-reloader ports: diff --git a/deployments/kubernetes/reloader.yaml b/deployments/kubernetes/reloader.yaml index 8905f705..c2dc20a1 100644 --- a/deployments/kubernetes/reloader.yaml +++ b/deployments/kubernetes/reloader.yaml @@ -8,7 +8,7 @@ metadata: meta.helm.sh/release-name: "reloader" labels: app: reloader-reloader - chart: "reloader-1.0.116" + chart: "reloader-1.0.119" release: "reloader" heritage: "Helm" app.kubernetes.io/managed-by: "Helm" @@ -25,7 +25,7 @@ metadata: meta.helm.sh/release-name: "reloader" labels: app: reloader-reloader - chart: "reloader-1.0.116" + chart: "reloader-1.0.119" release: "reloader" heritage: "Helm" app.kubernetes.io/managed-by: "Helm" @@ -92,7 +92,7 @@ metadata: meta.helm.sh/release-name: "reloader" labels: app: reloader-reloader - chart: "reloader-1.0.116" + chart: "reloader-1.0.119" release: "reloader" heritage: "Helm" app.kubernetes.io/managed-by: "Helm" @@ -115,13 +115,13 @@ metadata: meta.helm.sh/release-name: "reloader" labels: app: reloader-reloader - chart: "reloader-1.0.116" + chart: "reloader-1.0.119" release: "reloader" heritage: "Helm" app.kubernetes.io/managed-by: "Helm" group: com.stakater.platform provider: stakater - version: v1.0.116 + version: v1.0.119 name: reloader-reloader namespace: default spec: @@ -135,16 +135,16 @@ spec: metadata: labels: app: reloader-reloader - chart: "reloader-1.0.116" + chart: "reloader-1.0.119" release: "reloader" heritage: "Helm" app.kubernetes.io/managed-by: "Helm" group: com.stakater.platform provider: stakater - version: v1.0.116 + version: v1.0.119 spec: containers: - - image: "ghcr.io/stakater/reloader:v1.0.116" + - image: "ghcr.io/stakater/reloader:v1.0.119" imagePullPolicy: IfNotPresent name: reloader-reloader