From 5e7465f95fb4040a80e6a470aa3b1c203714f003 Mon Sep 17 00:00:00 2001 From: marrobi Date: Wed, 2 Aug 2023 12:32:14 +0000 Subject: [PATCH 1/5] Custom actions fail in release 0.12 Fixes #3646 --- CHANGELOG.md | 1 + api_app/service_bus/helpers.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 06dc05c384..f61a432ecf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ FEATURES: ENHANCEMENTS: BUG FIXES: +* Cusotm actions fail on resources with a pipline ([#3646](https://github.com/microsoft/AzureTRE/issues/3646)) ## 0.12.0 (July 27, 2023) diff --git a/api_app/service_bus/helpers.py b/api_app/service_bus/helpers.py index 050e48b83f..5c791b6f77 100644 --- a/api_app/service_bus/helpers.py +++ b/api_app/service_bus/helpers.py @@ -63,8 +63,8 @@ async def update_resource_for_step(operation_step: OperationStep, resource_repo: parent_template = await resource_template_repo.get_template_by_name_and_version(step_resource.templateName, step_resource.templateVersion, step_resource.resourceType, step_resource_parent_service_name) - # if there are no pipelines, no need to continue with substitutions. - if not parent_template.pipeline: + # if there are no pipelines, or custom action, no need to continue with substitutions. + if not parent_template.pipeline or primary_action not in parent_template.pipeline.dict(): return step_resource pipeline_primary_action = parent_template.pipeline.dict()[primary_action] From 4f1bdc4db78feb3f56765628e522653e70ae695a Mon Sep 17 00:00:00 2001 From: marrobi Date: Wed, 2 Aug 2023 13:10:27 +0000 Subject: [PATCH 2/5] up api version --- api_app/_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api_app/_version.py b/api_app/_version.py index 07c3e7b824..66a62a276d 100644 --- a/api_app/_version.py +++ b/api_app/_version.py @@ -1 +1 @@ -__version__ = "0.15.6" +__version__ = "0.15.7" From 810688420441391c58910227b27c676b30499c2e Mon Sep 17 00:00:00 2001 From: marrobi Date: Wed, 2 Aug 2023 13:21:16 +0000 Subject: [PATCH 3/5] up api version --- api_app/_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api_app/_version.py b/api_app/_version.py index 07c3e7b824..66a62a276d 100644 --- a/api_app/_version.py +++ b/api_app/_version.py @@ -1 +1 @@ -__version__ = "0.15.6" +__version__ = "0.15.7" From b959320b69fef21e2ab793d9bc0f96642c2e1639 Mon Sep 17 00:00:00 2001 From: marrobi Date: Wed, 2 Aug 2023 15:28:56 +0000 Subject: [PATCH 4/5] Make DRY --- api_app/service_bus/helpers.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/api_app/service_bus/helpers.py b/api_app/service_bus/helpers.py index 5c791b6f77..1e1def5a1d 100644 --- a/api_app/service_bus/helpers.py +++ b/api_app/service_bus/helpers.py @@ -63,18 +63,20 @@ async def update_resource_for_step(operation_step: OperationStep, resource_repo: parent_template = await resource_template_repo.get_template_by_name_and_version(step_resource.templateName, step_resource.templateVersion, step_resource.resourceType, step_resource_parent_service_name) + parent_template_pipeline_dict = parent_template.pipeline.dict() + # if there are no pipelines, or custom action, no need to continue with substitutions. - if not parent_template.pipeline or primary_action not in parent_template.pipeline.dict(): + if not parent_template.pipeline or primary_action not in parent_template_pipeline_dict: return step_resource - pipeline_primary_action = parent_template.pipeline.dict()[primary_action] + pipeline_primary_action = parent_template_pipeline_dict[primary_action] is_first_main_step = pipeline_primary_action and len(pipeline_primary_action) == 1 and pipeline_primary_action[0]['stepId'] == 'main' if not pipeline_primary_action or is_first_main_step: return step_resource # get the template step template_step = None - for step in parent_template.pipeline.dict()[primary_action]: + for step in parent_template_pipeline_dict[primary_action]: if step["stepId"] == operation_step.templateStepId: template_step = parse_obj_as(PipelineStep, step) break From d2ee1af3825fb1c0043dfa8a9803c0758a9916fd Mon Sep 17 00:00:00 2001 From: marrobi Date: Wed, 2 Aug 2023 16:47:12 +0000 Subject: [PATCH 5/5] Fix case where calling dict on empty pipeline --- api_app/service_bus/helpers.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/api_app/service_bus/helpers.py b/api_app/service_bus/helpers.py index 1e1def5a1d..729b9953af 100644 --- a/api_app/service_bus/helpers.py +++ b/api_app/service_bus/helpers.py @@ -63,10 +63,14 @@ async def update_resource_for_step(operation_step: OperationStep, resource_repo: parent_template = await resource_template_repo.get_template_by_name_and_version(step_resource.templateName, step_resource.templateVersion, step_resource.resourceType, step_resource_parent_service_name) + # if there are no pipelines, or custom action, no need to continue with substitutions. + if not parent_template.pipeline: + return step_resource + parent_template_pipeline_dict = parent_template.pipeline.dict() - # if there are no pipelines, or custom action, no need to continue with substitutions. - if not parent_template.pipeline or primary_action not in parent_template_pipeline_dict: + # if action not defined as a pipeline, custom action, no need to continue with substitutions. + if primary_action not in parent_template_pipeline_dict: return step_resource pipeline_primary_action = parent_template_pipeline_dict[primary_action]