Provide full data to get_or_create_namespace

This commit is contained in:
Tobias Kunze 2025-06-15 18:06:30 +02:00
parent 5b7c26bbac
commit 918c2a20ec

View file

@ -210,8 +210,9 @@ class ControlPlane(ServalaModelMixin, models.Model):
except Exception as e:
return False, _("Connection error: {}").format(str(e))
def get_or_create_namespace(self, name):
def get_or_create_namespace(self, organization):
api_instance = kubernetes.client.CoreV1Api(self.get_kubernetes_client())
name = organization.namespace
try:
api_instance.read_namespace(name=name)
except kubernetes.client.ApiException as e:
@ -551,7 +552,7 @@ class ServiceInstance(ServalaModelMixin, models.Model):
@classmethod
def create_instance(cls, name, organization, context, created_by, spec_data):
# Ensure the namespace exists
context.control_plane.get_or_create_namespace(organization.namespace)
context.control_plane.get_or_create_namespace(organization)
try:
instance = cls.objects.create(
name=name,