From 08b810de67a98d8d21584cf4f3511bf2ce46460b Mon Sep 17 00:00:00 2001 From: Luke Luong Date: Tue, 29 Oct 2024 14:00:30 -0700 Subject: [PATCH 1/2] Change performance diagnostics to use Managed Identity --- .../azureperformancediagnostics.py | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/microsoft/testsuites/vm_extensions/azureperformancediagnostics.py b/microsoft/testsuites/vm_extensions/azureperformancediagnostics.py index 5548ab1be4..1525a7a105 100644 --- a/microsoft/testsuites/vm_extensions/azureperformancediagnostics.py +++ b/microsoft/testsuites/vm_extensions/azureperformancediagnostics.py @@ -28,7 +28,7 @@ AzureNodeSchema, check_or_create_storage_account, get_node_context, - get_storage_credential, + add_system_assign_identity, list_blobs, ) from lisa.sut_orchestrator.azure.features import AzureExtension @@ -91,12 +91,15 @@ def verify_azure_performance_diagnostics( log=log, ) - account_credential = get_storage_credential( - credential=platform.credential, - subscription_id=platform.subscription_id, - cloud=platform.cloud, - account_name=storage_account_name, - resource_group_name=resource_group_name, + # Assign system identity to VM + # This MSI will be pre-configured with the necessary role assigments to Storage Account from Subscription level + # Permissions required: Storage Account Contributor, Storage Blob Data Contributor, Storage Blob Data Contributor + add_system_assign_identity( + platform=platform, + resource_group_name=node_context.resource_group_name, + vm_name=node_context.vm_name, + location=node_context.location, + log=log, ) # Run VM Extension @@ -116,7 +119,7 @@ def verify_azure_performance_diagnostics( protected_settings = { "storageAccountName": storage_account_name, - "storageAccountKey": account_credential.get("account_key"), + "authenticationType": "SystemManagedIdentity" } extension_result = extension.create_or_update( @@ -167,11 +170,11 @@ def _is_supported_linux_distro(self, node: Node) -> bool: CentOs: [6, 7], Oracle: [6, 7], Debian: [8, 9, 10, 11], - Ubuntu: [14, 16, 18, 20], + Ubuntu: [14, 16, 18, 20, 22], Suse: [12, 15], SLES: [12, 15], AlmaLinux: [8], - CBLMariner: [2], + CBLMariner: [2, 3], #AzureLinux uses CBLMariner class } for distro in supported_major_versions: From 21cd90ba13cde9299b02b3e9a5744a08946d4a0b Mon Sep 17 00:00:00 2001 From: Luke Luong Date: Wed, 13 Nov 2024 16:19:10 -0800 Subject: [PATCH 2/2] Address comments an fix flake8 warnings --- .../azureperformancediagnostics.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/microsoft/testsuites/vm_extensions/azureperformancediagnostics.py b/microsoft/testsuites/vm_extensions/azureperformancediagnostics.py index 1525a7a105..bd4fa3e588 100644 --- a/microsoft/testsuites/vm_extensions/azureperformancediagnostics.py +++ b/microsoft/testsuites/vm_extensions/azureperformancediagnostics.py @@ -26,9 +26,9 @@ from lisa.sut_orchestrator import AZURE from lisa.sut_orchestrator.azure.common import ( AzureNodeSchema, + add_system_assign_identity, check_or_create_storage_account, get_node_context, - add_system_assign_identity, list_blobs, ) from lisa.sut_orchestrator.azure.features import AzureExtension @@ -60,7 +60,7 @@ def before_case(self, log: Logger, **kwargs: Any) -> None: storage account key, which we cannot use currently. Will change it back once the extension works with MSI. """, - priority=5, + priority=1, requirement=simple_requirement( supported_features=[AzureExtension], ), @@ -92,8 +92,12 @@ def verify_azure_performance_diagnostics( ) # Assign system identity to VM - # This MSI will be pre-configured with the necessary role assigments to Storage Account from Subscription level - # Permissions required: Storage Account Contributor, Storage Blob Data Contributor, Storage Blob Data Contributor + # This MSI will be pre-configured with the necessary + # role assigments to Storage Account from Subscription level + # Permissions required: + # Storage Account Contributor + # Storage Blob Data Contributor + # Storage Blob Data Contributor add_system_assign_identity( platform=platform, resource_group_name=node_context.resource_group_name, @@ -119,7 +123,7 @@ def verify_azure_performance_diagnostics( protected_settings = { "storageAccountName": storage_account_name, - "authenticationType": "SystemManagedIdentity" + "authenticationType": "SystemManagedIdentity", } extension_result = extension.create_or_update( @@ -174,7 +178,8 @@ def _is_supported_linux_distro(self, node: Node) -> bool: Suse: [12, 15], SLES: [12, 15], AlmaLinux: [8], - CBLMariner: [2, 3], #AzureLinux uses CBLMariner class + # AzureLinux uses CBLMariner class + CBLMariner: [2, 3], } for distro in supported_major_versions: