|
15 | 15 |
|
16 | 16 | 41: Not able to bind PersitantVolume to PersitantVolumeClaim |
17 | 17 | 42: ReadWriteOnce is not a supported access mode |
18 | | -43: PVC not found |
19 | | -44: Pod not found |
| 18 | +43: Resource not found PVC not found |
| 19 | +44: Resource not found Pod not found |
20 | 20 |
|
21 | 21 | All return codes between (and including) 1-19 as well as all return codes ending on 9 |
22 | 22 | can be seen as failures. |
@@ -92,22 +92,22 @@ def create_pvc_pod( |
92 | 92 | # 1. Create PersistantVolumeClaim |
93 | 93 | logger.debug(f"create pvc: {pvc_name}") |
94 | 94 |
|
95 | | - # pvc_meta = client.V1ObjectMeta(name=pvc_name) |
96 | | - # pvc_resources = client.V1ResourceRequirements( |
97 | | - # requests={"storage": "1Gi"}, |
98 | | - # ) |
99 | | - # pvc_spec = client.V1PersistentVolumeClaimSpec( |
100 | | - # access_modes=["ReadWriteOnce"], |
101 | | - # storage_class_name=storage_class, |
102 | | - # resources=pvc_resources, |
103 | | - # ) |
104 | | - # body_pvc = client.V1PersistentVolumeClaim( |
105 | | - # api_version="v1", kind="PersistentVolumeClaim", metadata=pvc_meta, spec=pvc_spec |
106 | | - # ) |
107 | | - |
108 | | - # api_response = k8s_api_instance.create_namespaced_persistent_volume_claim( |
109 | | - # namespace, body_pvc |
110 | | - # ) |
| 95 | + pvc_meta = client.V1ObjectMeta(name=pvc_name) |
| 96 | + pvc_resources = client.V1ResourceRequirements( |
| 97 | + requests={"storage": "1Gi"}, |
| 98 | + ) |
| 99 | + pvc_spec = client.V1PersistentVolumeClaimSpec( |
| 100 | + access_modes=["ReadWriteOnce"], |
| 101 | + storage_class_name=storage_class, |
| 102 | + resources=pvc_resources, |
| 103 | + ) |
| 104 | + body_pvc = client.V1PersistentVolumeClaim( |
| 105 | + api_version="v1", kind="PersistentVolumeClaim", metadata=pvc_meta, spec=pvc_spec |
| 106 | + ) |
| 107 | + |
| 108 | + api_response = k8s_api_instance.create_namespaced_persistent_volume_claim( |
| 109 | + namespace, body_pvc |
| 110 | + ) |
111 | 111 | try: |
112 | 112 | k8s_api_instance.read_namespaced_persistent_volume_claim(name=pvc_name, namespace=namespace) |
113 | 113 | logger.debug("created pvc successfully") |
@@ -314,7 +314,17 @@ def __enter__(self): |
314 | 314 |
|
315 | 315 | def __exit__(self, exc_type, exc_value, traceback): |
316 | 316 | if self.return_code != 43: |
317 | | - self.clean() |
| 317 | + try: |
| 318 | + self.clean() |
| 319 | + except ApiException as api_exception: |
| 320 | + logger.info(f"code {api_exception.status}") |
| 321 | + if api_exception.status == 404: # might be obsolete |
| 322 | + logger.info( |
| 323 | + "resource not found, " |
| 324 | + "failed to build resources correctly" |
| 325 | + ) |
| 326 | + self.return_code = 4 |
| 327 | + self.return_message = "(404) resource not found" |
318 | 328 | if self.return_code == 0: |
319 | 329 | self.return_message = "all tests passed" |
320 | 330 | if isinstance(exc_value, SCSTestException): |
@@ -379,24 +389,24 @@ def main(argv): |
379 | 389 | env.return_message = "(404) resource not found" |
380 | 390 | return |
381 | 391 | except ApiException as api_exception: |
382 | | - logger.info(f"code {api_exception.status}") |
383 | | - if api_exception.status == 404: # might be obsolete |
384 | | - logger.info( |
385 | | - "resource not found, " |
386 | | - "failed to build resources correctly" |
387 | | - ) |
388 | | - env.return_code = 4 |
389 | | - env.return_message = "(404) resource not found" |
390 | | - return |
391 | | - elif api_exception.status == 409:# might be obsolete |
392 | | - logger.info( |
393 | | - "conflicting resources, " |
394 | | - "try to clean up left overs, then start again" |
395 | | - ) |
396 | | - env.return_code = 3 |
397 | | - env.return_message = "(409) conflicting resources" |
398 | | - return |
399 | | - else: |
| 392 | + # logger.info(f"code {api_exception.status}") |
| 393 | + # if api_exception.status == 404: # might be obsolete |
| 394 | + # logger.info( |
| 395 | + # "resource not found, " |
| 396 | + # "failed to build resources correctly" |
| 397 | + # ) |
| 398 | + # env.return_code = 4 |
| 399 | + # env.return_message = "(404) resource not found" |
| 400 | + # return |
| 401 | + # elif api_exception.status == 409:# might be obsolete |
| 402 | + # logger.info( |
| 403 | + # "conflicting resources, " |
| 404 | + # "try to clean up left overs, then start again" |
| 405 | + # ) |
| 406 | + # env.return_code = 3 |
| 407 | + # env.return_message = "(409) conflicting resources" |
| 408 | + # return |
| 409 | + # else: |
400 | 410 | logger.info(f"An API error occurred: {api_exception}") |
401 | 411 | env.return_code = api_exception.status |
402 | 412 | return |
|
0 commit comments