Skip to content

Commit

Permalink
Boot diagnostics: enable with managed storage account
Browse files Browse the repository at this point in the history
  • Loading branch information
LiliDeng committed May 18, 2024
1 parent 2e7180d commit 9bf9d58
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 80 deletions.
4 changes: 0 additions & 4 deletions lisa/sut_orchestrator/azure/arm_template.bicep
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
@description('storage name for boot diagnosis')
param storage_name string

@description('storage name for copied vhds')
param vhd_storage_name string

Expand Down Expand Up @@ -345,7 +342,6 @@ resource nodes_vms 'Microsoft.Compute/virtualMachines@2022-08-01' = [for i in ra
diagnosticsProfile: {
bootDiagnostics: {
enabled: true
storageUri: reference(resourceId(shared_resource_group_name, 'Microsoft.Storage/storageAccounts', storage_name), '2015-06-15').primaryEndpoints.blob
}
}
additionalCapabilities: {
Expand Down
9 changes: 1 addition & 8 deletions lisa/sut_orchestrator/azure/arm_template.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"storage_name": {
"type": "string",
"metadata": {
"description": "storage name for boot diagnosis"
}
},
"vhd_storage_name": {
"type": "string",
"metadata": {
Expand Down Expand Up @@ -417,8 +411,7 @@
},
"diagnosticsProfile": {
"bootDiagnostics": {
"enabled": true,
"storageUri": "[reference(resourceId(parameters('shared_resource_group_name'), 'Microsoft.Storage/storageAccounts', parameters('storage_name')), '2015-06-15').primaryEndpoints['blob']]"
"enabled": true
}
},
"additionalCapabilities": "[if(equals(parameters('nodes')[copyIndex('vmCopy')]['data_disk_type'], 'UltraSSD_LRS'), json('{\"ultraSSDEnabled\": true}'), json('null'))]",
Expand Down
17 changes: 5 additions & 12 deletions lisa/sut_orchestrator/azure/autogen_arm_template.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.24.24.22086",
"templateHash": "10469517385668739272"
"version": "0.25.53.49325",
"templateHash": "6371934161409477905"
}
},
"functions": [
Expand Down Expand Up @@ -415,12 +415,6 @@
}
],
"parameters": {
"storage_name": {
"type": "string",
"metadata": {
"description": "storage name for boot diagnosis"
}
},
"vhd_storage_name": {
"type": "string",
"metadata": {
Expand Down Expand Up @@ -700,8 +694,7 @@
},
"diagnosticsProfile": {
"bootDiagnostics": {
"enabled": true,
"storageUri": "[reference(resourceId(parameters('shared_resource_group_name'), 'Microsoft.Storage/storageAccounts', parameters('storage_name')), '2015-06-15').primaryEndpoints.blob]"
"enabled": true
}
},
"additionalCapabilities": {
Expand Down Expand Up @@ -760,8 +753,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.24.24.22086",
"templateHash": "4605637987818789188"
"version": "0.25.53.49325",
"templateHash": "15038849300358134397"
}
},
"functions": [
Expand Down
1 change: 0 additions & 1 deletion lisa/sut_orchestrator/azure/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -1134,7 +1134,6 @@ class AvailabilityArmParameter:
@dataclass_json()
@dataclass
class AzureArmParameter:
storage_name: str = ""
vhd_storage_name: str = ""
location: str = ""
admin_username: str = ""
Expand Down
55 changes: 0 additions & 55 deletions lisa/sut_orchestrator/azure/platform_.py
Original file line number Diff line number Diff line change
Expand Up @@ -642,12 +642,6 @@ def _delete_environment(self, environment: Environment, log: Logger) -> None:
f"deleting resource group: {resource_group_name}, "
f"wait: {self._azure_runbook.wait_delete}"
)
try:
self._delete_boot_diagnostic_container(resource_group_name, log)
except Exception as identifier:
log.debug(
f"exception on deleting boot diagnostic container: {identifier}"
)
delete_operation: Any = None
try:
delete_operation = self._rm_client.resource_groups.begin_delete(
Expand Down Expand Up @@ -687,52 +681,6 @@ def _save_console_log_and_check_panic(
if check_serial_console is True:
check_panic(log_response_content.decode("utf-8"), "provision", log)

def _delete_boot_diagnostic_container(
self, resource_group_name: str, log: Logger
) -> None:
compute_client = get_compute_client(self)
vms = compute_client.virtual_machines.list(resource_group_name)
for vm in vms:
diagnostic_data = (
compute_client.virtual_machines.retrieve_boot_diagnostics_data(
resource_group_name=resource_group_name, vm_name=vm.name
)
)
if not diagnostic_data:
continue

# A sample url,
# https://storageaccountname.blob.core.windows.net:443/
# bootdiagnostics-node0-30779088-9b10-4074-8c27-98b91f1d8b70/
# node-0.30779088-9b10-4074-8c27-98b91f1d8b70.serialconsole.log
# ?sv=2018-03-28&sr=b&sig=mJEsvk9WunbKHfBs1lo1jcIBe4owq1brP8Kw3qXTQJA%3d&
# se=2021-09-14T08%3a55%3a38Z&sp=r
blob_uri = diagnostic_data.console_screenshot_blob_uri
if blob_uri:
matched = self._diagnostic_storage_container_pattern.match(blob_uri)
assert matched
# => storageaccountname
storage_name = matched.group("storage_name")
# => bootdiagnostics-node0-30779088-9b10-4074-8c27-98b91f1d8b70
container_name = matched.group("container_name")
container_client = get_or_create_storage_container(
credential=self.credential,
cloud=self.cloud,
account_name=storage_name,
container_name=container_name,
)
log.debug(
f"deleting boot diagnostic container: {container_name}"
f" under storage account {storage_name} of vm {vm.name}"
)
try:
container_client.delete_container()
except Exception as identifier:
log.debug(
f"exception on deleting boot diagnostic container:"
f" {identifier}"
)

def _get_node_information(self, node: Node) -> Dict[str, str]:
platform_runbook = cast(schema.Platform, self.runbook)
information: Dict[str, Any] = {}
Expand Down Expand Up @@ -1241,9 +1189,6 @@ def _create_deployment_parameters(
arm_parameters.admin_password = self.runbook.admin_password

arm_parameters.nodes = nodes_parameters
arm_parameters.storage_name = get_storage_account_name(
self.subscription_id, arm_parameters.location
)
arm_parameters.vhd_storage_name = get_storage_account_name(
self.subscription_id, arm_parameters.location, "t"
)
Expand Down

0 comments on commit 9bf9d58

Please sign in to comment.