Skip to content

Commit

Permalink
hypershift delete assets prior to vms
Browse files Browse the repository at this point in the history
  • Loading branch information
karmab committed Jun 19, 2024
1 parent 06d9a3e commit 114cac0
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions kvirt/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2807,6 +2807,19 @@ def delete_kube(self, cluster, overrides={}):
deleteclients.update(self.extraclients)
elif vmclients:
deleteclients.update({cli: Kconfig(client=cli).k for cli in vmclients if cli != self.client})
if hypershift:
kubeconfigmgmt = f"{clusterdir}/kubeconfig.mgmt"
if os.path.exists(f'{clusterdir}/bmcs.yml'):
call(f'KUBECONFIG={kubeconfigmgmt} oc delete -f {clusterdir}/bmcs.yml', shell=True)
call(f'KUBECONFIG={kubeconfigmgmt} oc delete -f {clusterdir}/autoapprovercron.yml', shell=True)
call(f'KUBECONFIG={kubeconfigmgmt} oc delete -f {clusterdir}/nodepool.yaml', shell=True)
call(f'KUBECONFIG={kubeconfigmgmt} oc delete -f {clusterdir}/hostedcluster.yaml', shell=True)
if not assisted and ('baremetal_iso' in clusterdata or 'baremetal_hosts' in clusterdata):
call(f'KUBECONFIG={kubeconfigmgmt} oc -n default delete all -l app=httpd-kcli', shell=True)
call(f'KUBECONFIG={kubeconfigmgmt} oc -n default delete pvc httpd-kcli-pvc', shell=True)
ingress_ip = clusterdata.get('ingress_ip')
if self.type == 'kubevirt' and clusterdata.get('platform') is None and ingress_ip is None:
call(f'KUBECONFIG={kubeconfigmgmt} oc -n {k.namespace} delete route {cluster}-ingress', shell=True)
for hypervisor in deleteclients:
c = deleteclients[hypervisor]
for vm in sorted(c.list(), key=lambda x: x['name']):
Expand Down Expand Up @@ -2872,21 +2885,6 @@ def delete_kube(self, cluster, overrides={}):
z = Kconfig(client=dnsclient).k
z.delete_dns(f"api.{cluster}", domain)
z.delete_dns(f"apps.{cluster}", domain)
if hypershift:
kubeconfigmgmt = f"{clusterdir}/kubeconfig.mgmt"
if os.path.exists(f'{clusterdir}/bmcs.yml'):
call(f'KUBECONFIG={kubeconfigmgmt} oc delete -f {clusterdir}/bmcs.yml', shell=True)
call(f'KUBECONFIG={kubeconfigmgmt} oc delete -f {clusterdir}/autoapprovercron.yml', shell=True)
call(f'KUBECONFIG={kubeconfigmgmt} oc delete -f {clusterdir}/nodepool.yaml', shell=True)
call(f'KUBECONFIG={kubeconfigmgmt} oc delete -f {clusterdir}/hostedcluster.yaml', shell=True)
if os.path.exists(f'{clusterdir}/assisted_infra.yml'):
call(f'KUBECONFIG={kubeconfigmgmt} oc delete -f {clusterdir}/assisted_infra.yml', shell=True)
if not assisted and ('baremetal_iso' in clusterdata or 'baremetal_hosts' in clusterdata):
call(f'KUBECONFIG={kubeconfigmgmt} oc -n default delete all -l app=httpd-kcli', shell=True)
call(f'KUBECONFIG={kubeconfigmgmt} oc -n default delete pvc httpd-kcli-pvc', shell=True)
ingress_ip = clusterdata.get('ingress_ip')
if self.type == 'kubevirt' and clusterdata.get('platform') is None and ingress_ip is None:
call(f'KUBECONFIG={kubeconfigmgmt} oc -n {k.namespace} delete route {cluster}-ingress', shell=True)
if gke:
gcpclient = None
if 'client' in clusterdata:
Expand Down

0 comments on commit 114cac0

Please sign in to comment.