def _ensure_crds() -> None: """ ensure_crds makes sure that all the required CRDs have been created """ crdv1 = client.ApiextensionsV1beta1Api() crd = _load_mongodb_crd() k8s_conditions.ignore_if_doesnt_exist( lambda: crdv1.delete_custom_resource_definition("mongodb.mongodb.com")) # Make sure that the CRD has being deleted before trying to create it again if not k8s_conditions.wait( lambda: crdv1.list_custom_resource_definition( field_selector="metadata.name==mongodb.mongodb.com"), lambda crd_list: len(crd_list.items) == 0, timeout=5, sleep_time=0.5, ): raise Exception( "Execution timed out while waiting for the CRD to be deleted") # TODO: fix this, when calling create_custom_resource_definition, we get the error # ValueError("Invalid value for `conditions`, must not be `None`") # but the crd is still successfully created try: crdv1.create_custom_resource_definition(body=crd) except ValueError as e: pass print("Ensured CRDs")
def _delete_test_pod(config_file: str) -> None: """ _delete_testrunner_pod deletes the test runner pod if it already exists. """ dev_config = load_config(config_file) corev1 = client.CoreV1Api() k8s_conditions.ignore_if_doesnt_exist(lambda: corev1.delete_namespaced_pod( TEST_POD_NAME, dev_config.namespace))