From 741a3686e0ad6ef3d318c9b0bec1faa0214490e8 Mon Sep 17 00:00:00 2001 From: Christian Schwede Date: Wed, 13 Mar 2024 16:32:55 +0100 Subject: [PATCH] Fix regression when scaling up The default PodManagementPolicy for StatefulSet is set to OrderedReadyPodManagement, which means it only creates new pods when the previous one is ready. However, to start the pods the Swift ring file ConfigMap is needed, and this in turn is only created once all requested pods are started and their PVCs are bound (because it needs information on the PVCs to be used). If the instance is scaled by more than 1 (which is the case also for starting with 3 replicas), it failed. This is a regression to previous behaviour, introduced by changes to the ring setup. Previously the ring rebalance did not wait until all PVCs where bound, but estimated their size and updated the rings afterwards with the correct size. This required ring rebalances and data movements even for new deployments. Therefore changing the policy to ParallelPodManagement, wich starts the number of requested pods immediately. This does only affect scaling, not updates. The kuttl tests has been updated to avoid regressions in the future. --- pkg/swiftstorage/statefulset.go | 3 ++- .../basic-deploy/02-assert-scaleup-swift.yaml | 21 +++++++++++++++++++ .../tests/basic-deploy/02-scaleup-swift.yaml | 5 +++++ .../{02-cleanup.yaml => 03-cleanup.yaml} | 2 ++ ...rs-cleanup.yaml => 03-errors-cleanup.yaml} | 0 5 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 tests/kuttl/tests/basic-deploy/02-assert-scaleup-swift.yaml create mode 100644 tests/kuttl/tests/basic-deploy/02-scaleup-swift.yaml rename tests/kuttl/tests/basic-deploy/{02-cleanup.yaml => 03-cleanup.yaml} (59%) rename tests/kuttl/tests/basic-deploy/{02-errors-cleanup.yaml => 03-errors-cleanup.yaml} (100%) diff --git a/pkg/swiftstorage/statefulset.go b/pkg/swiftstorage/statefulset.go index 13c5d2e8..5178d60a 100644 --- a/pkg/swiftstorage/statefulset.go +++ b/pkg/swiftstorage/statefulset.go @@ -205,7 +205,8 @@ func StatefulSet( Selector: &metav1.LabelSelector{ MatchLabels: labels, }, - Replicas: swiftstorage.Spec.Replicas, + Replicas: swiftstorage.Spec.Replicas, + PodManagementPolicy: appsv1.ParallelPodManagement, Template: corev1.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ Labels: labels, diff --git a/tests/kuttl/tests/basic-deploy/02-assert-scaleup-swift.yaml b/tests/kuttl/tests/basic-deploy/02-assert-scaleup-swift.yaml new file mode 100644 index 00000000..314bdcb0 --- /dev/null +++ b/tests/kuttl/tests/basic-deploy/02-assert-scaleup-swift.yaml @@ -0,0 +1,21 @@ +--- +apiVersion: v1 +kind: Pod +metadata: + name: swift-storage-0 +status: + phase: Running +--- +apiVersion: v1 +kind: Pod +metadata: + name: swift-storage-1 +status: + phase: Running +--- +apiVersion: v1 +kind: Pod +metadata: + name: swift-storage-2 +status: + phase: Running diff --git a/tests/kuttl/tests/basic-deploy/02-scaleup-swift.yaml b/tests/kuttl/tests/basic-deploy/02-scaleup-swift.yaml new file mode 100644 index 00000000..b8476fda --- /dev/null +++ b/tests/kuttl/tests/basic-deploy/02-scaleup-swift.yaml @@ -0,0 +1,5 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +commands: + - script: | + oc patch -n swift-kuttl-tests swift/swift --type='json' -p='[{"op": "replace", "path": "/spec/swiftStorage/replicas", "value":3}]' diff --git a/tests/kuttl/tests/basic-deploy/02-cleanup.yaml b/tests/kuttl/tests/basic-deploy/03-cleanup.yaml similarity index 59% rename from tests/kuttl/tests/basic-deploy/02-cleanup.yaml rename to tests/kuttl/tests/basic-deploy/03-cleanup.yaml index 67ffe930..eb0b694c 100644 --- a/tests/kuttl/tests/basic-deploy/02-cleanup.yaml +++ b/tests/kuttl/tests/basic-deploy/03-cleanup.yaml @@ -7,3 +7,5 @@ delete: commands: - script: | oc delete --ignore-not-found=true -n $NAMESPACE pvc srv-swift-storage-0 + oc delete --ignore-not-found=true -n $NAMESPACE pvc srv-swift-storage-1 + oc delete --ignore-not-found=true -n $NAMESPACE pvc srv-swift-storage-2 diff --git a/tests/kuttl/tests/basic-deploy/02-errors-cleanup.yaml b/tests/kuttl/tests/basic-deploy/03-errors-cleanup.yaml similarity index 100% rename from tests/kuttl/tests/basic-deploy/02-errors-cleanup.yaml rename to tests/kuttl/tests/basic-deploy/03-errors-cleanup.yaml