Skip to content

feat: enable cloud-init write_files module for OSGuard images#7937

Merged
awesomenix merged 1 commit intomainfrom
nishp/no_sudo
Feb 26, 2026
Merged

feat: enable cloud-init write_files module for OSGuard images#7937
awesomenix merged 1 commit intomainfrom
nishp/no_sudo

Conversation

@awesomenix
Copy link
Contributor

Summary

Enable the write_files cloud-init module on OSGuard images so that custom data write_files entries are delivered during node provisioning.

Problem

OSGuard's 10-users-ssh-enable.cfg explicitly lists cloud_init_modules with only users_groups and ssh. This causes cloud-init to skip the write_files module entirely, preventing any files from the custom data write_files section from being written during provisioning.

Changes

  • 10-users-ssh-enable.cfg: Add write_files to cloud_init_modules list
  • baker.go: Add IsOSGuard template function (IsAzureLinuxOSGuardDistro() || CustomizedImageLinuxGuard) for guarding future /usr/ path entries
  • nodecustomdata.yml: Add block comment documenting that OSGuard has /usr/ read-only (dm-verity) and how to use IsOSGuard guard
  • baker_test.go: Add regression test asserting no write_files entries target /usr/ paths for OSGuard

Context

OSGuard uses dm-verity (UKI + reinitialize-verity) which makes /usr/ read-only. All current write_files entries target /opt/ or /etc/ (both writable), so enabling the module is safe. The IsOSGuard function and regression test prevent future regressions if someone adds a /usr/ path entry.

Testing

  • Unit tests pass
  • E2E validated with Test_AzureLinux3OSGuard

Copy link
Contributor

Copilot AI left a comment

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 enables the cloud-init write_files module for OSGuard images to support custom data file delivery during node provisioning. Previously, OSGuard's cloud-init configuration only enabled users_groups and ssh modules, preventing any write_files entries from being written. The change is safe because all current write_files entries target /opt/ or /etc/ paths (both writable on OSGuard), avoiding the read-only /usr/ partition protected by dm-verity.

Changes:

  • Enable write_files module in OSGuard cloud-init configuration
  • Add IsAzlOSGuard template function to guard OSGuard-specific logic
  • Add OSGuard-specific CSE helper and install script constants and variable mappings
  • Document /usr/ write restriction and add regression test to prevent future violations
  • Remove EnableScriptlessCSECmd = false overrides in OSGuard e2e tests (now works with default behavior)

Reviewed changes

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

Show a summary per file
File Description
parts/linux/cloud-init/artifacts/azlosguard/10-users-ssh-enable.cfg Adds write_files to the cloud_init_modules list to enable file delivery on OSGuard
pkg/agent/baker.go Adds IsAzlOSGuard template function to detect OSGuard distros (both official and customized images)
parts/linux/cloud-init/nodecustomdata.yml Adds OSGuard-specific distro script blocks and documents /usr/ read-only restriction with guard pattern
pkg/agent/baker_test.go Adds regression test ensuring no write_files entries target /usr/ paths for OSGuard
pkg/agent/const.go Adds OSGuard-specific CSE helper and install script file path constants
pkg/agent/variables.go Adds OSGuard-specific script variable mappings for template rendering
e2e/scenario_test.go Removes EnableScriptlessCSECmd = false overrides and fixes whitespace alignment

@awesomenix awesomenix requested a review from YaoC as a code owner February 25, 2026 06:48
Copilot AI review requested due to automatic review settings February 25, 2026 16:50
Copy link
Contributor

Copilot AI left a comment

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 8 out of 8 changed files in this pull request and generated 2 comments.

Comment on lines 4 to 7
cloud_init_modules:
- write_files
- users_groups
- ssh
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

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

Enabling the write_files module at the OS image level is a behavioral change for all customData versions. Older AgentBaker customData templates treated OSGuard as IsMariner and would write Mariner distro scripts + package/snapshot update units into write_files; with /usr read-only on OSGuard, that older customData could now overwrite the baked OSGuard-safe scripts and/or enable update flows that aren’t OSGuard-compatible. Please confirm backward compatibility with older customData (6‑month VHD window), or add an image-side mitigation (e.g., prevent overwriting OSGuard distro scripts / disable update units when OSGuard is detected).

Copilot generated this review using guidance from repository custom instructions.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this behaviour change is only with new OSGuard VHD, which means they also get new CSE + CustomData, i wouldnt worry about this scenario

Comment on lines +1531 to +1541
Entry("CustomizedImageLinuxGuard write_files should not target /usr/ paths", "CustomizedImageLinuxGuard", "1.24.2",
func(c *datamodel.NodeBootstrappingConfiguration) {
c.ContainerService.Properties.AgentPoolProfiles[0].KubernetesConfig = &datamodel.KubernetesConfig{
ContainerRuntime: datamodel.Containerd,
}
c.ContainerService.Properties.AgentPoolProfiles[0].Distro = datamodel.CustomizedImageLinuxGuard
}, func(o *nodeBootstrappingOutput) {
for path := range o.files {
Expect(path).NotTo(HavePrefix("/usr/"), "OSGuard has /usr/ read-only (dm-verity), write_files must not target /usr/ paths: %s", path)
}
},
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

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

This regression test only covers CustomizedImageLinuxGuard, but IsAzlOSGuard also returns true for the actual OSGuard VHD distro(s) via IsAzureLinuxOSGuardDistro(). Consider adding a second table entry for an OSGuard SIG distro (e.g., AKSAzureLinuxV3OSGuardGen2FIPSTL) so template changes can’t accidentally reintroduce /usr write_files paths for non-custom images. Also, if the intent is “no writes to /usr at all”, you may want to fail on path == "/usr" in addition to HavePrefix("/usr/").

Copilot generated this review using guidance from repository custom instructions.
   Enable the write_files cloud-init module in OSGuard 10-users-ssh-enable.cfg
   so that custom data write_files entries are delivered during provisioning.
   Add IsOSGuard template function to guard future /usr/ path entries, since
   OSGuard has /usr/ mounted read-only via dm-verity. Add regression test
   ensuring no write_files entries target /usr/ paths for OSGuard.
Copy link
Contributor

Copilot AI left a comment

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 8 out of 8 changed files in this pull request and generated no new comments.

@awesomenix awesomenix merged commit 4adc93f into main Feb 26, 2026
33 of 35 checks passed
@awesomenix awesomenix deleted the nishp/no_sudo branch February 26, 2026 18:44
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