Skip to content

OCPBUGS-57603: Disallow cross subscription encryption sets#10335

Open
rna-afk wants to merge 1 commit intoopenshift:mainfrom
rna-afk:add_disk_encryption_validation
Open

OCPBUGS-57603: Disallow cross subscription encryption sets#10335
rna-afk wants to merge 1 commit intoopenshift:mainfrom
rna-afk:add_disk_encryption_validation

Conversation

@rna-afk
Copy link
Contributor

@rna-afk rna-afk commented Feb 24, 2026

Since CAPZ does not support using encryption sets in a subscription not in the current subscription, adding a validation to return error if the subscriptions don't match.

@openshift-ci-robot openshift-ci-robot added jira/severity-moderate Referenced Jira bug's severity is moderate for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. labels Feb 24, 2026
@openshift-ci-robot
Copy link
Contributor

@rna-afk: This pull request references Jira Issue OCPBUGS-57603, which is invalid:

  • expected the bug to target the "4.22.0" version, but no target version was set

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

The bug has been updated to refer to the pull request using the external bug tracker.

Details

In response to this:

Since CAPZ does not support using encryption sets in a subscription not in the current subscription, adding a validation to return error if the subscriptions don't match.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci-robot openshift-ci-robot added the jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. label Feb 24, 2026
@openshift-ci openshift-ci bot requested review from jhixson74 and sadasu February 24, 2026 18:13
@rna-afk
Copy link
Contributor Author

rna-afk commented Feb 24, 2026

/jira refresh

@openshift-ci-robot openshift-ci-robot added jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. and removed jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Feb 24, 2026
@openshift-ci-robot
Copy link
Contributor

@rna-afk: This pull request references Jira Issue OCPBUGS-57603, which is valid. The bug has been moved to the POST state.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (4.22.0) matches configured target version for branch (4.22.0)
  • bug is in the state ASSIGNED, which is one of the valid states (NEW, ASSIGNED, POST)

Requesting review from QA contact:
/cc @jinyunma

Details

In response to this:

/jira refresh

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci openshift-ci bot requested a review from jinyunma February 24, 2026 23:34
@jinyunma
Copy link
Contributor

pre-merge test passed.

/verified by jima

@openshift-ci-robot openshift-ci-robot added the verified Signifies that the PR passed pre-merge verification criteria label Feb 26, 2026
@openshift-ci-robot
Copy link
Contributor

@jinyunma: This PR has been marked as verified by jima.

Details

In response to this:

pre-merge test passed.

/verified by jima

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

Copy link
Contributor

@patrickdillon patrickdillon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work figuring this out!

To summarize what we discussed: cross-subscription Disk Encryption Sets are not supported, but users can use a key vault from another subscription to create the DES.

Can you update the bug to indicate that as the recommended path for the bug reporter? It seems like that should immediately unblock them (although we will probably still need to deal with the managed key used to encrypt bootstrap ignition, but that is a separate bug).

