From 124d17c25b73ba564887a991d3443646660a0e0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCller?= Date: Thu, 13 Aug 2026 20:38:20 +0200 Subject: [PATCH] chore: reproduce unnecessary statefulset restarts --- .../00-patch-ns.yaml.j2 | 9 +++++ .../10-assert.yaml | 14 +++++++ .../10-statefulset.yaml | 38 +++++++++++++++++++ .../20-assert.yaml | 23 +++++++++++ .../20-content-identical-write.yaml | 19 ++++++++++ tests/test-definition.yaml | 3 ++ 6 files changed, 106 insertions(+) create mode 100644 tests/templates/kuttl/restarter-content-identical-write/00-patch-ns.yaml.j2 create mode 100644 tests/templates/kuttl/restarter-content-identical-write/10-assert.yaml create mode 100644 tests/templates/kuttl/restarter-content-identical-write/10-statefulset.yaml create mode 100644 tests/templates/kuttl/restarter-content-identical-write/20-assert.yaml create mode 100644 tests/templates/kuttl/restarter-content-identical-write/20-content-identical-write.yaml diff --git a/tests/templates/kuttl/restarter-content-identical-write/00-patch-ns.yaml.j2 b/tests/templates/kuttl/restarter-content-identical-write/00-patch-ns.yaml.j2 new file mode 100644 index 00000000..67185acf --- /dev/null +++ b/tests/templates/kuttl/restarter-content-identical-write/00-patch-ns.yaml.j2 @@ -0,0 +1,9 @@ +{% if test_scenario['values']['openshift'] == 'true' %} +# see https://github.com/stackabletech/issues/issues/566 +--- +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +commands: + - script: kubectl patch namespace $NAMESPACE -p '{"metadata":{"labels":{"pod-security.kubernetes.io/enforce":"privileged"}}}' + timeout: 120 +{% endif %} diff --git a/tests/templates/kuttl/restarter-content-identical-write/10-assert.yaml b/tests/templates/kuttl/restarter-content-identical-write/10-assert.yaml new file mode 100644 index 00000000..9941c1f5 --- /dev/null +++ b/tests/templates/kuttl/restarter-content-identical-write/10-assert.yaml @@ -0,0 +1,14 @@ +--- +apiVersion: kuttl.dev/v1beta1 +kind: TestAssert +timeout: 300 +--- +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: test + generation: 1 +status: + readyReplicas: 2 + replicas: 2 + observedGeneration: 1 diff --git a/tests/templates/kuttl/restarter-content-identical-write/10-statefulset.yaml b/tests/templates/kuttl/restarter-content-identical-write/10-statefulset.yaml new file mode 100644 index 00000000..453532be --- /dev/null +++ b/tests/templates/kuttl/restarter-content-identical-write/10-statefulset.yaml @@ -0,0 +1,38 @@ +--- +# A minimal StatefulSet opted in to the restarter, mounting a ConfigMap. + +apiVersion: v1 +kind: ConfigMap +metadata: + name: test-config +data: + foo: bar +--- +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: test + labels: + restarter.stackable.tech/enabled: "true" +spec: + selector: + matchLabels: + app: test + serviceName: test + replicas: 2 + template: + metadata: + labels: + app: test + spec: + terminationGracePeriodSeconds: 1 + containers: + - name: nginx + image: nginxinc/nginx-unprivileged:1.27 + volumeMounts: + - name: config + mountPath: /config + volumes: + - name: config + configMap: + name: test-config diff --git a/tests/templates/kuttl/restarter-content-identical-write/20-assert.yaml b/tests/templates/kuttl/restarter-content-identical-write/20-assert.yaml new file mode 100644 index 00000000..dbd23104 --- /dev/null +++ b/tests/templates/kuttl/restarter-content-identical-write/20-assert.yaml @@ -0,0 +1,23 @@ +--- +apiVersion: kuttl.dev/v1beta1 +kind: TestAssert +timeout: 30 +--- +# The ConfigMap content never changed. +apiVersion: v1 +kind: ConfigMap +metadata: + name: test-config +data: + foo: bar +--- +# This should stay on generation 1 +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: test + generation: 1 +status: + readyReplicas: 2 + replicas: 2 + observedGeneration: 1 diff --git a/tests/templates/kuttl/restarter-content-identical-write/20-content-identical-write.yaml b/tests/templates/kuttl/restarter-content-identical-write/20-content-identical-write.yaml new file mode 100644 index 00000000..be86506e --- /dev/null +++ b/tests/templates/kuttl/restarter-content-identical-write/20-content-identical-write.yaml @@ -0,0 +1,19 @@ +--- +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +timeout: 120 +commands: + # Do a change that should (tm) not have an impact on a pod mounting/needing this cm. + - script: | + kubectl apply --server-side --field-manager=third-party-controller --force-conflicts -f - <