Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion e2e/vmss.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ func createVMSSModel(ctx context.Context, s *Scenario) armcompute.VirtualMachine
require.NoError(s.T, err)
cse = nodeBootstrapping.CSE
customData = nodeBootstrapping.CustomData
if s.Runtime.NBC.EnableScriptlessNBCCSECmd && !config.Config.DisableScriptLessCompilation && !s.Tags.NetworkIsolated {
if s.Runtime.NBC.EnableScriptlessNBCCSECmd && !config.Config.DisableScriptLessCompilation && !s.Tags.NetworkIsolated && !s.Runtime.NBC.PreProvisionOnly {
binaryURL, err := CachedCompileAndUploadAKSNodeController(ctx, s.VHD.Arch)
require.NoError(s.T, err, "failed to compile and upload aks-node-controller binary")
customData, err = CustomDataWithNBCCmdHack(s, customData, binaryURL)
Expand Down
4 changes: 2 additions & 2 deletions pkg/agent/baker.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (t *TemplateGenerator) getWindowsNodeBootstrappingPayload(config *datamodel
}

func (t *TemplateGenerator) getLinuxNodeBootstrappingPayload(config *datamodel.NodeBootstrappingConfiguration) string {
if config.EnableScriptlessNBCCSECmd {
if config.EnableScriptlessNBCCSECmd && !config.PreProvisionOnly {
Comment thread
awesomenix marked this conversation as resolved.
config.DisableCustomData = true
Comment thread
awesomenix marked this conversation as resolved.
config.EnableScriptlessCSECmd = true
nbcCMD := t.getLinuxNodeCSECommand(config)
Expand Down Expand Up @@ -352,7 +352,7 @@ func (t *TemplateGenerator) getNodeBootstrappingCmd(config *datamodel.NodeBootst
if config.AgentPoolProfile.IsWindows() {
return t.getWindowsNodeCSECommand(config)
}
if config.EnableScriptlessNBCCSECmd {
if config.EnableScriptlessNBCCSECmd && !config.PreProvisionOnly {
return "/opt/azure/containers/aks-node-controller provision-wait"
}
return t.getLinuxNodeCSECommand(config)
Expand Down
68 changes: 65 additions & 3 deletions pkg/agent/baker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1286,14 +1286,14 @@ var _ = Describe("getLinuxNodeCSECommand", func() {
})

var _ = Describe("getLinuxNodeBootstrappingPayload", func() {
It("should persist nodecustomdata in the scriptless NBC boothook", func() {
templateGenerator := InitializeTemplateGenerator()
newConfig := func(preProvisionOnly bool) *datamodel.NodeBootstrappingConfiguration {
agentPoolProfile := &datamodel.AgentPoolProfile{
Name: "nodepool1",
OSType: datamodel.Linux,
Distro: datamodel.AKSUbuntuContainerd2204Gen2,
}
config := &datamodel.NodeBootstrappingConfiguration{

return &datamodel.NodeBootstrappingConfiguration{
ContainerService: &datamodel.ContainerService{
Location: "eastus",
Properties: &datamodel.Properties{
Expand All @@ -1315,7 +1315,13 @@ var _ = Describe("getLinuxNodeBootstrappingPayload", func() {
K8sComponents: &datamodel.K8sComponents{},
KubeletConfig: map[string]string{},
EnableScriptlessNBCCSECmd: true,
PreProvisionOnly: preProvisionOnly,
}
}

It("should persist nodecustomdata in the scriptless NBC boothook", func() {
templateGenerator := InitializeTemplateGenerator()
config := newConfig(false)

payload := templateGenerator.getLinuxNodeBootstrappingPayload(config)
decodedPayload, err := base64.StdEncoding.DecodeString(payload)
Expand All @@ -1330,6 +1336,62 @@ var _ = Describe("getLinuxNodeBootstrappingPayload", func() {
Expect(string(decodedPayload)).To(ContainSubstring(encodedNodeCustomData))
Expect(string(decodedPayload)).To(ContainSubstring(nbcCmdFilePath))
})

It("should fall back to regular custom data when pre-provisioning is enabled", func() {
templateGenerator := InitializeTemplateGenerator()
config := newConfig(true)

payload := templateGenerator.getLinuxNodeBootstrappingPayload(config)
decodedPayload, err := base64.StdEncoding.DecodeString(payload)
Expect(err).NotTo(HaveOccurred())

decompressedPayload, err := getGzipDecodedValue(decodedPayload)
Expect(err).NotTo(HaveOccurred())

expectedCustomData := getCustomDataFromJSON(templateGenerator.getLinuxNodeCustomDataJSONObject(config))

Expect(string(decompressedPayload)).To(Equal(expectedCustomData))
Expect(string(decompressedPayload)).NotTo(ContainSubstring(nodeCustomDataPath))
Expect(string(decompressedPayload)).NotTo(ContainSubstring(nbcCmdFilePath))
})
})

var _ = Describe("getNodeBootstrappingCmd", func() {
It("should use the regular linux CSE command when pre-provisioning is enabled", func() {
templateGenerator := InitializeTemplateGenerator()
agentPoolProfile := &datamodel.AgentPoolProfile{
Name: "nodepool1",
OSType: datamodel.Linux,
Distro: datamodel.AKSUbuntuContainerd2204Gen2,
}
config := &datamodel.NodeBootstrappingConfiguration{
ContainerService: &datamodel.ContainerService{
Location: "eastus",
Properties: &datamodel.Properties{
OrchestratorProfile: &datamodel.OrchestratorProfile{
OrchestratorVersion: "1.29.0",
OrchestratorType: datamodel.Kubernetes,
KubernetesConfig: &datamodel.KubernetesConfig{
ContainerRuntimeConfig: map[string]string{},
},
},
HostedMasterProfile: &datamodel.HostedMasterProfile{
FQDN: "test-cluster.hcp.eastus.azmk8s.io",
},
AgentPoolProfiles: []*datamodel.AgentPoolProfile{agentPoolProfile},
},
},
AgentPoolProfile: agentPoolProfile,
CloudSpecConfig: datamodel.AzurePublicCloudSpecForTest,
K8sComponents: &datamodel.K8sComponents{},
KubeletConfig: map[string]string{},
EnableScriptlessNBCCSECmd: true,
PreProvisionOnly: true,
}

Expect(templateGenerator.getNodeBootstrappingCmd(config)).To(Equal(templateGenerator.getLinuxNodeCSECommand(config)))
Expect(templateGenerator.getNodeBootstrappingCmd(config)).NotTo(Equal("/opt/azure/containers/aks-node-controller provision-wait"))
})
})

var _ = Describe("cloudInitToButane", func() {
Expand Down
Loading