fix: write per-cluster files during node prep - #9225
Conversation
Windows Unit Test Results 3 files 13 suites 42s ⏱️ Results for commit 5bad43e. ♻️ This comment has been updated with latest results. |
There was a problem hiding this comment.
Pull request overview
This PR addresses a PIS (pre-provisioned image) correctness and security issue where nodes that skip basePrep could retain the image-build cluster’s azure.json and ca.crt. It moves the Linux writers (configureAzureJson, ensureKubeCACert) to the start of nodePrep so they are always written from live provisioning CustomData before cluster-join steps, and adds tests to pin the intended phase placement/order.
Changes:
- Move
configureAzureJsonandensureKubeCACertfrom LinuxbasePrepto the start ofnodePrepincse_main.sh. - Add a Linux ShellSpec test to enforce NodePrep-only placement and ordering relative to consumers.
- Add a Windows Pester test that asserts NodePrep-only placement for cluster identity/credential writes (Windows behavior unchanged).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
parts/linux/cloud-init/artifacts/cse_main.sh |
Moves per-cluster file writers (azure.json, ca.crt) into nodePrep to be PIS-safe. |
spec/parts/linux/cloud-init/artifacts/cse_main_pis_reconcile_spec.sh |
Adds ShellSpec assertions ensuring per-cluster writers run only in nodePrep and early enough for consumers. |
parts/windows/kuberneteswindowssetup.pisphases.tests.ps1 |
Adds Pester assertions that Windows cluster identity/credential writes remain NodePrep-only. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
PIS nodes skip basePrep, so files written there can retain another cluster's identity, network resources, credentials, and trust anchor. Write azure.json and ca.crt from live CustomData at the start of nodePrep instead of capturing them in the image. Add focused Linux phase-ordering coverage and Windows regression guards for the existing NodePrep-only behavior. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 56eb78a3-cefa-4bb6-bfed-f2446080b8e1
The previous helper anchored on descriptive comment text and returned no lines when that wording differed. Start at the base_prep.complete gate so the test follows the dispatch code it validates. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 56eb78a3-cefa-4bb6-bfed-f2446080b8e1
a68e087 to
5bad43e
Compare
What this PR does / why we need it:
PIS nodes skip
basePrepbecause the cached VHD already contains thebase_prep.completemarker.azure.jsonandca.crtwere written only inbasePrep, so cached nodes could retain the image-build cluster's identity, network resources, credentials, and trust anchor.This moves
configureAzureJsonandensureKubeCACertto the start ofnodePrep, where they are written once from live provisioning CustomData before secure TLS bootstrap, the API-server check, credential-provider configuration, and kubelet startup. The files and service-principal secret are no longer captured in new PIS images.Linux ShellSpec coverage pins the NodePrep-only placement and consumer ordering. Windows behavior is unchanged; Pester guards verify that its cloud-provider, credential, CA, and CNI configuration remains NodePrep-only.
Which issue(s) this PR fixes:
N/A