From ddbe20a30b465314046f36bb05c67768e208b7c9 Mon Sep 17 00:00:00 2001 From: Chinasubbareddy Mallavarapu Date: Mon, 24 Jun 2019 15:47:31 -0500 Subject: [PATCH] Ceph-Provisioner: wait for helm tests related pods This is to update logic to wait for pods created by helm tests. Change-Id: Ic1ee293613a0b050be9fa01a29642bfc9e8de2d7 --- .../templates/bin/_helm-tests.sh.tpl | 23 +++++++++++-------- .../templates/pod-helm-tests.yaml | 2 ++ ceph-provisioners/values.yaml | 1 + 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/ceph-provisioners/templates/bin/_helm-tests.sh.tpl b/ceph-provisioners/templates/bin/_helm-tests.sh.tpl index f3d296148..e98b0210d 100644 --- a/ceph-provisioners/templates/bin/_helm-tests.sh.tpl +++ b/ceph-provisioners/templates/bin/_helm-tests.sh.tpl @@ -40,6 +40,7 @@ function storageclass_validation() pod_name=$2 pvc_name=$3 storageclass=$4 + echo "--> Starting validation" # storageclass check @@ -64,9 +65,9 @@ spec: EOF # waiting for pvc to get create - end=$(($(date +%s) + 120)) - while ! kubectl get pvc -n $pvc_namespace $pvc_name|grep Bound; do - if [ "$(date +%s)" -gt $end ]; then + end=$(($(date +%s) + TEST_POD_WAIT_TIMEOUT)) + while ! kubectl get pvc -n $pvc_namespace $pvc_name | grep Bound; do + if [ "$(date +%s)" -gt "${end}" ]; then kubectl get pvc -n $pvc_namespace $pvc_name kubectl get pv echo "Storageclass is available but can't create PersistentVolumeClaim." @@ -101,12 +102,16 @@ spec: claimName: $pvc_name EOF - # waiting for pod to get create - sleep 60 - if ! kubectl get pods -n $pvc_namespace $pod_name; then - echo "Can not create POD with rbd storage class $storageclass based PersistentVolumeClaim." - echo 1 - fi + # waiting for pod to get completed + end=$(($(date +%s) + TEST_POD_WAIT_TIMEOUT)) + while ! kubectl get pods -n $pvc_namespace $pod_name | grep -i Completed; do + if [ "$(date +%s)" -gt "${end}" ]; then + kubectl get pods -n $pvc_namespace $pod_name + echo "Cannot create POD with rbd storage class $storageclass based PersistentVolumeClaim." + exit 1 + fi + sleep 10 + done } diff --git a/ceph-provisioners/templates/pod-helm-tests.yaml b/ceph-provisioners/templates/pod-helm-tests.yaml index bd428f8cd..d9781f95a 100644 --- a/ceph-provisioners/templates/pod-helm-tests.yaml +++ b/ceph-provisioners/templates/pod-helm-tests.yaml @@ -91,6 +91,8 @@ spec: value: {{ .Values.pod.test_pod.cephfs.name }} - name: CEPHFS_TEST_PVC_NAME value: {{ .Values.pod.test_pod.cephfs.pvc_name }} + - name: TEST_POD_WAIT_TIMEOUT + value: {{ .Values.pod.test_pod.wait_timeout | quote }} command: - /tmp/helm-tests.sh volumeMounts: diff --git a/ceph-provisioners/values.yaml b/ceph-provisioners/values.yaml index c401d2c0c..0f8038918 100644 --- a/ceph-provisioners/values.yaml +++ b/ceph-provisioners/values.yaml @@ -53,6 +53,7 @@ labels: pod: test_pod: + wait_timeout: 120 rbd: name: rbd-prov-test-pod pvc_name: rbd-prov-test-pvc