Honor the --delete-volumes flag.
Some checks failed
Lint Checks / Run linter (pull_request) Failing after 43s
Webapp Test / Run webapp test suite (pull_request) Successful in 4m38s
Deploy Test / Run deploy test suite (pull_request) Successful in 5m29s
Smoke Test / Run basic test suite (pull_request) Successful in 5m18s
Some checks failed
Lint Checks / Run linter (pull_request) Failing after 43s
Webapp Test / Run webapp test suite (pull_request) Successful in 4m38s
Deploy Test / Run deploy test suite (pull_request) Successful in 5m29s
Smoke Test / Run basic test suite (pull_request) Successful in 5m18s
This commit is contained in:
parent
6411f12770
commit
88d8bab8b2
@ -88,6 +88,16 @@ class K8sDeployer(Deployer):
|
|||||||
if opts.o.debug:
|
if opts.o.debug:
|
||||||
print(f"Sending this pv: {pv}")
|
print(f"Sending this pv: {pv}")
|
||||||
if not opts.o.dry_run:
|
if not opts.o.dry_run:
|
||||||
|
try:
|
||||||
|
pv_resp = self.core_api.read_persistent_volume(name=pv.metadata.name)
|
||||||
|
if pv_resp:
|
||||||
|
if opts.o.debug:
|
||||||
|
print("PVs already present:")
|
||||||
|
print(f"{pv_resp}")
|
||||||
|
continue
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
pv_resp = self.core_api.create_persistent_volume(body=pv)
|
pv_resp = self.core_api.create_persistent_volume(body=pv)
|
||||||
if opts.o.debug:
|
if opts.o.debug:
|
||||||
print("PVs created:")
|
print("PVs created:")
|
||||||
@ -100,6 +110,17 @@ class K8sDeployer(Deployer):
|
|||||||
print(f"Sending this pvc: {pvc}")
|
print(f"Sending this pvc: {pvc}")
|
||||||
|
|
||||||
if not opts.o.dry_run:
|
if not opts.o.dry_run:
|
||||||
|
try:
|
||||||
|
pvc_resp = self.core_api.read_namespaced_persistent_volume_claim(
|
||||||
|
name=pvc.metadata.name, namespace=self.k8s_namespace)
|
||||||
|
if pvc_resp:
|
||||||
|
if opts.o.debug:
|
||||||
|
print("PVCs already present:")
|
||||||
|
print(f"{pvc_resp}")
|
||||||
|
continue
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
pvc_resp = self.core_api.create_namespaced_persistent_volume_claim(body=pvc, namespace=self.k8s_namespace)
|
pvc_resp = self.core_api.create_namespaced_persistent_volume_claim(body=pvc, namespace=self.k8s_namespace)
|
||||||
if opts.o.debug:
|
if opts.o.debug:
|
||||||
print("PVCs created:")
|
print("PVCs created:")
|
||||||
@ -181,33 +202,35 @@ class K8sDeployer(Deployer):
|
|||||||
def down(self, timeout, volumes): # noqa: C901
|
def down(self, timeout, volumes): # noqa: C901
|
||||||
self.connect_api()
|
self.connect_api()
|
||||||
# Delete the k8s objects
|
# Delete the k8s objects
|
||||||
# Create the host-path-mounted PVs for this deployment
|
|
||||||
pvs = self.cluster_info.get_pvs()
|
|
||||||
for pv in pvs:
|
|
||||||
if opts.o.debug:
|
|
||||||
print(f"Deleting this pv: {pv}")
|
|
||||||
try:
|
|
||||||
pv_resp = self.core_api.delete_persistent_volume(name=pv.metadata.name)
|
|
||||||
if opts.o.debug:
|
|
||||||
print("PV deleted:")
|
|
||||||
print(f"{pv_resp}")
|
|
||||||
except client.exceptions.ApiException as e:
|
|
||||||
_check_delete_exception(e)
|
|
||||||
|
|
||||||
# Figure out the PVCs for this deployment
|
if volumes:
|
||||||
pvcs = self.cluster_info.get_pvcs()
|
# Create the host-path-mounted PVs for this deployment
|
||||||
for pvc in pvcs:
|
pvs = self.cluster_info.get_pvs()
|
||||||
if opts.o.debug:
|
for pv in pvs:
|
||||||
print(f"Deleting this pvc: {pvc}")
|
|
||||||
try:
|
|
||||||
pvc_resp = self.core_api.delete_namespaced_persistent_volume_claim(
|
|
||||||
name=pvc.metadata.name, namespace=self.k8s_namespace
|
|
||||||
)
|
|
||||||
if opts.o.debug:
|
if opts.o.debug:
|
||||||
print("PVCs deleted:")
|
print(f"Deleting this pv: {pv}")
|
||||||
print(f"{pvc_resp}")
|
try:
|
||||||
except client.exceptions.ApiException as e:
|
pv_resp = self.core_api.delete_persistent_volume(name=pv.metadata.name)
|
||||||
_check_delete_exception(e)
|
if opts.o.debug:
|
||||||
|
print("PV deleted:")
|
||||||
|
print(f"{pv_resp}")
|
||||||
|
except client.exceptions.ApiException as e:
|
||||||
|
_check_delete_exception(e)
|
||||||
|
|
||||||
|
# Figure out the PVCs for this deployment
|
||||||
|
pvcs = self.cluster_info.get_pvcs()
|
||||||
|
for pvc in pvcs:
|
||||||
|
if opts.o.debug:
|
||||||
|
print(f"Deleting this pvc: {pvc}")
|
||||||
|
try:
|
||||||
|
pvc_resp = self.core_api.delete_namespaced_persistent_volume_claim(
|
||||||
|
name=pvc.metadata.name, namespace=self.k8s_namespace
|
||||||
|
)
|
||||||
|
if opts.o.debug:
|
||||||
|
print("PVCs deleted:")
|
||||||
|
print(f"{pvc_resp}")
|
||||||
|
except client.exceptions.ApiException as e:
|
||||||
|
_check_delete_exception(e)
|
||||||
|
|
||||||
# Figure out the ConfigMaps for this deployment
|
# Figure out the ConfigMaps for this deployment
|
||||||
cfg_maps = self.cluster_info.get_configmaps()
|
cfg_maps = self.cluster_info.get_configmaps()
|
||||||
|
Loading…
Reference in New Issue
Block a user