feat(backend): add node pool encryption at host validation #7498
Pipeline controller notification
This PR uses the pipeline controller for second-stage tests. Selection and triggering follow the repository configuration.
Use /test ? to list jobs and /pipeline help for commands.
The deployed DEV/CSPR FPA mock cannot authorize this new call: dev-infrastructure/templates/e2e-subscription-rbac-assignment-subscription.bicep:60-68 grants that principal only SAL and resource-group actions, with no Microsoft.Features read action. Consequently Get will return an authorization error and every encryption-enabled node pool in those environments will remain Unknown/requirements-invalid. Add the required feature-read permission to the mock role and reapply its subscription assignments; also verify the production FPA contract before rollout.
Registering this controller changes the documented backend controller catalog and Cosmos write flow, but docs/cosmos-data-flow.md still omits this validation (and its controller totals). Repository guidance requires regenerating that document and its synchronized graph sources/artifacts whenever controller implementation or startup registration changes.
<!-- ccr-overview-v2 -->
🟡 Changes recommended
The feature lookup lacks required mock-FPA authorization, and mandatory controller data-flow documentation is missing.
<details open>
<summary><strong>2 open findings</strong></summary>
</details>
<details>
<summary><strong>What changed in this PR</strong></summary>
Adds backend validation for node-pool encryption-at-host prerequisites.
Changes:
| File | Description |
| ---- | ----------- |
| backend/go.mod | Adds Azure Features SDK. |
| backend/go.sum | Records dependency checksums. |
| test-integration/go.mod | Propagates indirect dependency. |
| test-integration/go.sum | Records integration checksums. |
| backend/pkg/azure/client/features_client.go | Defines Features client interface. |
| backend/pkg/azure/client/mock_features_client.go | Adds generated client mock. |
| backend/pkg/azure/client/fpa_client_builder.go | Constructs Features clients. |
| backend/pkg/azure/client/mock_fpa_client_builder.go | Extends builder mock. |
| backend/pkg/azure/azuremockclient/mock_clients.go | Implements expanded builder interface. |
| backend/pkg/utils/validationutils/resource_sku_capabilities.go | Adds encryption capability lookup. |
| backend/pkg/utils/validationutils/resource_sku_capabilities_test.go | Tests capability lookup. |
| backend/pkg/utils/validationutils/azure_nodepool_encryption_at_host_validation.go | Implements prerequisite validation. |
| backend/pkg/utils/validationutils/azure_nodepool_encryption_at_host_validation_test.go | Tests validation outcomes. |
| backend/pkg/controllers/nodepool/validation/nodepool_validation_controller.go | Adds controller name. |
| backend/pkg/controllers/nodepool/registration.go | Registers the controller. |
| backend/pkg/app/controller_registry_test.go | Updates registry expectations. |
</details>
<details>
<summary>Files not reviewed (2)</summary>
backend/pkg/azure/client/mock_features_client.go: Generated file
backend/pkg/azure/client/mock_fpa_client_builder.go: Generated file
</details>
🧠 Review effort: Balanced
---
💡 <a href="/Azure/ARO-HCP/new/main?filename=.github/skills/code-review/SKILL.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Add a code-review agent skill</a> or configure MCP servers for context-aware, tailored reviews. <a href="https://docs.github.com/copilot/how-tos/use-copilot-agents/request-a-code-review/use-code-review?tool=webui#mcp-servers-and-agent-skills" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Learn more in the docs.</a>
Scheduling tests matching the pipeline_run_if_changed or not excluded by pipeline_skip_if_only_changed parameters:
/test e2e-parallel
This mock has been in use with CS without issue @copilot
if nodePoolSubscription.Properties == nil || nodePoolSubscription.Properties.TenantId == nil || len(*nodePoolSubscription.Properties.TenantId) == 0 {
do we want to ignore casing? We used to not ignore casing in CS but asking if this is something we want to consder
good question...
Azure doesn't really provide documentation nor guidance about it so there's no answer nor consistent way and it depends on each case.
In https://learn.microsoft.com/en-us/javascript/api/@azure/arm-features/subscriptionfeatureregistrationstate?view=azure-node-latest for example it documents the values cased. But then in the https://learn.microsoft.com/en-us/rest/api/resources/features/get?view=rest-resources-2021-07-01&tabs=HTTP sample response it shows lowercase
The actual API call returns it cased:
msoriano@localhost:~/go/src/github.com/Azure/ARO-HCP (add-np-encryptionathost-validation)(ocm:?)$ az feature show --namespace Microsoft.Compute --name EncryptionAtHost --query '{name:name, state:properties.state}' -o json
{
"name": "Microsoft.Compute/EncryptionAtHost",
"state": "Registered"
}
So, who knows. It doesn't really seem possible to know what should be done and I suspect ignoring casing can be dangerous in some cases.
I am going to ignore casing because of having seen differences in several written places. In this case because semantically they mean the same I am fine with ignoring the casing.
Makes sense to ignore casing and thank you for the fix and detailed followup on this
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED
This pull-request has been approved by: <a href="https://github.com/Azure/ARO-HCP/pull/7498#pullrequestreview-5515603478" title="LGTM">machi1990</a>, <a href="https://github.com/Azure/ARO-HCP/pull/7498#" title="Author self-approved">miguelsorianod</a>
The full list of commands accepted by this bot can be found here.
The pull request process is described 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
</details>
<!-- META={"approvers":[]} -->
The PR description does not reference a Jira/GitHub tracking ticket or explain why no ticket exists. CONTRIBUTING.md:98-101 requires one of those before merge; please update the PR metadata.
<!-- ccr-overview-v2 -->
🟡 Changes recommended
Required controller-flow documentation and a tracking-ticket reference are missing.
<details open>
<summary><strong>2 open findings</strong></summary>
</details>
<details>
<summary><strong>1 resolved since last review</strong></summary>
</details>
<details>
<summary>Files not reviewed (2)</summary>
backend/pkg/azure/client/mock_features_client.go: Generated file
backend/pkg/azure/client/mock_fpa_client_builder.go: Generated file
</details>
🧠 Review effort: Balanced
Scheduling tests matching the pipeline_run_if_changed or not excluded by pipeline_skip_if_only_changed parameters:
/test e2e-parallel
/retest-required
Remaining retests: 0 against base HEAD 4a04076b8f4563d63b3f7b265c14c30b0890e732 and 2 for PR HEAD 814133ccb42b63d5c700439f9f596b28801d82cb in total
/retest-required
Remaining retests: 0 against base HEAD a509eebe04553eee0b2c11754a6c6387b4e633ad and 1 for PR HEAD 814133ccb42b63d5c700439f9f596b28801d82cb in total
/retest-required
Remaining retests: 0 against base HEAD 56e655b05d089072840185c67940ec3f670c8773 and 0 for PR HEAD 814133ccb42b63d5c700439f9f596b28801d82cb in total
/hold
Revision 814133ccb42b63d5c700439f9f596b28801d82cb was retested 3 times: holding
PR needs rebase.
<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.
</details>
@miguelsorianod: 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/e2e-parallel | 814133ccb42b63d5c700439f9f596b28801d82cb | link | true | /test e2e-parallel
ci/prow/podman-integration | 814133ccb42b63d5c700439f9f596b28801d82cb | link | true | /test podman-integration
ci/prow/podman-mega-linter | 814133ccb42b63d5c700439f9f596b28801d82cb | link | true | /test podman-mega-linter
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.
</details>
<!-- test report -->
machi1990
miguelsorianod
Node pools can request encryption at host, but nothing validates beforehand that the chosen VM size actually supports it or that the EncryptionAtHost feature is registered on the customer's subscription. Both are prerequisites for the setting to actually take effect in Azure.
Add AzureNodePoolEncryptionAtHostValidation, a node pool validation controller that checks the VM size's EncryptionAtHostSupported Resource SKU capability via the existing cached SKU reader, and separately checks the Microsoft.Compute/EncryptionAtHost feature registration state via a new Azure Features client added to the FPA client builder. Both checks run independently so a single failed validation reports every unmet prerequisite, not just the first one found.
Node pools that don't request encryption at host are skipped.
This validation is being performed on CS side through a CS inflight check so this implements it on this side. Once it's rolled out we should remove the validation on CS side.
<!-- Link to Jira issue -->
What
<!-- Briefly describe what this PR does -->
Why
<!-- Briefly explain why this change is needed -->
Testing
Testing is required for feature completion and tests should be part of the pull
request along with the feature changes.
Describe the testing provided. If you did not add tests, provide a clear
justification.
Special notes for your reviewer
<!-- optional -->
PR Checklist
If E2E tests are included:
demonstrate that the test is able to detect a defect/error and fail with
proper error message and logs which communicates nature of the problem.