From 1835b30b952569bb1d53221b513df0b2e1cf993c Mon Sep 17 00:00:00 2001 From: Alexander Hebel Date: Mon, 18 Mar 2024 12:56:55 +0100 Subject: [PATCH 1/4] Add vm boot diagnostic profile --- pkg/azure/api/providerspec.go | 12 ++++++++++++ pkg/azure/provider/helpers/driver.go | 13 +++++++++++++ 2 files changed, 25 insertions(+) diff --git a/pkg/azure/api/providerspec.go b/pkg/azure/api/providerspec.go index ce69f9131..b9c7b9739 100644 --- a/pkg/azure/api/providerspec.go +++ b/pkg/azure/api/providerspec.go @@ -104,6 +104,9 @@ type AzureVirtualMachineProperties struct { // 3. Only `Flexible` variant of VMSS is currently supported. It is strongly recommended that consumers turn-off any // autoscaling capabilities as it interferes with the lifecycle management of MCM and auto-scaling capabilities offered by Cluster-Autoscaler. VirtualMachineScaleSet *AzureSubResource `json:"virtualMachineScaleSet,omitempty"` + // DiagnosticsProfile specifies if boot metrics are enabled and where they are stored + // For additional information see: [https://learn.microsoft.com/en-us/azure/virtual-machines/boot-diagnostics] + DiagnosticsProfile *AzureDiagnosticsProfile `json:"diagnosticsProfile,omitempty"` // Deprecated: Use either AvailabilitySet or VirtualMachineScaleSet instead MachineSet *AzureMachineSetConfig `json:"machineSet,omitempty"` } @@ -266,3 +269,12 @@ type AzureSubnetInfo struct { // SubnetName is the name of the subnet which is unique within a resource group. SubnetName string `json:"subnetName,omitempty"` } + +// AzureDiagnosticsProfile specifies boot diagnostic options +type AzureDiagnosticsProfile struct { + // Enabled configures boot diagnostics to be stored or not + Enabled bool `json:"enabled,omitempty"` + // StorageURI is the URI of the storage account to use for storing console output and screenshot. + // If not specified azure managed storage will be used. + StorageURI *string `json:"storageURI,omitempty"` +} diff --git a/pkg/azure/provider/helpers/driver.go b/pkg/azure/provider/helpers/driver.go index 441c3e854..41d121134 100644 --- a/pkg/azure/provider/helpers/driver.go +++ b/pkg/azure/provider/helpers/driver.go @@ -620,6 +620,7 @@ func createVMCreationParams(providerSpec api.AzureProviderSpec, imageRef armcomp }, AvailabilitySet: getAvailabilitySet(providerSpec.Properties.AvailabilitySet), VirtualMachineScaleSet: getVirtualMachineScaleSet(providerSpec.Properties.VirtualMachineScaleSet), + DiagnosticsProfile: getDiagnosticsProfile(providerSpec.Properties.DiagnosticsProfile), }, Tags: vmTags, Zones: getZonesFromProviderSpec(providerSpec), @@ -727,3 +728,15 @@ func getZonesFromProviderSpec(spec api.AzureProviderSpec) []*string { } return zones } + +func getDiagnosticsProfile(profile *api.AzureDiagnosticsProfile) *armcompute.DiagnosticsProfile { + if profile == nil { + return nil + } + return &armcompute.DiagnosticsProfile{ + BootDiagnostics: &armcompute.BootDiagnostics{ + Enabled: to.Ptr(profile.Enabled), + StorageURI: profile.StorageURI, + }, + } +} From a63cd653e34a50903771c63edef4ab63f4649c26 Mon Sep 17 00:00:00 2001 From: Alexander Hebel Date: Mon, 18 Mar 2024 13:27:42 +0100 Subject: [PATCH 2/4] add vm diagnostic profile to machine-class.yaml --- kubernetes/machine-class.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kubernetes/machine-class.yaml b/kubernetes/machine-class.yaml index 99be5bc13..4a7db5956 100644 --- a/kubernetes/machine-class.yaml +++ b/kubernetes/machine-class.yaml @@ -54,6 +54,9 @@ providerSpec: machineSet: id: Kind: + diagnosticsProfile: + enabled: false + # storageURI: resourceGroup: subnetInfo: # vnetResourceGroup: From 6a103fc23354ca8b03fc829418633f30e7fa8602 Mon Sep 17 00:00:00 2001 From: Alexander Hebel Date: Mon, 18 Mar 2024 13:31:32 +0100 Subject: [PATCH 3/4] DiagnosticsProfile as value instead of pointer to reduce complexity --- pkg/azure/api/providerspec.go | 2 +- pkg/azure/provider/helpers/driver.go | 19 ++++++------------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/pkg/azure/api/providerspec.go b/pkg/azure/api/providerspec.go index b9c7b9739..591de4076 100644 --- a/pkg/azure/api/providerspec.go +++ b/pkg/azure/api/providerspec.go @@ -106,7 +106,7 @@ type AzureVirtualMachineProperties struct { VirtualMachineScaleSet *AzureSubResource `json:"virtualMachineScaleSet,omitempty"` // DiagnosticsProfile specifies if boot metrics are enabled and where they are stored // For additional information see: [https://learn.microsoft.com/en-us/azure/virtual-machines/boot-diagnostics] - DiagnosticsProfile *AzureDiagnosticsProfile `json:"diagnosticsProfile,omitempty"` + DiagnosticsProfile AzureDiagnosticsProfile `json:"diagnosticsProfile,omitempty"` // Deprecated: Use either AvailabilitySet or VirtualMachineScaleSet instead MachineSet *AzureMachineSetConfig `json:"machineSet,omitempty"` } diff --git a/pkg/azure/provider/helpers/driver.go b/pkg/azure/provider/helpers/driver.go index 41d121134..048bdb775 100644 --- a/pkg/azure/provider/helpers/driver.go +++ b/pkg/azure/provider/helpers/driver.go @@ -620,7 +620,12 @@ func createVMCreationParams(providerSpec api.AzureProviderSpec, imageRef armcomp }, AvailabilitySet: getAvailabilitySet(providerSpec.Properties.AvailabilitySet), VirtualMachineScaleSet: getVirtualMachineScaleSet(providerSpec.Properties.VirtualMachineScaleSet), - DiagnosticsProfile: getDiagnosticsProfile(providerSpec.Properties.DiagnosticsProfile), + DiagnosticsProfile: &armcompute.DiagnosticsProfile{ + BootDiagnostics: &armcompute.BootDiagnostics{ + Enabled: to.Ptr(providerSpec.Properties.DiagnosticsProfile.Enabled), + StorageURI: providerSpec.Properties.DiagnosticsProfile.StorageURI, + }, + }, }, Tags: vmTags, Zones: getZonesFromProviderSpec(providerSpec), @@ -728,15 +733,3 @@ func getZonesFromProviderSpec(spec api.AzureProviderSpec) []*string { } return zones } - -func getDiagnosticsProfile(profile *api.AzureDiagnosticsProfile) *armcompute.DiagnosticsProfile { - if profile == nil { - return nil - } - return &armcompute.DiagnosticsProfile{ - BootDiagnostics: &armcompute.BootDiagnostics{ - Enabled: to.Ptr(profile.Enabled), - StorageURI: profile.StorageURI, - }, - } -} From 04983259591b02e48880600aa8ea3f221b7797ff Mon Sep 17 00:00:00 2001 From: Alexander Hebel Date: Wed, 20 Mar 2024 17:16:05 +0100 Subject: [PATCH 4/4] Add diagnostics profile --- pkg/azure/api/providerspec.go | 2 +- pkg/azure/provider/helpers/driver.go | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/pkg/azure/api/providerspec.go b/pkg/azure/api/providerspec.go index 591de4076..b9c7b9739 100644 --- a/pkg/azure/api/providerspec.go +++ b/pkg/azure/api/providerspec.go @@ -106,7 +106,7 @@ type AzureVirtualMachineProperties struct { VirtualMachineScaleSet *AzureSubResource `json:"virtualMachineScaleSet,omitempty"` // DiagnosticsProfile specifies if boot metrics are enabled and where they are stored // For additional information see: [https://learn.microsoft.com/en-us/azure/virtual-machines/boot-diagnostics] - DiagnosticsProfile AzureDiagnosticsProfile `json:"diagnosticsProfile,omitempty"` + DiagnosticsProfile *AzureDiagnosticsProfile `json:"diagnosticsProfile,omitempty"` // Deprecated: Use either AvailabilitySet or VirtualMachineScaleSet instead MachineSet *AzureMachineSetConfig `json:"machineSet,omitempty"` } diff --git a/pkg/azure/provider/helpers/driver.go b/pkg/azure/provider/helpers/driver.go index 048bdb775..41d121134 100644 --- a/pkg/azure/provider/helpers/driver.go +++ b/pkg/azure/provider/helpers/driver.go @@ -620,12 +620,7 @@ func createVMCreationParams(providerSpec api.AzureProviderSpec, imageRef armcomp }, AvailabilitySet: getAvailabilitySet(providerSpec.Properties.AvailabilitySet), VirtualMachineScaleSet: getVirtualMachineScaleSet(providerSpec.Properties.VirtualMachineScaleSet), - DiagnosticsProfile: &armcompute.DiagnosticsProfile{ - BootDiagnostics: &armcompute.BootDiagnostics{ - Enabled: to.Ptr(providerSpec.Properties.DiagnosticsProfile.Enabled), - StorageURI: providerSpec.Properties.DiagnosticsProfile.StorageURI, - }, - }, + DiagnosticsProfile: getDiagnosticsProfile(providerSpec.Properties.DiagnosticsProfile), }, Tags: vmTags, Zones: getZonesFromProviderSpec(providerSpec), @@ -733,3 +728,15 @@ func getZonesFromProviderSpec(spec api.AzureProviderSpec) []*string { } return zones } + +func getDiagnosticsProfile(profile *api.AzureDiagnosticsProfile) *armcompute.DiagnosticsProfile { + if profile == nil { + return nil + } + return &armcompute.DiagnosticsProfile{ + BootDiagnostics: &armcompute.BootDiagnostics{ + Enabled: to.Ptr(profile.Enabled), + StorageURI: profile.StorageURI, + }, + } +}