From 72fedefb7f7c00af12988d47387f3fa131d3d96f Mon Sep 17 00:00:00 2001 From: Tobias Kunze Date: Tue, 14 Oct 2025 11:16:03 +0200 Subject: [PATCH] Roll back service creation on error ref #202 --- src/servala/core/models/service.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/servala/core/models/service.py b/src/servala/core/models/service.py index cecd7dd..7be6003 100644 --- a/src/servala/core/models/service.py +++ b/src/servala/core/models/service.py @@ -663,6 +663,7 @@ class ServiceInstance(ServalaModelMixin, models.Model): return mark_safe(f"") @classmethod + @transaction.atomic def create_instance(cls, name, organization, context, created_by, spec_data): # Ensure the namespace exists context.control_plane.get_or_create_namespace(organization) @@ -710,7 +711,7 @@ class ServiceInstance(ServalaModelMixin, models.Model): body=create_data, ) except Exception as e: - instance.delete() + # Transaction will automatically roll back the instance creation if isinstance(e, ApiException): try: error_body = json.loads(e.body)