@@ -18,6 +18,7 @@ import (
1818 "testing"
1919 "time"
2020
21+ aksnodeconfigv1 "github.com/Azure/agentbaker/aks-node-controller/pkg/gen/aksnodeconfig/v1"
2122 "github.com/Azure/agentbaker/aks-node-controller/pkg/nodeconfigutils"
2223 "github.com/Azure/agentbaker/e2e/config"
2324 "github.com/Azure/agentbaker/e2e/toolkit"
@@ -144,26 +145,55 @@ coreos:
144145 return base64 .StdEncoding .EncodeToString ([]byte (customDataYAML )), nil
145146}
146147
148+ // CustomDataWithDirectProvision writes the aks-node-controller config to a test-only path and
149+ // runs provisioning directly from cloud-init runcmd, avoiding the VMSS Custom Script Extension.
150+ func CustomDataWithDirectProvision (cfg * aksnodeconfigv1.Configuration ) (string , error ) {
151+ cloudConfigTemplate := `#cloud-config
152+ write_files:
153+ - path: /opt/azure/containers/aks-node-controller-config-runcmd.json
154+ permissions: "0755"
155+ owner: root
156+ content: !!binary |
157+ %s
158+ runcmd:
159+ - /opt/azure/containers/aks-node-controller provision --provision-config=/opt/azure/containers/aks-node-controller-config-runcmd.json
160+ `
161+
162+ aksNodeConfigJSON , err := nodeconfigutils .MarshalConfigurationV1 (cfg )
163+ if err != nil {
164+ return "" , fmt .Errorf ("failed to marshal nbc, error: %w" , err )
165+ }
166+ encodedAksNodeConfigJSON := base64 .StdEncoding .EncodeToString (aksNodeConfigJSON )
167+ customDataYAML := fmt .Sprintf (cloudConfigTemplate , encodedAksNodeConfigJSON )
168+ return base64 .StdEncoding .EncodeToString ([]byte (customDataYAML )), nil
169+ }
170+
147171func createVMSSModel (ctx context.Context , s * Scenario ) armcompute.VirtualMachineScaleSet {
148172 cluster := s .Runtime .Cluster
149173 var nodeBootstrapping * datamodel.NodeBootstrapping
150174 ab , err := agent .NewAgentBaker ()
151175 require .NoError (s .T , err )
152176 var cse , customData string
153177 if s .Runtime .AKSNodeConfig != nil {
154- cse = nodeconfigutils .CSE
155- customData = func () string {
156- if config .Config .DisableScriptLessCompilation {
157- data , err := nodeconfigutils .CustomData (s .Runtime .AKSNodeConfig )
158- require .NoError (s .T , err , "failed to generate custom data from AKSNodeConfig" )
178+ if s .Config .UseCustomDataOnlyProvisioning {
179+ data , err := CustomDataWithDirectProvision (s .Runtime .AKSNodeConfig )
180+ require .NoError (s .T , err , "failed to generate custom data from AKSNodeConfig with direct provision" )
181+ customData = data
182+ } else {
183+ cse = nodeconfigutils .CSE
184+ customData = func () string {
185+ if config .Config .DisableScriptLessCompilation {
186+ data , err := nodeconfigutils .CustomData (s .Runtime .AKSNodeConfig )
187+ require .NoError (s .T , err , "failed to generate custom data from AKSNodeConfig" )
188+ return data
189+ }
190+ binaryURL , err := CachedCompileAndUploadAKSNodeController (ctx , s .VHD .Arch )
191+ require .NoError (s .T , err , "failed to compile and upload aks-node-controller binary" )
192+ data , err := CustomDataWithHack (s , binaryURL )
193+ require .NoError (s .T , err , "failed to generate custom data from AKSNodeConfig with hack" )
159194 return data
160- }
161- binaryURL , err := CachedCompileAndUploadAKSNodeController (ctx , s .VHD .Arch )
162- require .NoError (s .T , err , "failed to compile and upload aks-node-controller binary" )
163- data , err := CustomDataWithHack (s , binaryURL )
164- require .NoError (s .T , err , "failed to generate custom data from AKSNodeConfig with hack" )
165- return data
166- }()
195+ }()
196+ }
167197
168198 } else {
169199 nodeBootstrapping , err = ab .GetNodeBootstrapping (ctx , s .Runtime .NBC )
0 commit comments