Skip to content

Commit

Permalink
Merge pull request #1601 from grycap/devel
Browse files Browse the repository at this point in the history
Fix error deleting ns
  • Loading branch information
micafer authored Jul 24, 2024
2 parents 30ba415 + fd5ed42 commit fa317d1
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions IM/connectors/Kubernetes.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,10 +502,7 @@ def _generate_pod_data(self, namespace, name, outports, system, volumes, configm

return pod_data

def launch(self, inf, radl, requested_radl, num_vm, auth_data):
system = radl.systems[0]

res = []
def _get_namespace(self, inf, auth_data):
_, namespace = self.get_auth_header(auth_data)
# If the namespace is set in the auth_data use it
if not namespace:
Expand All @@ -514,6 +511,13 @@ def launch(self, inf, radl, requested_radl, num_vm, auth_data):
if inf.radl.description and inf.radl.description.getValue('namespace'):
# finally if it is set in the RADL use it
namespace = inf.radl.description.getValue('namespace')
return namespace

def launch(self, inf, radl, requested_radl, num_vm, auth_data):
system = radl.systems[0]

res = []
namespace = self._get_namespace(inf, auth_data)

# First create the namespace for the infrastructure
headers = {'Content-Type': 'application/json'}
Expand Down Expand Up @@ -622,7 +626,11 @@ def _get_pod(self, vm, auth_data):
try:
namespace = vm.id.split("/")[0]
pod_name = vm.id.split("/")[1]
except Exception as ex:
self.log_exception("Error invalid VM id")
return (False, None, "Error invalid VM id: " + str(ex))

try:
uri = "/api/v1/namespaces/%s/%s/%s" % (namespace, "pods", pod_name)
resp = self.create_request('GET', uri, auth_data)

Expand Down Expand Up @@ -724,7 +732,10 @@ def finalize(self, vm, last, auth_data):
return success, msg

def _delete_namespace(self, vm, auth_data):
namespace = vm.id.split("/")[0]
if vm.id:
namespace = vm.id.split("/")[0]
else:
namespace = self._get_namespace(vm.inf, auth_data)
self.log_debug("Deleting Namespace: %s" % namespace)
uri = "/api/v1/namespaces/%s" % namespace

Expand Down

0 comments on commit fa317d1

Please sign in to comment.