From a643a5a69ba97aedfb1eedc052dc27324ec5a072 Mon Sep 17 00:00:00 2001 From: Tanya Borisova Date: Thu, 27 Oct 2022 11:45:21 +0100 Subject: [PATCH] Fail Firewall migration if there's no firewall --- api_app/_version.py | 2 +- api_app/db/migrations/shared_services.py | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/api_app/_version.py b/api_app/_version.py index 86716a713a..a779a44262 100644 --- a/api_app/_version.py +++ b/api_app/_version.py @@ -1 +1 @@ -__version__ = "0.5.5" +__version__ = "0.5.6" diff --git a/api_app/db/migrations/shared_services.py b/api_app/db/migrations/shared_services.py index 454ad60c1a..8651ccef2f 100644 --- a/api_app/db/migrations/shared_services.py +++ b/api_app/db/migrations/shared_services.py @@ -30,10 +30,13 @@ def checkMinFirewallVersion(self) -> bool: template_name = 'tre-shared-service-firewall' min_template_version = semantic_version.Version('0.4.0') - resource = self.query(query=f'SELECT * FROM c WHERE c.resourceType = "shared-service" \ + resources = self.query(query=f'SELECT * FROM c WHERE c.resourceType = "shared-service" \ AND c.templateName = "{template_name}" AND {IS_OPERATING_SHARED_SERVICE}') - template_version = semantic_version.Version(resource[0]["templateVersion"]) + if not resources: + raise ValueError(f"Expecting to have an instance of Firewall (template name {template_name}) deployed in a successful TRE deployment") + + template_version = semantic_version.Version(resources[0]["templateVersion"]) if (template_version < min_template_version): raise ValueError(f"{template_name} deployed version ({template_version}) is below minimum ({min_template_version})!",