Skip to content

Commit 62afd6b

Browse files
Copilotmarrobi
andauthored
fix: make Porter parameter set name unique per run using UUID suffix
Agent-Logs-Url: https://github.com/microsoft/AzureTRE/sessions/c0be6c59-94cb-4a09-8225-b1726b0f6c58 Co-authored-by: marrobi <17089773+marrobi@users.noreply.github.com>
1 parent f6aeecf commit 62afd6b

2 files changed

Lines changed: 11 additions & 8 deletions

File tree

resource_processor/helpers/commands.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import base64
44
import logging
55
import tempfile
6+
import uuid
67
from urllib.parse import urlparse
78

89
from shared.logging import logger, shell_output_logger
@@ -124,7 +125,7 @@ async def build_porter_command(config, msg_body, custom_action=False):
124125
})
125126

126127
installation_id = msg_body['id']
127-
param_set_name = f"tre-params-{installation_id}"
128+
param_set_name = f"tre-params-{installation_id}-{uuid.uuid4().hex[:8]}"
128129

129130
param_set_file = None
130131
if param_set_entries:

resource_processor/tests_rp/test_commands.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ async def test_build_porter_command(mock_get_porter_parameter_keys):
6262
commands, param_set_file, param_set_name = await build_porter_command(config, msg_body)
6363
try:
6464
assert param_set_file is not None
65-
assert param_set_name == "tre-params-guid"
65+
assert param_set_name.startswith("tre-params-guid-")
66+
assert len(param_set_name) == len("tre-params-guid-") + 8
6667
assert os.path.exists(param_set_file)
6768

6869
# First command applies the parameter set to Porter's store
@@ -72,7 +73,7 @@ async def test_build_porter_command(mock_get_porter_parameter_keys):
7273
assert commands[1] == [
7374
"porter", "install", "guid",
7475
"--reference", "myregistry.azurecr.io/mybundle:v1.0.0",
75-
"--parameter-set", "tre-params-guid",
76+
"--parameter-set", param_set_name,
7677
"--force",
7778
"--credential-set", "arm_auth",
7879
"--credential-set", "aad_auth"
@@ -82,7 +83,7 @@ async def test_build_porter_command(mock_get_porter_parameter_keys):
8283
param_set = json.load(f)
8384

8485
assert param_set["schemaType"] == "ParameterSet"
85-
assert param_set["name"] == "tre-params-guid"
86+
assert param_set["name"] == param_set_name
8687
assert len(param_set["parameters"]) == 1
8788
assert param_set["parameters"][0] == {"name": "param1", "source": {"value": "value1"}}
8889
finally:
@@ -100,7 +101,7 @@ async def test_build_porter_command_for_upgrade(mock_get_porter_parameter_keys):
100101
commands, param_set_file, param_set_name = await build_porter_command(config, msg_body)
101102
try:
102103
assert param_set_file is not None
103-
assert param_set_name == "tre-params-guid"
104+
assert param_set_name.startswith("tre-params-guid-")
104105
assert os.path.exists(param_set_file)
105106

106107
# First command applies the parameter set to Porter's store
@@ -110,7 +111,7 @@ async def test_build_porter_command_for_upgrade(mock_get_porter_parameter_keys):
110111
assert commands[1] == [
111112
"porter", "upgrade", "guid",
112113
"--reference", "myregistry.azurecr.io/mybundle:v1.0.0",
113-
"--parameter-set", "tre-params-guid",
114+
"--parameter-set", param_set_name,
114115
"--force",
115116
"--credential-set", "arm_auth",
116117
"--credential-set", "aad_auth",
@@ -145,7 +146,7 @@ async def test_build_porter_command_no_parameters(mock_get_porter_parameter_keys
145146
commands, param_set_file, param_set_name = await build_porter_command(config, msg_body)
146147

147148
assert param_set_file is None
148-
assert param_set_name == "tre-params-guid"
149+
assert param_set_name.startswith("tre-params-guid-")
149150
assert commands == [[
150151
"porter", "install", "guid",
151152
"--reference", "myregistry.azurecr.io/mybundle:v1.0.0",
@@ -185,7 +186,8 @@ async def test_build_porter_command_with_complex_parameters(mock_get_porter_para
185186
# Main porter command should reference the parameter set by name
186187
main_command = commands[1]
187188
assert "--parameter-set" in main_command
188-
assert "tre-params-guid" in main_command
189+
assert param_set_name in main_command
190+
assert param_set_name.startswith("tre-params-guid-")
189191
assert "--param" not in main_command
190192

191193
# Verify the param set file contains the correct parameters

0 commit comments

Comments
 (0)