@@ -254,8 +254,9 @@ func (p *Provider) InfraReady(ctx context.Context, in clusterapi.InfraReadyInput
254254 logrus .Debugf ("StorageAccount.ID=%s" , * storageAccount .ID )
255255 }
256256
257- // Create a managed image, which is only used for OKD, as OCP can use marketplace images.
258- if installConfig .IsOKD () && platform .CloudName != aztypes .StackCloud {
257+ // Create a managed image, which is used for OKD or confidential VMs on OCP.
258+ hasConfidentialVM := getMachinePoolSecurityType (installConfig ) == ""
259+ if (hasConfidentialVM || installConfig .IsOKD ()) && platform .CloudName != aztypes .StackCloud {
259260 // Create vhd blob storage container
260261 publicAccess := armstorage .PublicAccessNone
261262 createBlobContainerOutput , err := CreateBlobContainer (ctx , & CreateBlobContainerInput {
@@ -327,10 +328,7 @@ func (p *Provider) InfraReady(ctx context.Context, in clusterapi.InfraReadyInput
327328 // If Control Plane Security Type is provided, then pass that along
328329 // during Gen V2 Gallery Image creation. It will be added as a
329330 // supported feature of the image.
330- securityType , err := getMachinePoolSecurityType (in )
331- if err != nil {
332- return err
333- }
331+ securityType := getMachinePoolSecurityType (installConfig )
334332
335333 _ , err = CreateGalleryImage (ctx , & CreateGalleryImageInput {
336334 ResourceGroupName : resourceGroupName ,
@@ -803,16 +801,16 @@ func (p Provider) Ignition(ctx context.Context, in clusterapi.IgnitionInput) ([]
803801 return ignSecrets , nil
804802}
805803
806- func getMachinePoolSecurityType (in clusterapi. InfraReadyInput ) ( string , error ) {
804+ func getMachinePoolSecurityType (installConfig * types. InstallConfig ) string {
807805 var securityType aztypes.SecurityTypes
808- if in . InstallConfig . Config . ControlPlane != nil && in . InstallConfig . Config .ControlPlane .Platform .Azure != nil {
809- pool := in . InstallConfig . Config .ControlPlane .Platform .Azure
806+ if installConfig . ControlPlane != nil && installConfig .ControlPlane .Platform .Azure != nil {
807+ pool := installConfig .ControlPlane .Platform .Azure
810808 if pool .Settings != nil {
811809 securityType = pool .Settings .SecurityType
812810 }
813811 }
814- if securityType == "" && in . InstallConfig . Config .Compute != nil {
815- for _ , compute := range in . InstallConfig . Config .Compute {
812+ if securityType == "" && installConfig .Compute != nil {
813+ for _ , compute := range installConfig .Compute {
816814 if compute .Platform .Azure != nil {
817815 pool := compute .Platform .Azure
818816 if pool .Settings != nil {
@@ -822,17 +820,17 @@ func getMachinePoolSecurityType(in clusterapi.InfraReadyInput) (string, error) {
822820 }
823821 }
824822 }
825- if securityType == "" && in . InstallConfig . Config .Platform .Azure .DefaultMachinePlatform != nil {
826- pool := in . InstallConfig . Config .Platform .Azure .DefaultMachinePlatform
823+ if securityType == "" && installConfig .Platform .Azure .DefaultMachinePlatform != nil {
824+ pool := installConfig .Platform .Azure .DefaultMachinePlatform
827825 if pool .Settings != nil {
828826 securityType = pool .Settings .SecurityType
829827 }
830828 }
831829 switch securityType {
832830 case aztypes .SecurityTypesTrustedLaunch :
833- return trustedLaunchST , nil
831+ return trustedLaunchST
834832 case aztypes .SecurityTypesConfidentialVM :
835- return confidentialVMST , nil
833+ return confidentialVMST
836834 }
837- return "" , nil
835+ return ""
838836}
0 commit comments