Skip to content

fix: write per-cluster files during node prep - #9225

Merged
r2k1 merged 2 commits into
mainfrom
r2k1-pis-runtime-reconcile
Aug 19, 2026
Merged

fix: write per-cluster files during node prep#9225
r2k1 merged 2 commits into
mainfrom
r2k1-pis-runtime-reconcile

Conversation

@r2k1

@r2k1 r2k1 commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

PIS nodes skip basePrep because the cached VHD already contains the base_prep.complete marker. azure.json and ca.crt were written only in basePrep, so cached nodes could retain the image-build cluster's identity, network resources, credentials, and trust anchor.

This moves configureAzureJson and ensureKubeCACert to the start of nodePrep, 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

@github-actions

github-actions Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Windows Unit Test Results

  3 files   13 suites   42s ⏱️
404 tests 404 ✅ 0 💤 0 ❌
407 runs  407 ✅ 0 💤 0 ❌

Results for commit 5bad43e.

♻️ This comment has been updated with latest results.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 configureAzureJson and ensureKubeCACert from Linux basePrep to the start of nodePrep in cse_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.

Copilot AI review requested due to automatic review settings August 17, 2026 03:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

r2k1 and others added 2 commits August 18, 2026 08:42
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
Copilot AI review requested due to automatic review settings August 17, 2026 20:43
@r2k1
r2k1 force-pushed the r2k1-pis-runtime-reconcile branch from a68e087 to 5bad43e Compare August 17, 2026 20:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

@r2k1
r2k1 enabled auto-merge (squash) August 17, 2026 21:07
@r2k1
r2k1 requested a review from janenotjung-hue August 17, 2026 21:19
@r2k1
r2k1 disabled auto-merge August 18, 2026 22:44
@r2k1
r2k1 merged commit 8273f04 into main Aug 19, 2026
49 checks passed
@r2k1
r2k1 deleted the r2k1-pis-runtime-reconcile branch August 19, 2026 08:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants