From 4f4bcd327d5255c2359e9187d16bfb594129126d Mon Sep 17 00:00:00 2001 From: parth-gr Date: Thu, 5 Oct 2023 15:55:11 +0530 Subject: [PATCH 1/2] external: fix client healhchecker user keyring return if the client.health checker already exited it was returning extra information, It was making the structure and return JSON non idempotent output, So fixed that problem by returning a single value Signed-off-by: parth-gr (cherry picked from commit bf5252e13994e270a02fa0ab314cbed1f78fbc0b) --- deploy/examples/create-external-cluster-resources.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy/examples/create-external-cluster-resources.py b/deploy/examples/create-external-cluster-resources.py index fbc5b2c28..148f7d68b 100644 --- a/deploy/examples/create-external-cluster-resources.py +++ b/deploy/examples/create-external-cluster-resources.py @@ -1162,7 +1162,7 @@ class RadosJSON: # check if user already exist user_key = self.check_user_exist(entity) if user_key != "": - return user_key, f"{entity.split('.', 1)[1]}" + return user_key ret_val, json_out, err_msg = self._common_cmd_json_gen(cmd_json) # if there is an unsuccessful attempt, From f3e2548a0e41fc12eaf73b4a6153a3bea49c1c80 Mon Sep 17 00:00:00 2001 From: parth-gr Date: Thu, 5 Oct 2023 17:00:43 +0530 Subject: [PATCH 2/2] ci: add a test to check the script result in idempotent output Signed-off-by: parth-gr (cherry picked from commit 98125c78b953704439ca72f29880c3bb1a51fd9e) --- .github/workflows/canary-integration-test.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.github/workflows/canary-integration-test.yml b/.github/workflows/canary-integration-test.yml index 01a6be33f..0433214d2 100644 --- a/.github/workflows/canary-integration-test.yml +++ b/.github/workflows/canary-integration-test.yml @@ -79,6 +79,22 @@ jobs: # print existing client auth kubectl -n rook-ceph exec $toolbox -- ceph auth ls + - name: test re-running of external script should result in same output + run: | + toolbox=$(kubectl get pod -l app=rook-ceph-tools -n rook-ceph -o jsonpath='{.items[*].metadata.name}') + kubectl -n rook-ceph exec $toolbox -- python3 /etc/ceph/create-external-cluster-resources.py --rbd-data-pool-name=replicapool | tee output1.txt + kubectl -n rook-ceph exec $toolbox -- python3 /etc/ceph/create-external-cluster-resources.py --rbd-data-pool-name=replicapool | tee output2.txt + if cmp output1.txt output2.txt; then + echo "files have same output" + rm output1.txt + rm output2.txt + else + echo "re-run with same flags changed the output, result in failure" + rm output1.txt + rm output2.txt + exit 1 + fi + - name: dry run external script create-external-cluster-resources.py run: | toolbox=$(kubectl get pod -l app=rook-ceph-tools -n rook-ceph -o jsonpath='{.items[*].metadata.name}')