Skip to content

Commit 5d7fc8d

Browse files
feat: add OSSKU-based IsCgroupV2 detection and CustomizedImageTrustedLaunch distro (#8252)
Signed-off-by: Aadhar Agarwal <aadagarwal@microsoft.com>
1 parent ccb3417 commit 5d7fc8d

5 files changed

Lines changed: 76 additions & 8 deletions

File tree

pkg/agent/baker.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,8 @@ func getContainerServiceFuncMap(config *datamodel.NodeBootstrappingConfiguration
639639
return config.GetOrderedKubeproxyConfigStringForPowershell()
640640
},
641641
"IsCgroupV2": func() bool {
642-
return profile.Is2204VHDDistro() || profile.IsAzureLinuxCgroupV2VHDDistro() || profile.Is2404VHDDistro() || profile.IsFlatcar() || profile.IsACL()
642+
return profile.Is2204VHDDistro() || profile.Is2404VHDDistro() ||
643+
config.IsAzureLinux() || config.IsFlatcar() || config.IsACL()
643644
},
644645
"GetKubeProxyFeatureGatesPsh": func() string {
645646
return cs.Properties.GetKubeProxyFeatureGatesWindowsArguments()
@@ -735,7 +736,8 @@ func getContainerServiceFuncMap(config *datamodel.NodeBootstrappingConfiguration
735736
"IsCustomImage": func() bool {
736737
return profile.Distro == datamodel.CustomizedImage ||
737738
profile.Distro == datamodel.CustomizedImageKata ||
738-
profile.Distro == datamodel.CustomizedImageLinuxGuard
739+
profile.Distro == datamodel.CustomizedImageLinuxGuard ||
740+
profile.Distro == datamodel.CustomizedImageTrustedLaunch
739741
},
740742
"EnableHostsConfigAgent": func() bool {
741743
return cs.Properties.OrchestratorProfile.KubernetesConfig != nil &&

pkg/agent/baker_test.go

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,6 +1154,57 @@ var _ = Describe("getLinuxNodeCSECommand", func() {
11541154
Expect(vars).To(HaveKeyWithValue("NEEDS_CGROUPV2", "true"))
11551155
})
11561156

1157+
It("should set NEEDS_CGROUPV2 for CustomizedImage with AzureLinux OSSKU", func() {
1158+
config, err := deepcopy.Anything(baseConfig)
1159+
Expect(err).To(BeNil())
1160+
typedConfig, ok := config.(*datamodel.NodeBootstrappingConfiguration)
1161+
Expect(ok).To(BeTrue())
1162+
typedConfig.AgentPoolProfile.Distro = datamodel.CustomizedImage
1163+
typedConfig.OSSKU = datamodel.OSSKUAzureLinux
1164+
1165+
cseCmd := templateGenerator.getLinuxNodeCSECommand(typedConfig)
1166+
1167+
Expect(cseCmd).NotTo(BeEmpty())
1168+
Expect(strings.Contains(cseCmd, "\n")).To(BeFalse())
1169+
1170+
vars := decodeCSEVars(cseCmd)
1171+
Expect(vars).To(HaveKeyWithValue("NEEDS_CGROUPV2", "true"))
1172+
})
1173+
1174+
It("should set NEEDS_CGROUPV2 for CustomizedImage with Flatcar OSSKU", func() {
1175+
config, err := deepcopy.Anything(baseConfig)
1176+
Expect(err).To(BeNil())
1177+
typedConfig, ok := config.(*datamodel.NodeBootstrappingConfiguration)
1178+
Expect(ok).To(BeTrue())
1179+
typedConfig.AgentPoolProfile.Distro = datamodel.CustomizedImage
1180+
typedConfig.OSSKU = datamodel.OSSKUFlatcar
1181+
1182+
cseCmd := templateGenerator.getLinuxNodeCSECommand(typedConfig)
1183+
1184+
Expect(cseCmd).NotTo(BeEmpty())
1185+
Expect(strings.Contains(cseCmd, "\n")).To(BeFalse())
1186+
1187+
vars := decodeCSEVars(cseCmd)
1188+
Expect(vars).To(HaveKeyWithValue("NEEDS_CGROUPV2", "true"))
1189+
})
1190+
1191+
It("should set NEEDS_CGROUPV2 for CustomizedImageTrustedLaunch with AzureContainerLinux OSSKU", func() {
1192+
config, err := deepcopy.Anything(baseConfig)
1193+
Expect(err).To(BeNil())
1194+
typedConfig, ok := config.(*datamodel.NodeBootstrappingConfiguration)
1195+
Expect(ok).To(BeTrue())
1196+
typedConfig.AgentPoolProfile.Distro = datamodel.CustomizedImageTrustedLaunch
1197+
typedConfig.OSSKU = datamodel.OSSKUAzureContainerLinux
1198+
1199+
cseCmd := templateGenerator.getLinuxNodeCSECommand(typedConfig)
1200+
1201+
Expect(cseCmd).NotTo(BeEmpty())
1202+
Expect(strings.Contains(cseCmd, "\n")).To(BeFalse())
1203+
1204+
vars := decodeCSEVars(cseCmd)
1205+
Expect(vars).To(HaveKeyWithValue("NEEDS_CGROUPV2", "true"))
1206+
})
1207+
11571208
It("should panic when template processing fails", func() {
11581209
// Create invalid config that will cause template processing to fail
11591210
invalidConfig := &datamodel.NodeBootstrappingConfiguration{

pkg/agent/bakerapi.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ func (agentBaker *agentBakerImpl) GetNodeBootstrapping(ctx context.Context, conf
5353
if distro == datamodel.CustomizedWindowsOSImage ||
5454
distro == datamodel.CustomizedImage ||
5555
distro == datamodel.CustomizedImageKata ||
56-
distro == datamodel.CustomizedImageLinuxGuard {
56+
distro == datamodel.CustomizedImageLinuxGuard ||
57+
distro == datamodel.CustomizedImageTrustedLaunch {
5758
return nodeBootstrapping, nil
5859
}
5960

pkg/agent/bakerapi_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,15 @@ var _ = Describe("AgentBaker API implementation tests", func() {
254254
Expect(err).NotTo(HaveOccurred())
255255
})
256256

257+
It("should not return an error for customized trusted launch image", func() {
258+
config.AgentPoolProfile.Distro = datamodel.CustomizedImageTrustedLaunch
259+
agentBaker, err := NewAgentBaker()
260+
Expect(err).NotTo(HaveOccurred())
261+
262+
_, err = agentBaker.GetNodeBootstrapping(context.Background(), config)
263+
Expect(err).NotTo(HaveOccurred())
264+
})
265+
257266
It("should not return an error for customized windows image", func() {
258267
config.AgentPoolProfile.Distro = datamodel.CustomizedWindowsOSImage
259268
agentBaker, err := NewAgentBaker()

pkg/agent/datamodel/types.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -213,11 +213,12 @@ const (
213213
// AKSWindows2025Gen2 stands for distro for windows server 2025 Gen 2 SIG image.
214214
AKSWindows2025Gen2 Distro = "aks-windows-2025-gen2"
215215
// AKSWindows2019PIR stands for distro of windows server 2019 PIR image with docker.
216-
AKSWindows2019PIR Distro = "aks-windows-2019-pir"
217-
CustomizedImage Distro = "CustomizedImage"
218-
CustomizedImageKata Distro = "CustomizedImageKata"
219-
CustomizedImageLinuxGuard Distro = "CustomizedImageLinuxGuard"
220-
CustomizedWindowsOSImage Distro = "CustomizedWindowsOSImage"
216+
AKSWindows2019PIR Distro = "aks-windows-2019-pir"
217+
CustomizedImage Distro = "CustomizedImage"
218+
CustomizedImageKata Distro = "CustomizedImageKata"
219+
CustomizedImageLinuxGuard Distro = "CustomizedImageLinuxGuard"
220+
CustomizedImageTrustedLaunch Distro = "CustomizedImageTrustedLaunch"
221+
CustomizedWindowsOSImage Distro = "CustomizedWindowsOSImage"
221222

222223
// USNatCloud is a const string reference identifier for USNat.
223224
USNatCloud = "USNatCloud"
@@ -1798,6 +1799,10 @@ type NodeBootstrappingConfiguration struct {
17981799
EnableScriptlessCSECmd bool
17991800
}
18001801

1802+
func (config *NodeBootstrappingConfiguration) IsAzureLinux() bool {
1803+
return config.OSSKU == OSSKUAzureLinux || config.AgentPoolProfile.IsAzureLinuxCgroupV2VHDDistro()
1804+
}
1805+
18011806
func (config *NodeBootstrappingConfiguration) IsFlatcar() bool {
18021807
return config.OSSKU == OSSKUFlatcar || config.AgentPoolProfile.IsFlatcar()
18031808
}

0 commit comments

Comments
 (0)