Skip to content

Commit 061c695

Browse files
committed
Azure: Return original SKU if Gen1 & Gen2 are set
This commit updates the `ms_azure.utils.update_skus` to not update the SKUs if both Gen1 and Gen2 are provided, instead it will return them to prevent erros by trying to change the SKU names with a possible new one which follows the strict naming convention. Refers to SPSTRAT-416
1 parent 4a709cf commit 061c695

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

cloudpub/ms_azure/utils.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,12 @@ def update_skus(
295295
disk_versions, default_gen=generation, alt_gen=alt_gen, plan_name=plan_name
296296
)
297297

298+
# If we have SKUs for both genenerations we don't need to update them as they're already
299+
# properly set.
300+
if len(old_skus) == 2:
301+
return old_skus
302+
303+
# Update SKUs to create the alternate gen.
298304
# The security type may exist only for Gen2, so it iterates over all gens to find it
299305
security_type = None
300306
# The alternate plan name ends with the suffix "-genX" and we can't change that once

tests/ms_azure/test_utils.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,13 @@ def test_update_existing_skus_gen2_default(
232232
self, technical_config_obj: VMIPlanTechConfig, metadata_azure_obj: AzurePublishingMetadata
233233
) -> None:
234234
"""Test for a "SKU update" from scratch."""
235+
skus = [
236+
VMISku.from_json(x)
237+
for x in [
238+
{"imageType": "x64Gen1", "skuId": "plan-1-gen1"},
239+
]
240+
]
241+
technical_config_obj.skus = skus
235242
res = update_skus(
236243
disk_versions=technical_config_obj.disk_versions,
237244
generation=metadata_azure_obj.generation,
@@ -252,7 +259,6 @@ def test_update_existing_skus_gen1_default(
252259
skus = [
253260
VMISku.from_json(x)
254261
for x in [
255-
{"imageType": "x64Gen1", "skuId": "plan1"},
256262
{"imageType": "x64Gen2", "skuId": "plan1-gen2", "securityType": ["trusted"]},
257263
]
258264
]

0 commit comments

Comments
 (0)