Skip to content

Commit

Permalink
bug: reduce windows bootstrap command size (#5672)
Browse files Browse the repository at this point in the history
  • Loading branch information
timmy-wright authored Feb 2, 2025
1 parent 5224f98 commit b95d1c7
Show file tree
Hide file tree
Showing 39 changed files with 1,087 additions and 600 deletions.
2 changes: 1 addition & 1 deletion e2e/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func execScriptOnVm(ctx context.Context, s *Scenario, vmPrivateIP, jumpboxPodNam

joinedSteps := strings.Join(steps, " && ")

s.T.Log(fmt.Sprintf("Executing script %s:\n---START-SCRIPT---\n%s\n---END-SCRIPT---\n", scriptFileName, script))
s.T.Log(fmt.Sprintf("Executing script %[1]s using %[2]s:\n---START-SCRIPT---\n%[3]s\n---END-SCRIPT---\n", scriptFileName, interpreter, script.script))

kube := s.Runtime.Cluster.Kube
execResult, err := execOnPrivilegedPod(ctx, kube, defaultNamespace, jumpboxPodName, joinedSteps)
Expand Down
7 changes: 6 additions & 1 deletion e2e/node_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ import (
)

func getBaseNBC(t *testing.T, cluster *Cluster, vhd *config.Image) *datamodel.NodeBootstrappingConfiguration {
nbc := baseTemplateLinux(t, config.Config.Location, *cluster.Model.Properties.CurrentKubernetesVersion, vhd.Arch)
var nbc *datamodel.NodeBootstrappingConfiguration

if vhd.Distro.IsWindowsDistro() {
nbc = baseTemplateWindows(t, config.Config.Location)
cert := cluster.Kube.clientCertificate()
Expand All @@ -35,7 +36,10 @@ func getBaseNBC(t *testing.T, cluster *Cluster, vhd *config.Image) *datamodel.No
nbc.SubscriptionID = config.Config.SubscriptionID
nbc.ResourceGroupName = *cluster.Model.Properties.NodeResourceGroup
nbc.TenantID = *cluster.Model.Identity.TenantID
} else {
nbc = baseTemplateLinux(t, config.Config.Location, *cluster.Model.Properties.CurrentKubernetesVersion, vhd.Arch)
}

nbc.ContainerService.Properties.CertificateProfile.CaCertificate = string(cluster.ClusterParams.CACert)

nbc.KubeletClientTLSBootstrapToken = &cluster.ClusterParams.BootstrapToken
Expand Down Expand Up @@ -464,6 +468,7 @@ func baseTemplateWindows(t *testing.T, location string) *datamodel.NodeBootstrap
ResourceGroupName: "resourcegroup",

ContainerService: &datamodel.ContainerService{
Location: location,
Properties: &datamodel.Properties{
HostedMasterProfile: &datamodel.HostedMasterProfile{},
CertificateProfile: &datamodel.CertificateProfile{},
Expand Down
3 changes: 2 additions & 1 deletion e2e/vmss.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ func createVMSS(ctx context.Context, s *Scenario) *armcompute.VirtualMachineScal
})

vmssResp, err := operation.PollUntilDone(ctx, config.DefaultPollUntilDoneOptions)

// fail test, but continue to extract debug information
require.NoError(s.T, err, "create vmss %q, check %s for vm logs", s.Runtime.VMSSName, testDir(s.T))
return &vmssResp.VirtualMachineScaleSet
Expand Down Expand Up @@ -196,7 +197,7 @@ func extractLogsFromVMWindows(ctx context.Context, s *Scenario) {
client := config.Azure.VMSSVMRunCommands

// Invoke the RunCommand on the VMSS instance
s.T.Log("uploading windows logs to blob storage, may take a few minutes")
s.T.Logf("uploading windows logs to blob storage at %s, may take a few minutes", blobUrl)

pollerResp, err := client.BeginCreateOrUpdate(
ctx,
Expand Down
19 changes: 6 additions & 13 deletions parts/windows/csecmd.ps1
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
powershell.exe -ExecutionPolicy Unrestricted -command \"
$inputFile = '%SYSTEMDRIVE%\AzureData\CustomData.bin';
$outputFile = '%SYSTEMDRIVE%\AzureData\CustomDataSetupScript.ps1';
if (!(Test-Path $inputFile)) { throw 'ExitCode: |49|, Output: |WINDOWS_CSE_ERROR_NO_CUSTOM_DATA_BIN|, Error: |C:\AzureData\CustomData.bin does not exist.|' };
if (!(Test-Path $inputFile)) { throw 'ExitCode: |49|, Output: |WINDOWS_CSE_ERROR_NO_CUSTOM_DATA_BIN|, Error: |$inputFile does not exist.|' };
Copy-Item $inputFile $outputFile -Force;
PowerShell -File $outputFile
-MasterIP ''{{ GetKubernetesEndpoint }}''
-KubeDnsServiceIp ''{{ GetParameter "kubeDNSServiceIP" }}''
-MasterFQDNPrefix ''{{ GetParameter "masterEndpointDNSNamePrefix" }}''
-Location ''{{ GetVariable "location" }}''
{{if UserAssignedIDEnabled}}
-UserAssignedClientID ''{{ GetVariable "userAssignedIdentityID" }}''
{{ end }}
-TargetEnvironment ''{{ GetTargetEnvironment }}''
PowerShell
-File $outputFile
-AgentKey ''{{ GetParameter "clientPrivateKey" }}''
-AADClientId ''{{ GetParameter "servicePrincipalClientId" }}''
-AADClientSecret ''{{ GetParameter "encodedServicePrincipalClientSecret" }}''
-NetworkAPIVersion 2018-08-01
-CSEResultFilePath %SYSTEMDRIVE%\AzureData\provision.complete >> %SYSTEMDRIVE%\AzureData\CustomDataSetupScript.log 2>&1;
if (!(Test-Path %SYSTEMDRIVE%\AzureData\provision.complete)) { throw 'ExitCode: |50|, Output: |WINDOWS_CSE_ERROR_NO_CSE_RESULT_LOG|, Error: |C:\AzureData\provision.complete is not generated.|'; }; $result=(Get-Content %SYSTEMDRIVE%\AzureData\provision.complete); if($result -ne '0') { throw $result; };
if (!(Test-Path %SYSTEMDRIVE%\AzureData\provision.complete)) { throw 'ExitCode: |50|, Output: |WINDOWS_CSE_ERROR_NO_CSE_RESULT_LOG|, Error: |C:\AzureData\provision.complete is not generated.|'; };
$result=(Get-Content %SYSTEMDRIVE%\AzureData\provision.complete);
if ($result -ne '0') { throw $result; };
\"
49 changes: 17 additions & 32 deletions parts/windows/kuberneteswindowssetup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,53 +19,38 @@
#>
[CmdletBinding(DefaultParameterSetName="Standard")]
param(
[string]
[ValidateNotNullOrEmpty()]
$MasterIP,

[parameter()]
[ValidateNotNullOrEmpty()]
$KubeDnsServiceIp,

[parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
$MasterFQDNPrefix,

[parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
$Location,

[parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
$AgentKey,

[parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
$AADClientId,

[parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
$AADClientSecret, # base64

[parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
$NetworkAPIVersion,

[parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
$TargetEnvironment,

# C:\AzureData\provision.complete
# MUST keep generating this file when CSE is done and do not change the name
# - It is used to avoid running CSE multiple times
# - Some customers use this file to check if CSE is done
[parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
$CSEResultFilePath,

[string]
$UserAssignedClientID
$CSEResultFilePath
)

# In an ideal world, all these values would be passed to this script in parameters. However, we don't live in an ideal world.
# https://learn.microsoft.com/en-gb/troubleshoot/windows-client/shell-experience/command-line-string-limitation

$MasterIP = "{{ GetKubernetesEndpoint }}"
$KubeDnsServiceIp="{{ GetParameter "kubeDNSServiceIP" }}"
$MasterFQDNPrefix="{{ GetParameter "masterEndpointDNSNamePrefix" }}"
$Location="{{ GetVariable "location" }}"
{{if UserAssignedIDEnabled}}
$UserAssignedClientID="{{ GetVariable "userAssignedIdentityID" }}"
{{ end }}
$TargetEnvironment="{{ GetTargetEnvironment }}"
$AgentKey="{{ GetParameter "clientPrivateKey" }}"
$AADClientId="{{ GetParameter "servicePrincipalClientId" }}"
$NetworkAPIVersion="2018-08-01"

# Do not parse the start time from $LogFile to simplify the logic
$StartTime=Get-Date
$global:ExitCode=0
Expand Down
24 changes: 15 additions & 9 deletions pkg/agent/baker.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,24 @@ func InitializeTemplateGenerator() *TemplateGenerator {
// GetNodeBootstrappingPayload get node bootstrapping data.
// This function only can be called after the validation of the input NodeBootstrappingConfiguration.
func (t *TemplateGenerator) getNodeBootstrappingPayload(config *datamodel.NodeBootstrappingConfiguration) string {
var customData string
if config.AgentPoolProfile.IsWindows() {
customData = getCustomDataFromJSON(t.getWindowsNodeCustomDataJSONObject(config))
} else {
customData = getCustomDataFromJSON(t.getLinuxNodeCustomDataJSONObject(config))
return t.getWindowsNodeBootstrappingPayload(config)
}

if config.AgentPoolProfile.IsWindows() {
return base64.StdEncoding.EncodeToString([]byte(customData))
}
return t.getLinuxNodeBootstrappingPayload(config)
}

func (t *TemplateGenerator) getWindowsNodeBootstrappingPayload(config *datamodel.NodeBootstrappingConfiguration) string {
// this might seem strange that we're encoding the custom data to a JSON string and then extracting it, but without that serialisation and deserialisation
// lots of tests fail.
customData := getCustomDataFromJSON(t.getWindowsNodeCustomDataJSONObject(config))
return base64.StdEncoding.EncodeToString([]byte(customData))
}

func (t *TemplateGenerator) getLinuxNodeBootstrappingPayload(config *datamodel.NodeBootstrappingConfiguration) string {
// this might seem strange that we're encoding the custom data to a JSON string and then extracting it, but without that serialisation and deserialisation
// lots of tests fail.
customData := getCustomDataFromJSON(t.getLinuxNodeCustomDataJSONObject(config))
return getBase64EncodedGzippedCustomScriptFromStr(customData)
}

Expand Down Expand Up @@ -76,7 +83,6 @@ func (t *TemplateGenerator) getWindowsNodeCustomDataJSONObject(config *datamodel
}

preprovisionCmd := ""

if profile.PreprovisionExtension != nil {
preprovisionCmd = makeAgentExtensionScriptCommands(cs, profile)
}
Expand Down Expand Up @@ -134,7 +140,7 @@ func (t *TemplateGenerator) getWindowsNodeCSECommand(config *datamodel.NodeBoots
if e != nil {
panic(e)
}
/* NOTE(qinahao): windows cse cmd uses esapced \" to quote Powershell command in
/* NOTE(qinahao): windows cse cmd uses escaped \" to quote Powershell command in
[csecmd.p1](https://github.com/Azure/AgentBaker/blob/master/parts/windows/csecmd.ps1). */
// to not break go template parsing. We switch \" back to " otherwise Azure ARM template will escape \ to be \\\"
str = strings.ReplaceAll(str, `\"`, `"`)
Expand Down
2 changes: 2 additions & 0 deletions pkg/agent/baker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1052,6 +1052,8 @@ var _ = Describe("Assert generated customData and cseCmd", func() {
}
},
func(o *nodeBootstrappingOutput) {
Expect(o).ShouldNot(BeNil())
Expect(o.files["/opt/azure/containers/provision.sh"]).ShouldNot(BeNil())
Expect(o.files["/opt/azure/containers/provision.sh"].encoding).To(Equal(cseVariableEncodingGzip))
cseMain := o.files["/opt/azure/containers/provision.sh"].value
httpProxyStr := "export http_proxy=\"http://myproxy.server.com:8080/\""
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
powershell.exe -ExecutionPolicy Unrestricted -command " $inputFile = '%SYSTEMDRIVE%\AzureData\CustomData.bin'; $outputFile = '%SYSTEMDRIVE%\AzureData\CustomDataSetupScript.ps1'; if (!(Test-Path $inputFile)) { throw 'ExitCode: |49|, Output: |WINDOWS_CSE_ERROR_NO_CUSTOM_DATA_BIN|, Error: |C:\AzureData\CustomData.bin does not exist.|' }; Copy-Item $inputFile $outputFile -Force; PowerShell -File $outputFile -MasterIP ''uttestdom-dns-5d7c849e.hcp.southcentralus.azmk8s.io'' -KubeDnsServiceIp ''10.0.0.10'' -MasterFQDNPrefix ''uttestdom'' -Location ''southcentralus'' -TargetEnvironment ''akscustom'' -AgentKey '''' -AADClientId ''ClientID'' -AADClientSecret ''U2VjcmV0'' -NetworkAPIVersion 2018-08-01 -CSEResultFilePath %SYSTEMDRIVE%\AzureData\provision.complete >> %SYSTEMDRIVE%\AzureData\CustomDataSetupScript.log 2>&1; if (!(Test-Path %SYSTEMDRIVE%\AzureData\provision.complete)) { throw 'ExitCode: |50|, Output: |WINDOWS_CSE_ERROR_NO_CSE_RESULT_LOG|, Error: |C:\AzureData\provision.complete is not generated.|'; }; $result=(Get-Content %SYSTEMDRIVE%\AzureData\provision.complete); if($result -ne '0') { throw $result; }; "
powershell.exe -ExecutionPolicy Unrestricted -command " $inputFile = '%SYSTEMDRIVE%\AzureData\CustomData.bin'; $outputFile = '%SYSTEMDRIVE%\AzureData\CustomDataSetupScript.ps1'; if (!(Test-Path $inputFile)) { throw 'ExitCode: |49|, Output: |WINDOWS_CSE_ERROR_NO_CUSTOM_DATA_BIN|, Error: |$inputFile does not exist.|' }; Copy-Item $inputFile $outputFile -Force; PowerShell -File $outputFile -AgentKey '''' -AADClientSecret ''U2VjcmV0'' -CSEResultFilePath %SYSTEMDRIVE%\AzureData\provision.complete >> %SYSTEMDRIVE%\AzureData\CustomDataSetupScript.log 2>&1; if (!(Test-Path %SYSTEMDRIVE%\AzureData\provision.complete)) { throw 'ExitCode: |50|, Output: |WINDOWS_CSE_ERROR_NO_CSE_RESULT_LOG|, Error: |C:\AzureData\provision.complete is not generated.|'; }; $result=(Get-Content %SYSTEMDRIVE%\AzureData\provision.complete); if ($result -ne '0') { throw $result; }; "
Original file line number Diff line number Diff line change
Expand Up @@ -19,53 +19,36 @@
#>
[CmdletBinding(DefaultParameterSetName="Standard")]
param(
[string]
[ValidateNotNullOrEmpty()]
$MasterIP,

[parameter()]
[ValidateNotNullOrEmpty()]
$KubeDnsServiceIp,

[parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
$MasterFQDNPrefix,

[parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
$Location,

[parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
$AgentKey,

[parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
$AADClientId,

[parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
$AADClientSecret, # base64

[parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
$NetworkAPIVersion,

[parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
$TargetEnvironment,

# C:\AzureData\provision.complete
# MUST keep generating this file when CSE is done and do not change the name
# - It is used to avoid running CSE multiple times
# - Some customers use this file to check if CSE is done
[parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
$CSEResultFilePath,

[string]
$UserAssignedClientID
$CSEResultFilePath
)

# In an ideal world, all these values would be passed to this script in parameters. However, we don't live in an ideal world.
# https://learn.microsoft.com/en-gb/troubleshoot/windows-client/shell-experience/command-line-string-limitation

$MasterIP = "uttestdom-dns-5d7c849e.hcp.southcentralus.azmk8s.io"
$KubeDnsServiceIp="10.0.0.10"
$MasterFQDNPrefix="uttestdom"
$Location="southcentralus"

$TargetEnvironment="akscustom"
$AgentKey=""
$AADClientId="ClientID"
$NetworkAPIVersion="2018-08-01"

# Do not parse the start time from $LogFile to simplify the logic
$StartTime=Get-Date
$global:ExitCode=0
Expand Down
2 changes: 1 addition & 1 deletion pkg/agent/testdata/AKSWindows2019+CustomCloud/CSECommand
Original file line number Diff line number Diff line change
@@ -1 +1 @@
powershell.exe -ExecutionPolicy Unrestricted -command " $inputFile = '%SYSTEMDRIVE%\AzureData\CustomData.bin'; $outputFile = '%SYSTEMDRIVE%\AzureData\CustomDataSetupScript.ps1'; if (!(Test-Path $inputFile)) { throw 'ExitCode: |49|, Output: |WINDOWS_CSE_ERROR_NO_CUSTOM_DATA_BIN|, Error: |C:\AzureData\CustomData.bin does not exist.|' }; Copy-Item $inputFile $outputFile -Force; PowerShell -File $outputFile -MasterIP ''uttestdom-dns-5d7c849e.hcp.southcentralus.azmk8s.io'' -KubeDnsServiceIp ''10.0.0.10'' -MasterFQDNPrefix ''uttestdom'' -Location ''southcentralus'' -TargetEnvironment ''akscustom'' -AgentKey '''' -AADClientId ''ClientID'' -AADClientSecret ''U2VjcmV0'' -NetworkAPIVersion 2018-08-01 -CSEResultFilePath %SYSTEMDRIVE%\AzureData\provision.complete >> %SYSTEMDRIVE%\AzureData\CustomDataSetupScript.log 2>&1; if (!(Test-Path %SYSTEMDRIVE%\AzureData\provision.complete)) { throw 'ExitCode: |50|, Output: |WINDOWS_CSE_ERROR_NO_CSE_RESULT_LOG|, Error: |C:\AzureData\provision.complete is not generated.|'; }; $result=(Get-Content %SYSTEMDRIVE%\AzureData\provision.complete); if($result -ne '0') { throw $result; }; "
powershell.exe -ExecutionPolicy Unrestricted -command " $inputFile = '%SYSTEMDRIVE%\AzureData\CustomData.bin'; $outputFile = '%SYSTEMDRIVE%\AzureData\CustomDataSetupScript.ps1'; if (!(Test-Path $inputFile)) { throw 'ExitCode: |49|, Output: |WINDOWS_CSE_ERROR_NO_CUSTOM_DATA_BIN|, Error: |$inputFile does not exist.|' }; Copy-Item $inputFile $outputFile -Force; PowerShell -File $outputFile -AgentKey '''' -AADClientSecret ''U2VjcmV0'' -CSEResultFilePath %SYSTEMDRIVE%\AzureData\provision.complete >> %SYSTEMDRIVE%\AzureData\CustomDataSetupScript.log 2>&1; if (!(Test-Path %SYSTEMDRIVE%\AzureData\provision.complete)) { throw 'ExitCode: |50|, Output: |WINDOWS_CSE_ERROR_NO_CSE_RESULT_LOG|, Error: |C:\AzureData\provision.complete is not generated.|'; }; $result=(Get-Content %SYSTEMDRIVE%\AzureData\provision.complete); if ($result -ne '0') { throw $result; }; "
47 changes: 15 additions & 32 deletions pkg/agent/testdata/AKSWindows2019+CustomCloud/CustomData
Original file line number Diff line number Diff line change
Expand Up @@ -19,53 +19,36 @@
#>
[CmdletBinding(DefaultParameterSetName="Standard")]
param(
[string]
[ValidateNotNullOrEmpty()]
$MasterIP,

[parameter()]
[ValidateNotNullOrEmpty()]
$KubeDnsServiceIp,

[parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
$MasterFQDNPrefix,

[parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
$Location,

[parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
$AgentKey,

[parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
$AADClientId,

[parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
$AADClientSecret, # base64

[parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
$NetworkAPIVersion,

[parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
$TargetEnvironment,

# C:\AzureData\provision.complete
# MUST keep generating this file when CSE is done and do not change the name
# - It is used to avoid running CSE multiple times
# - Some customers use this file to check if CSE is done
[parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
$CSEResultFilePath,

[string]
$UserAssignedClientID
$CSEResultFilePath
)

# In an ideal world, all these values would be passed to this script in parameters. However, we don't live in an ideal world.
# https://learn.microsoft.com/en-gb/troubleshoot/windows-client/shell-experience/command-line-string-limitation

$MasterIP = "uttestdom-dns-5d7c849e.hcp.southcentralus.azmk8s.io"
$KubeDnsServiceIp="10.0.0.10"
$MasterFQDNPrefix="uttestdom"
$Location="southcentralus"

$TargetEnvironment="akscustom"
$AgentKey=""
$AADClientId="ClientID"
$NetworkAPIVersion="2018-08-01"

# Do not parse the start time from $LogFile to simplify the logic
$StartTime=Get-Date
$global:ExitCode=0
Expand Down
2 changes: 1 addition & 1 deletion pkg/agent/testdata/AKSWindows2019+CustomVnet/CSECommand
Original file line number Diff line number Diff line change
@@ -1 +1 @@
powershell.exe -ExecutionPolicy Unrestricted -command " $inputFile = '%SYSTEMDRIVE%\AzureData\CustomData.bin'; $outputFile = '%SYSTEMDRIVE%\AzureData\CustomDataSetupScript.ps1'; if (!(Test-Path $inputFile)) { throw 'ExitCode: |49|, Output: |WINDOWS_CSE_ERROR_NO_CUSTOM_DATA_BIN|, Error: |C:\AzureData\CustomData.bin does not exist.|' }; Copy-Item $inputFile $outputFile -Force; PowerShell -File $outputFile -MasterIP ''uttestdom-dns-5d7c849e.hcp.southcentralus.azmk8s.io'' -KubeDnsServiceIp ''10.0.0.10'' -MasterFQDNPrefix ''uttestdom'' -Location ''southcentralus'' -TargetEnvironment ''AzurePublicCloud'' -AgentKey '''' -AADClientId ''ClientID'' -AADClientSecret ''U2VjcmV0'' -NetworkAPIVersion 2018-08-01 -CSEResultFilePath %SYSTEMDRIVE%\AzureData\provision.complete >> %SYSTEMDRIVE%\AzureData\CustomDataSetupScript.log 2>&1; if (!(Test-Path %SYSTEMDRIVE%\AzureData\provision.complete)) { throw 'ExitCode: |50|, Output: |WINDOWS_CSE_ERROR_NO_CSE_RESULT_LOG|, Error: |C:\AzureData\provision.complete is not generated.|'; }; $result=(Get-Content %SYSTEMDRIVE%\AzureData\provision.complete); if($result -ne '0') { throw $result; }; "
powershell.exe -ExecutionPolicy Unrestricted -command " $inputFile = '%SYSTEMDRIVE%\AzureData\CustomData.bin'; $outputFile = '%SYSTEMDRIVE%\AzureData\CustomDataSetupScript.ps1'; if (!(Test-Path $inputFile)) { throw 'ExitCode: |49|, Output: |WINDOWS_CSE_ERROR_NO_CUSTOM_DATA_BIN|, Error: |$inputFile does not exist.|' }; Copy-Item $inputFile $outputFile -Force; PowerShell -File $outputFile -AgentKey '''' -AADClientSecret ''U2VjcmV0'' -CSEResultFilePath %SYSTEMDRIVE%\AzureData\provision.complete >> %SYSTEMDRIVE%\AzureData\CustomDataSetupScript.log 2>&1; if (!(Test-Path %SYSTEMDRIVE%\AzureData\provision.complete)) { throw 'ExitCode: |50|, Output: |WINDOWS_CSE_ERROR_NO_CSE_RESULT_LOG|, Error: |C:\AzureData\provision.complete is not generated.|'; }; $result=(Get-Content %SYSTEMDRIVE%\AzureData\provision.complete); if ($result -ne '0') { throw $result; }; "
Loading

0 comments on commit b95d1c7

Please sign in to comment.