Skip to content

Commit 8b20cff

Browse files
authored
fix: dont run scriptless phase2 if preprovision is turned on (#8440)
1 parent 04e9f38 commit 8b20cff

3 files changed

Lines changed: 68 additions & 6 deletions

File tree

e2e/vmss.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ func createVMSSModel(ctx context.Context, s *Scenario) armcompute.VirtualMachine
355355
require.NoError(s.T, err)
356356
cse = nodeBootstrapping.CSE
357357
customData = nodeBootstrapping.CustomData
358-
if s.Runtime.NBC.EnableScriptlessNBCCSECmd && !config.Config.DisableScriptLessCompilation && !s.Tags.NetworkIsolated {
358+
if s.Runtime.NBC.EnableScriptlessNBCCSECmd && !config.Config.DisableScriptLessCompilation && !s.Tags.NetworkIsolated && !s.Runtime.NBC.PreProvisionOnly {
359359
binaryURL, err := CachedCompileAndUploadAKSNodeController(ctx, s.VHD.Arch)
360360
require.NoError(s.T, err, "failed to compile and upload aks-node-controller binary")
361361
customData, err = CustomDataWithNBCCmdHack(s, customData, binaryURL)

pkg/agent/baker.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func (t *TemplateGenerator) getWindowsNodeBootstrappingPayload(config *datamodel
9292
}
9393

9494
func (t *TemplateGenerator) getLinuxNodeBootstrappingPayload(config *datamodel.NodeBootstrappingConfiguration) string {
95-
if config.EnableScriptlessNBCCSECmd {
95+
if config.EnableScriptlessNBCCSECmd && !config.PreProvisionOnly {
9696
config.DisableCustomData = true
9797
config.EnableScriptlessCSECmd = true
9898
nbcCMD := t.getLinuxNodeCSECommand(config)
@@ -352,7 +352,7 @@ func (t *TemplateGenerator) getNodeBootstrappingCmd(config *datamodel.NodeBootst
352352
if config.AgentPoolProfile.IsWindows() {
353353
return t.getWindowsNodeCSECommand(config)
354354
}
355-
if config.EnableScriptlessNBCCSECmd {
355+
if config.EnableScriptlessNBCCSECmd && !config.PreProvisionOnly {
356356
return "/opt/azure/containers/aks-node-controller provision-wait"
357357
}
358358
return t.getLinuxNodeCSECommand(config)

pkg/agent/baker_test.go

Lines changed: 65 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,14 +1286,14 @@ var _ = Describe("getLinuxNodeCSECommand", func() {
12861286
})
12871287

12881288
var _ = Describe("getLinuxNodeBootstrappingPayload", func() {
1289-
It("should persist nodecustomdata in the scriptless NBC boothook", func() {
1290-
templateGenerator := InitializeTemplateGenerator()
1289+
newConfig := func(preProvisionOnly bool) *datamodel.NodeBootstrappingConfiguration {
12911290
agentPoolProfile := &datamodel.AgentPoolProfile{
12921291
Name: "nodepool1",
12931292
OSType: datamodel.Linux,
12941293
Distro: datamodel.AKSUbuntuContainerd2204Gen2,
12951294
}
1296-
config := &datamodel.NodeBootstrappingConfiguration{
1295+
1296+
return &datamodel.NodeBootstrappingConfiguration{
12971297
ContainerService: &datamodel.ContainerService{
12981298
Location: "eastus",
12991299
Properties: &datamodel.Properties{
@@ -1315,7 +1315,13 @@ var _ = Describe("getLinuxNodeBootstrappingPayload", func() {
13151315
K8sComponents: &datamodel.K8sComponents{},
13161316
KubeletConfig: map[string]string{},
13171317
EnableScriptlessNBCCSECmd: true,
1318+
PreProvisionOnly: preProvisionOnly,
13181319
}
1320+
}
1321+
1322+
It("should persist nodecustomdata in the scriptless NBC boothook", func() {
1323+
templateGenerator := InitializeTemplateGenerator()
1324+
config := newConfig(false)
13191325

13201326
payload := templateGenerator.getLinuxNodeBootstrappingPayload(config)
13211327
decodedPayload, err := base64.StdEncoding.DecodeString(payload)
@@ -1330,6 +1336,62 @@ var _ = Describe("getLinuxNodeBootstrappingPayload", func() {
13301336
Expect(string(decodedPayload)).To(ContainSubstring(encodedNodeCustomData))
13311337
Expect(string(decodedPayload)).To(ContainSubstring(nbcCmdFilePath))
13321338
})
1339+
1340+
It("should fall back to regular custom data when pre-provisioning is enabled", func() {
1341+
templateGenerator := InitializeTemplateGenerator()
1342+
config := newConfig(true)
1343+
1344+
payload := templateGenerator.getLinuxNodeBootstrappingPayload(config)
1345+
decodedPayload, err := base64.StdEncoding.DecodeString(payload)
1346+
Expect(err).NotTo(HaveOccurred())
1347+
1348+
decompressedPayload, err := getGzipDecodedValue(decodedPayload)
1349+
Expect(err).NotTo(HaveOccurred())
1350+
1351+
expectedCustomData := getCustomDataFromJSON(templateGenerator.getLinuxNodeCustomDataJSONObject(config))
1352+
1353+
Expect(string(decompressedPayload)).To(Equal(expectedCustomData))
1354+
Expect(string(decompressedPayload)).NotTo(ContainSubstring(nodeCustomDataPath))
1355+
Expect(string(decompressedPayload)).NotTo(ContainSubstring(nbcCmdFilePath))
1356+
})
1357+
})
1358+
1359+
var _ = Describe("getNodeBootstrappingCmd", func() {
1360+
It("should use the regular linux CSE command when pre-provisioning is enabled", func() {
1361+
templateGenerator := InitializeTemplateGenerator()
1362+
agentPoolProfile := &datamodel.AgentPoolProfile{
1363+
Name: "nodepool1",
1364+
OSType: datamodel.Linux,
1365+
Distro: datamodel.AKSUbuntuContainerd2204Gen2,
1366+
}
1367+
config := &datamodel.NodeBootstrappingConfiguration{
1368+
ContainerService: &datamodel.ContainerService{
1369+
Location: "eastus",
1370+
Properties: &datamodel.Properties{
1371+
OrchestratorProfile: &datamodel.OrchestratorProfile{
1372+
OrchestratorVersion: "1.29.0",
1373+
OrchestratorType: datamodel.Kubernetes,
1374+
KubernetesConfig: &datamodel.KubernetesConfig{
1375+
ContainerRuntimeConfig: map[string]string{},
1376+
},
1377+
},
1378+
HostedMasterProfile: &datamodel.HostedMasterProfile{
1379+
FQDN: "test-cluster.hcp.eastus.azmk8s.io",
1380+
},
1381+
AgentPoolProfiles: []*datamodel.AgentPoolProfile{agentPoolProfile},
1382+
},
1383+
},
1384+
AgentPoolProfile: agentPoolProfile,
1385+
CloudSpecConfig: datamodel.AzurePublicCloudSpecForTest,
1386+
K8sComponents: &datamodel.K8sComponents{},
1387+
KubeletConfig: map[string]string{},
1388+
EnableScriptlessNBCCSECmd: true,
1389+
PreProvisionOnly: true,
1390+
}
1391+
1392+
Expect(templateGenerator.getNodeBootstrappingCmd(config)).To(Equal(templateGenerator.getLinuxNodeCSECommand(config)))
1393+
Expect(templateGenerator.getNodeBootstrappingCmd(config)).NotTo(Equal("/opt/azure/containers/aks-node-controller provision-wait"))
1394+
})
13331395
})
13341396

13351397
var _ = Describe("cloudInitToButane", func() {

0 commit comments

Comments
 (0)