I think there are a few more things we should do to improve the experience surrounding this API:

  • I don't think we should deprecate the field (although I could be convinced), but we should generally discourage users from using it. Can you update the field doc text to indicate: "Azure does not support cross-subscription disk-encryption sets. By default, the subscription from the installer credentials will be used. Therefore, setting this field is unnecessary."
  • Then we need to follow up on this promise of setting the defaults. We're already doing it in one place (more on that in a moment), but not in the machine manifests. Can you follow this pattern so that the default is set in the install config itself, and will be used everywhere:
    func (a *InstallConfig) finishGCP() error {

Basically you just need to create an Azure finish function wherfe if disk encryption is set, and subscription is empty, add the subscription from the creds.

  • Finally we can simplify the one code instance where the default is set, because it will be redundant:

subscriptionID := platform.OSDisk.DiskEncryptionSet.SubscriptionID
if subscriptionID == "" {
session, err := installConfig.Azure.Session()
if err != nil {
return errors.Wrap(err, "could not get azure session")
}
subscriptionID = session.Credentials.SubscriptionID
}

// GetDiskEncryptionSet retrieves the specified disk encryption set.
func (c *Client) GetDiskEncryptionSet(ctx context.Context, subscriptionID, groupName, diskEncryptionSetName string) (*azenc.DiskEncryptionSet, error) {
if c.ssn.Credentials.SubscriptionID != subscriptionID {
return nil, fmt.Errorf("different subscription from resource group subscription. CAPZ does not support cross subscription encryption sets")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CAPZ is an implementation detail here, so we wouldn't want to mention it by name. Also the restriction is in Azure

Suggested change
return nil, fmt.Errorf("different subscription from resource group subscription. CAPZ does not support cross subscription encryption sets")
return nil, fmt.Errorf("different subscription from resource group subscription. Azure does not support cross subscription encryption sets")

@jinyunma
Copy link
Contributor

but users can use a key vault from another subscription to create the DES.

@patrickdillon I tested with az command, this is also disallowed in Azure.

What I tested:

  1. created keyvault/key in subscription A, then created DES using this keyvault/key in subscription B, all of them were in the same region.
    Result: DES was created failed.
% az disk-encryption-set create -n $DISK_ENCRYPTION_SET_NAME -l $LOCATION -g $RESOURCEGROUP --source-vault $KEYVAULT_ID --key-url $KEYVAULT_KEY_URL
(InvalidParameter) The SubscriptionId:"53b8f551-f0fc-4bea-8cba-6d1fefd54c8a" of the request must match the SubscriptionId "8cbff7ff-5103-4cc2-b691-abbee101e1d0" contained in the Key Vault Id.
Code: InvalidParameter
Message: The SubscriptionId:"53b8f551-f0fc-4bea-8cba-6d1fefd54c8a" of the request must match the SubscriptionId "8cbff7ff-5103-4cc2-b691-abbee101e1d0" contained in the Key Vault Id.
Target: diskEncryptionSet.properties.activeKey.sourceVault.id
  1. created keyvault/key/DES in subscription A, create VM in subscription B with DES configured.
    Result: VM created failed, same as bug description.
% az vm create --name jima-vm --resource-group jima-test-rg --image RedHat:RHEL:8-lvm-gen2:8.6.2022051814  --size Standard_D8s_v3 --admin-username core --ssh-key-values <key.pub> --os-disk-encryption-set $DES_RESOURCE_ID
{"status":"Failed","error":{"code":"DeploymentFailed","target":"/subscriptions/53b8f551-f0fc-4bea-8cba-6d1fefd54c8a/resourceGroups/jima-test-rg/providers/Microsoft.Resources/deployments/vm_deploy_Imxll7mR1VkSg8NKFYQxkQ0v8HuEUWxv","message":"At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-deployment-operations for usage details.","details":[{"code":"BadRequest","target":"CRP disk id 9bcbbd01-07b6-4c41-909b-626a2268230b","message":"DiskEncryptionSet '/subscriptions/8cbff7ff-5103-4cc2-b691-abbee101e1d0/resourceGroups/jima-test-rg/providers/Microsoft.Compute/diskEncryptionSets/jima-des' was not found."}]}}

So look like that Azure doc is misleading, that's not TRUE!
"Azure Key Vaults may be used from a different subscription but must be in the same region as your disk encryption set. "
DES, keyvault, VM and disk should be in the same subscription.

Since CAPZ does not support using encryption sets in a subscription
not in the current subscription, adding a validation to return
error if the subscriptions don't match.
@rna-afk rna-afk force-pushed the add_disk_encryption_validation branch from 2a64205 to cdf725a Compare March 5, 2026 21:29
@openshift-ci-robot openshift-ci-robot removed the verified Signifies that the PR passed pre-merge verification criteria label Mar 5, 2026
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 5, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign jcpowermac for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 6, 2026

@rna-afk: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/azure-private cdf725a link false /test azure-private
ci/prow/e2e-azure-default-config cdf725a link false /test e2e-azure-default-config
ci/prow/azure-ovn-marketplace-images cdf725a link false /test azure-ovn-marketplace-images
ci/prow/e2e-azure-ovn-shared-vpc cdf725a link false /test e2e-azure-ovn-shared-vpc
ci/prow/e2e-azurestack cdf725a link false /test e2e-azurestack
ci/prow/e2e-azure-ovn cdf725a link true /test e2e-azure-ovn

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@patrickdillon
Copy link
Contributor

@patrickdillon I tested with az command, this is also disallowed in Azure.

@jinyunma thank you for testing this crucial detail!

if err != nil {
return err
}
a.Config.Azure.DefaultMachinePlatform.OSDisk.SubscriptionID = session.Credentials.SubscriptionID
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, subscriptionID must be set, otherwise installer exited with error:

$ ./openshift-install create manifests --dir ipi4
INFO ipFamily is not specified in install-config; defaulting to "IPv4" 
ERROR failed to fetch Master Machines: failed to load asset "Install Config": failed to create install config: invalid "install-config.yaml" file: [controlPlane.platform.azure.defaultMachinePlatform.osDisk.diskEncryptionSet.subscriptionID: Required value: subscription ID is required, compute[0].platform.azure.defaultMachinePlatform.osDisk.diskEncryptionSet.subscriptionID: Required value: subscription ID is required] 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

jira/severity-moderate Referenced Jira bug's severity is moderate for the branch this PR is targeting. jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants