Skip to content

Commit 6ec00c7

Browse files
committed
azure: do not use marketplace images for confidential VMs
Marketplace images do not support confidential VMs or trusted launch, so when machinesets use confidential VMs the installer will still create an image gallery compatible with the security settings.
1 parent 8eef546 commit 6ec00c7

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

pkg/asset/rhcos/image.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,11 @@ func osImage(ctx context.Context, ic *installconfig.InstallConfig, machinePool *
149149
return "", fmt.Errorf("%s: No azure build found", streamArchPrefix)
150150
}
151151
azi := ext.AzureDisk.URL
152+
azMP := machinePool.Platform.Azure
153+
confidentialVM := azMP != nil && azMP.Settings != nil && azMP.Settings.SecurityType != ""
152154
if mkt := ext.Marketplace; mkt == nil || mkt.Azure == nil || mkt.Azure.NoPurchasePlan == nil || mkt.Azure.NoPurchasePlan.Gen2 == nil {
153155
logrus.Warnf("%s: No default Azure marketplace image was found in stream", streamArchPrefix)
154-
} else {
156+
} else if !confidentialVM { // Marketplace images don't suppot confidential VMs, so stick with managed image.
155157
gen, err := getHyperVGeneration(ic.Azure, machinePool.Name)
156158
if err != nil {
157159
return "", fmt.Errorf("failed to get hyperVGeneration: %w", err)

pkg/infrastructure/azure/azure.go

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)