1515
161641: Not able to bind PersitantVolume to PersitantVolumeClaim
171742: ReadWriteOnce is not a supported access mode
18+ 43: PVC not found
19+ 44: Pod not found
1820
1921All return codes between (and including) 1-19 as well as all return codes ending on 9
2022can be seen as failures.
@@ -89,7 +91,7 @@ def create_pvc_pod(
8991 """
9092 # 1. Create PersistantVolumeClaim
9193 logger .debug (f"create pvc: { pvc_name } " )
92-
94+ creationflag = 2
9395 pvc_meta = client .V1ObjectMeta (name = pvc_name )
9496 pvc_resources = client .V1ResourceRequirements (
9597 requests = {"storage" : "1Gi" },
@@ -106,8 +108,9 @@ def create_pvc_pod(
106108 api_response = k8s_api_instance .create_namespaced_persistent_volume_claim (
107109 namespace , body_pvc
108110 )
109- k8s_api_instance .read_namespaced_persistent_volume_claim (name = pvc_name , namespace = namespace )
110- logger .debug ("created pvc successfully" )
111+ if k8s_api_instance .read_namespaced_persistent_volume_claim (name = pvc_name , namespace = namespace ):
112+ creationflag -= 1
113+ logger .debug (f"created pvc successfully { creationflag } " )
111114
112115 # 2. Create a pod which makes use of the PersistantVolumeClaim
113116 logger .debug (f"create pod: { pod_name } " )
@@ -135,8 +138,9 @@ def create_pvc_pod(
135138 api_response = k8s_api_instance .create_namespaced_pod (
136139 namespace , pod_body , _preload_content = False ,
137140 )
138- k8s_api_instance .read_namespaced_pod (name = pod_name , namespace = namespace )
139- logger .debug ("created pod successfully" )
141+ if k8s_api_instance .read_namespaced_pod (name = pod_name , namespace = namespace ):
142+ creationflag -= 1
143+ logger .debug (f"created pod successfully { creationflag } " )
140144 pod_info = json .loads (api_response .read ().decode ("utf-8" ))
141145 pod_status = pod_info ["status" ]["phase" ]
142146
@@ -221,7 +225,6 @@ def __init__(self, kubeconfig):
221225 self .return_code = 0
222226 self .return_message = "return_message: FAILED"
223227 self .kubeconfig = kubeconfig
224- self .cleanup = False
225228
226229 def prepare (self ):
227230 """
@@ -353,11 +356,9 @@ def main(argv):
353356 env .return_code = 1
354357 logger .debug ("check_default_storageclass() failed" )
355358 return env .return_code
356- # logger.debug("check_default_storageclass() failed")
357- # return 1
358- env .cleanup = True
359359 try :
360360 env .return_code = create_pvc_pod (k8s_core_api , default_class_name )
361+ logger .debug (f"create: { env .return_code } " )
361362 except ApiException as api_exception :
362363 logger .info (f"code { api_exception .status } " )
363364 if api_exception .status == 404 :
0 commit comments