From 206a9c6c08a25807c4a2f2a555d854682260ca3e Mon Sep 17 00:00:00 2001 From: Travis Nielsen Date: Fri, 5 Apr 2024 12:46:30 -0600 Subject: [PATCH] clean: ensure cephcluster cleanup job runs The cleanup policy was not allowed to take effect during the cluster cleanup. The finalizer was immediately be removed instead of remaining until the operator has a chance to handle the cleanup policy and internally remove the finalizer. Now the cleanup policy is allowed to be applied and the cleanup job(s) will be started to cleanup the host path and disks from OSDs. Signed-off-by: Travis Nielsen --- .github/workflows/go-test.yaml | 7 +++++-- pkg/crds/crds.go | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/go-test.yaml b/.github/workflows/go-test.yaml index 9a2ffb19..ff9c077e 100644 --- a/.github/workflows/go-test.yaml +++ b/.github/workflows/go-test.yaml @@ -160,7 +160,7 @@ jobs: set -ex kubectl rook-ceph destroy-cluster sleep 1 - kubectl get deployments -n rook-ceph --no-headers| wc -l | (read n && [ $n -le 1 ] || { echo "the crs could not be deleted"; kubectl get all -n rook-ceph; exit 1;}) + kubectl get deployments -n rook-ceph --no-headers| wc -l | (read n && [ $n -le 3 ] || { echo "the crs could not be deleted"; kubectl get all -n rook-ceph; exit 1;}) - name: collect common logs if: always() @@ -323,7 +323,10 @@ jobs: set -ex kubectl rook-ceph --operator-namespace test-operator -n test-cluster destroy-cluster sleep 1 - kubectl get deployments -n test-cluster --no-headers| wc -l | (read n && [ $n -le 1 ] || { echo "the crs could not be deleted"; kubectl get all -n test-cluster; exit 1;}) + kubectl -n test-cluster get deployments --no-headers| wc -l | (read n && [ $n -le 1 ] || { echo "the crs could not be deleted"; kubectl get all -n test-cluster; exit 1;}) + sleep 15 + node_name=$(kubectl get node --no-headers | awk '{print $1}') + kubectl -n test-cluster get pod -l job-name=cluster-cleanup-job-${node_name} --no-headers | grep Completed || { echo "cluster cleanup job not found or failed"; kubectl get all -n test-cluster; exit 1;} - name: collect common logs if: always() diff --git a/pkg/crds/crds.go b/pkg/crds/crds.go index 9eda8402..cdf0aff3 100644 --- a/pkg/crds/crds.go +++ b/pkg/crds/crds.go @@ -167,6 +167,8 @@ func updatingFinalizers(ctx context.Context, clientsets k8sutil.ClientsetsInterf if err != nil { return err } + logging.Info("Added cleanup policy to the cephcluster CR %q", resource) + return nil } jsonPatchData, _ := json.Marshal(DefaultResourceRemoveFinalizers)