Boot diagnostics: enable with managed storage account

This commit is contained in:
Lili Deng 2024-05-17 15:27:23 +08:00 коммит произвёл LiliDeng
Родитель 2e7180d6e2
Коммит 9bf9d585e0
5 изменённых файлов: 6 добавлений и 80 удалений

Просмотреть файл

@ -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
@ -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: {

Просмотреть файл

@ -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": {
@ -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'))]",

Просмотреть файл

@ -5,8 +5,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.24.24.22086",
"templateHash": "10469517385668739272"
"version": "0.25.53.49325",
"templateHash": "6371934161409477905"
}
},
"functions": [
@ -415,12 +415,6 @@
}
],
"parameters": {
"storage_name": {
"type": "string",
"metadata": {
"description": "storage name for boot diagnosis"
}
},
"vhd_storage_name": {
"type": "string",
"metadata": {
@ -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": {
@ -760,8 +753,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.24.24.22086",
"templateHash": "4605637987818789188"
"version": "0.25.53.49325",
"templateHash": "15038849300358134397"
}
},
"functions": [

Просмотреть файл

@ -1134,7 +1134,6 @@ class AvailabilityArmParameter:
@dataclass_json()
@dataclass
class AzureArmParameter:
storage_name: str = ""
vhd_storage_name: str = ""
location: str = ""
admin_username: str = ""

Просмотреть файл

@ -642,12 +642,6 @@ class AzurePlatform(Platform):
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(
@ -687,52 +681,6 @@ class AzurePlatform(Platform):
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] = {}
@ -1241,9 +1189,6 @@ class AzurePlatform(Platform):
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"
)