зеркало из https://github.com/Azure/AgentBaker.git
feat: remove Invoke-Expression in Windows CSE command (#4563)
This commit is contained in:
Родитель
9d6f6f97fd
Коммит
94e581901c
|
@ -1,5 +1,9 @@
|
|||
powershell.exe -ExecutionPolicy Unrestricted -command \"
|
||||
$arguments = '
|
||||
$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 ''{{ GetKubernetesEndpoint }}''
|
||||
-KubeDnsServiceIp ''{{ GetParameter "kubeDNSServiceIP" }}''
|
||||
-MasterFQDNPrefix ''{{ GetParameter "masterEndpointDNSNamePrefix" }}''
|
||||
|
@ -12,11 +16,6 @@ $arguments = '
|
|||
-AADClientId ''{{ GetParameter "servicePrincipalClientId" }}''
|
||||
-AADClientSecret ''{{ GetParameter "encodedServicePrincipalClientSecret" }}''
|
||||
-NetworkAPIVersion 2018-08-01
|
||||
-LogFile %SYSTEMDRIVE%\AzureData\CustomDataSetupScript.log
|
||||
-CSEResultFilePath %SYSTEMDRIVE%\AzureData\provision.complete';
|
||||
$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;
|
||||
Invoke-Expression('{0} {1}' -f $outputFile, $arguments);
|
||||
-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; };
|
||||
\"
|
|
@ -55,10 +55,6 @@ param(
|
|||
[ValidateNotNullOrEmpty()]
|
||||
$TargetEnvironment,
|
||||
|
||||
[parameter(Mandatory=$true)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
$LogFile,
|
||||
|
||||
# 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
|
||||
|
@ -74,7 +70,7 @@ param(
|
|||
$StartTime=Get-Date
|
||||
$global:ExitCode=0
|
||||
$global:ErrorMessage=""
|
||||
Start-Transcript -Path $LogFile
|
||||
|
||||
# These globals will not change between nodes in the same cluster, so they are not
|
||||
# passed as powershell parameters
|
||||
|
||||
|
@ -229,7 +225,7 @@ $global:OperationId = New-Guid
|
|||
|
||||
try
|
||||
{
|
||||
Logs-To-Event -TaskName "AKS.WindowsCSE.ExecuteCustomDataSetupScript" -TaskMessage ".\CustomDataSetupScript.ps1 -MasterIP $MasterIP -KubeDnsServiceIp $KubeDnsServiceIp -MasterFQDNPrefix $MasterFQDNPrefix -Location $Location -AADClientId $AADClientId -NetworkAPIVersion $NetworkAPIVersion -TargetEnvironment $TargetEnvironment"
|
||||
Logs-To-Event -TaskName "AKS.WindowsCSE.ExecuteCustomDataSetupScript" -TaskMessage ".\CustomDataSetupScript.ps1 -MasterIP $MasterIP -KubeDnsServiceIp $KubeDnsServiceIp -MasterFQDNPrefix $MasterFQDNPrefix -Location $Location -AADClientId $AADClientId -NetworkAPIVersion $NetworkAPIVersion -TargetEnvironment $TargetEnvironment -CSEResultFilePath $CSEResultFilePath"
|
||||
|
||||
# Exit early if the script has been executed
|
||||
if (Test-Path -Path $CSEResultFilePath -PathType Leaf) {
|
||||
|
@ -499,22 +495,19 @@ finally
|
|||
# Generate CSE result so it can be returned as the CSE response in csecmd.ps1
|
||||
$ExecutionDuration=$(New-Timespan -Start $StartTime -End $(Get-Date))
|
||||
Write-Log "CSE ExecutionDuration: $ExecutionDuration. ExitCode: $global:ExitCode"
|
||||
# $CSEResultFilePath is used to avoid running CSE multiple times
|
||||
Set-Content -Path $CSEResultFilePath -Value $global:ExitCode -Force
|
||||
|
||||
Logs-To-Event -TaskName "AKS.WindowsCSE.cse_main" -TaskMessage "ExitCode: $global:ExitCode. ErrorMessage: $global:ErrorMessage."
|
||||
# Please not use Write-Log or Logs-To-Events after Stop-Transcript
|
||||
Stop-Transcript
|
||||
|
||||
# Remove the parameters in the log file to avoid leaking secrets
|
||||
$logs=Get-Content $LogFile | Where-Object {$_ -notmatch "^Host Application: "}
|
||||
$logs | Set-Content $LogFile
|
||||
|
||||
Upload-GuestVMLogs -ExitCode $global:ExitCode
|
||||
# $CSEResultFilePath is used to avoid running CSE multiple times
|
||||
if ($global:ExitCode -ne 0) {
|
||||
# $JsonString = "ExitCode: |{0}|, Output: |{1}|, Error: |{2}|"
|
||||
# Max length of the full error message returned by Windows CSE is ~256. We use 240 to be safe.
|
||||
$errorMessageLength = "ExitCode: |$global:ExitCode|, Output: |$($global:ErrorCodeNames[$global:ExitCode])|, Error: ||".Length
|
||||
$turncatedErrorMessage = $global:ErrorMessage.Substring(0, [Math]::Min(240 - $errorMessageLength, $global:ErrorMessage.Length))
|
||||
throw "ExitCode: |$global:ExitCode|, Output: |$($global:ErrorCodeNames[$global:ExitCode])|, Error: |$turncatedErrorMessage|"
|
||||
Set-Content -Path $CSEResultFilePath -Value "ExitCode: |$global:ExitCode|, Output: |$($global:ErrorCodeNames[$global:ExitCode])|, Error: |$turncatedErrorMessage|"
|
||||
}
|
||||
else {
|
||||
Set-Content -Path $CSEResultFilePath -Value $global:ExitCode -Force
|
||||
}
|
||||
Upload-GuestVMLogs -ExitCode $global:ExitCode
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
powershell.exe -ExecutionPolicy Unrestricted -command " $arguments = ' -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 -LogFile %SYSTEMDRIVE%\AzureData\CustomDataSetupScript.log -CSEResultFilePath %SYSTEMDRIVE%\AzureData\provision.complete'; $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; Invoke-Expression('{0} {1}' -f $outputFile, $arguments); "
|
||||
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; }; "
|
|
@ -55,10 +55,6 @@ param(
|
|||
[ValidateNotNullOrEmpty()]
|
||||
$TargetEnvironment,
|
||||
|
||||
[parameter(Mandatory=$true)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
$LogFile,
|
||||
|
||||
# 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
|
||||
|
@ -74,7 +70,7 @@ param(
|
|||
$StartTime=Get-Date
|
||||
$global:ExitCode=0
|
||||
$global:ErrorMessage=""
|
||||
Start-Transcript -Path $LogFile
|
||||
|
||||
# These globals will not change between nodes in the same cluster, so they are not
|
||||
# passed as powershell parameters
|
||||
|
||||
|
@ -225,7 +221,7 @@ $global:OperationId = New-Guid
|
|||
|
||||
try
|
||||
{
|
||||
Logs-To-Event -TaskName "AKS.WindowsCSE.ExecuteCustomDataSetupScript" -TaskMessage ".\CustomDataSetupScript.ps1 -MasterIP $MasterIP -KubeDnsServiceIp $KubeDnsServiceIp -MasterFQDNPrefix $MasterFQDNPrefix -Location $Location -AADClientId $AADClientId -NetworkAPIVersion $NetworkAPIVersion -TargetEnvironment $TargetEnvironment"
|
||||
Logs-To-Event -TaskName "AKS.WindowsCSE.ExecuteCustomDataSetupScript" -TaskMessage ".\CustomDataSetupScript.ps1 -MasterIP $MasterIP -KubeDnsServiceIp $KubeDnsServiceIp -MasterFQDNPrefix $MasterFQDNPrefix -Location $Location -AADClientId $AADClientId -NetworkAPIVersion $NetworkAPIVersion -TargetEnvironment $TargetEnvironment -CSEResultFilePath $CSEResultFilePath"
|
||||
|
||||
# Exit early if the script has been executed
|
||||
if (Test-Path -Path $CSEResultFilePath -PathType Leaf) {
|
||||
|
@ -495,22 +491,19 @@ finally
|
|||
# Generate CSE result so it can be returned as the CSE response in csecmd.ps1
|
||||
$ExecutionDuration=$(New-Timespan -Start $StartTime -End $(Get-Date))
|
||||
Write-Log "CSE ExecutionDuration: $ExecutionDuration. ExitCode: $global:ExitCode"
|
||||
# $CSEResultFilePath is used to avoid running CSE multiple times
|
||||
Set-Content -Path $CSEResultFilePath -Value $global:ExitCode -Force
|
||||
|
||||
Logs-To-Event -TaskName "AKS.WindowsCSE.cse_main" -TaskMessage "ExitCode: $global:ExitCode. ErrorMessage: $global:ErrorMessage."
|
||||
# Please not use Write-Log or Logs-To-Events after Stop-Transcript
|
||||
Stop-Transcript
|
||||
|
||||
# Remove the parameters in the log file to avoid leaking secrets
|
||||
$logs=Get-Content $LogFile | Where-Object {$_ -notmatch "^Host Application: "}
|
||||
$logs | Set-Content $LogFile
|
||||
|
||||
Upload-GuestVMLogs -ExitCode $global:ExitCode
|
||||
# $CSEResultFilePath is used to avoid running CSE multiple times
|
||||
if ($global:ExitCode -ne 0) {
|
||||
# $JsonString = "ExitCode: |{0}|, Output: |{1}|, Error: |{2}|"
|
||||
# Max length of the full error message returned by Windows CSE is ~256. We use 240 to be safe.
|
||||
$errorMessageLength = "ExitCode: |$global:ExitCode|, Output: |$($global:ErrorCodeNames[$global:ExitCode])|, Error: ||".Length
|
||||
$turncatedErrorMessage = $global:ErrorMessage.Substring(0, [Math]::Min(240 - $errorMessageLength, $global:ErrorMessage.Length))
|
||||
throw "ExitCode: |$global:ExitCode|, Output: |$($global:ErrorCodeNames[$global:ExitCode])|, Error: |$turncatedErrorMessage|"
|
||||
Set-Content -Path $CSEResultFilePath -Value "ExitCode: |$global:ExitCode|, Output: |$($global:ErrorCodeNames[$global:ExitCode])|, Error: |$turncatedErrorMessage|"
|
||||
}
|
||||
else {
|
||||
Set-Content -Path $CSEResultFilePath -Value $global:ExitCode -Force
|
||||
}
|
||||
Upload-GuestVMLogs -ExitCode $global:ExitCode
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
powershell.exe -ExecutionPolicy Unrestricted -command " $arguments = ' -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 -LogFile %SYSTEMDRIVE%\AzureData\CustomDataSetupScript.log -CSEResultFilePath %SYSTEMDRIVE%\AzureData\provision.complete'; $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; Invoke-Expression('{0} {1}' -f $outputFile, $arguments); "
|
||||
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; }; "
|
|
@ -55,10 +55,6 @@ param(
|
|||
[ValidateNotNullOrEmpty()]
|
||||
$TargetEnvironment,
|
||||
|
||||
[parameter(Mandatory=$true)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
$LogFile,
|
||||
|
||||
# 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
|
||||
|
@ -74,7 +70,7 @@ param(
|
|||
$StartTime=Get-Date
|
||||
$global:ExitCode=0
|
||||
$global:ErrorMessage=""
|
||||
Start-Transcript -Path $LogFile
|
||||
|
||||
# These globals will not change between nodes in the same cluster, so they are not
|
||||
# passed as powershell parameters
|
||||
|
||||
|
@ -225,7 +221,7 @@ $global:OperationId = New-Guid
|
|||
|
||||
try
|
||||
{
|
||||
Logs-To-Event -TaskName "AKS.WindowsCSE.ExecuteCustomDataSetupScript" -TaskMessage ".\CustomDataSetupScript.ps1 -MasterIP $MasterIP -KubeDnsServiceIp $KubeDnsServiceIp -MasterFQDNPrefix $MasterFQDNPrefix -Location $Location -AADClientId $AADClientId -NetworkAPIVersion $NetworkAPIVersion -TargetEnvironment $TargetEnvironment"
|
||||
Logs-To-Event -TaskName "AKS.WindowsCSE.ExecuteCustomDataSetupScript" -TaskMessage ".\CustomDataSetupScript.ps1 -MasterIP $MasterIP -KubeDnsServiceIp $KubeDnsServiceIp -MasterFQDNPrefix $MasterFQDNPrefix -Location $Location -AADClientId $AADClientId -NetworkAPIVersion $NetworkAPIVersion -TargetEnvironment $TargetEnvironment -CSEResultFilePath $CSEResultFilePath"
|
||||
|
||||
# Exit early if the script has been executed
|
||||
if (Test-Path -Path $CSEResultFilePath -PathType Leaf) {
|
||||
|
@ -495,22 +491,19 @@ finally
|
|||
# Generate CSE result so it can be returned as the CSE response in csecmd.ps1
|
||||
$ExecutionDuration=$(New-Timespan -Start $StartTime -End $(Get-Date))
|
||||
Write-Log "CSE ExecutionDuration: $ExecutionDuration. ExitCode: $global:ExitCode"
|
||||
# $CSEResultFilePath is used to avoid running CSE multiple times
|
||||
Set-Content -Path $CSEResultFilePath -Value $global:ExitCode -Force
|
||||
|
||||
Logs-To-Event -TaskName "AKS.WindowsCSE.cse_main" -TaskMessage "ExitCode: $global:ExitCode. ErrorMessage: $global:ErrorMessage."
|
||||
# Please not use Write-Log or Logs-To-Events after Stop-Transcript
|
||||
Stop-Transcript
|
||||
|
||||
# Remove the parameters in the log file to avoid leaking secrets
|
||||
$logs=Get-Content $LogFile | Where-Object {$_ -notmatch "^Host Application: "}
|
||||
$logs | Set-Content $LogFile
|
||||
|
||||
Upload-GuestVMLogs -ExitCode $global:ExitCode
|
||||
# $CSEResultFilePath is used to avoid running CSE multiple times
|
||||
if ($global:ExitCode -ne 0) {
|
||||
# $JsonString = "ExitCode: |{0}|, Output: |{1}|, Error: |{2}|"
|
||||
# Max length of the full error message returned by Windows CSE is ~256. We use 240 to be safe.
|
||||
$errorMessageLength = "ExitCode: |$global:ExitCode|, Output: |$($global:ErrorCodeNames[$global:ExitCode])|, Error: ||".Length
|
||||
$turncatedErrorMessage = $global:ErrorMessage.Substring(0, [Math]::Min(240 - $errorMessageLength, $global:ErrorMessage.Length))
|
||||
throw "ExitCode: |$global:ExitCode|, Output: |$($global:ErrorCodeNames[$global:ExitCode])|, Error: |$turncatedErrorMessage|"
|
||||
Set-Content -Path $CSEResultFilePath -Value "ExitCode: |$global:ExitCode|, Output: |$($global:ErrorCodeNames[$global:ExitCode])|, Error: |$turncatedErrorMessage|"
|
||||
}
|
||||
else {
|
||||
Set-Content -Path $CSEResultFilePath -Value $global:ExitCode -Force
|
||||
}
|
||||
Upload-GuestVMLogs -ExitCode $global:ExitCode
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
powershell.exe -ExecutionPolicy Unrestricted -command " $arguments = ' -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 -LogFile %SYSTEMDRIVE%\AzureData\CustomDataSetupScript.log -CSEResultFilePath %SYSTEMDRIVE%\AzureData\provision.complete'; $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; Invoke-Expression('{0} {1}' -f $outputFile, $arguments); "
|
||||
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; }; "
|
|
@ -55,10 +55,6 @@ param(
|
|||
[ValidateNotNullOrEmpty()]
|
||||
$TargetEnvironment,
|
||||
|
||||
[parameter(Mandatory=$true)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
$LogFile,
|
||||
|
||||
# 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
|
||||
|
@ -74,7 +70,7 @@ param(
|
|||
$StartTime=Get-Date
|
||||
$global:ExitCode=0
|
||||
$global:ErrorMessage=""
|
||||
Start-Transcript -Path $LogFile
|
||||
|
||||
# These globals will not change between nodes in the same cluster, so they are not
|
||||
# passed as powershell parameters
|
||||
|
||||
|
@ -225,7 +221,7 @@ $global:OperationId = New-Guid
|
|||
|
||||
try
|
||||
{
|
||||
Logs-To-Event -TaskName "AKS.WindowsCSE.ExecuteCustomDataSetupScript" -TaskMessage ".\CustomDataSetupScript.ps1 -MasterIP $MasterIP -KubeDnsServiceIp $KubeDnsServiceIp -MasterFQDNPrefix $MasterFQDNPrefix -Location $Location -AADClientId $AADClientId -NetworkAPIVersion $NetworkAPIVersion -TargetEnvironment $TargetEnvironment"
|
||||
Logs-To-Event -TaskName "AKS.WindowsCSE.ExecuteCustomDataSetupScript" -TaskMessage ".\CustomDataSetupScript.ps1 -MasterIP $MasterIP -KubeDnsServiceIp $KubeDnsServiceIp -MasterFQDNPrefix $MasterFQDNPrefix -Location $Location -AADClientId $AADClientId -NetworkAPIVersion $NetworkAPIVersion -TargetEnvironment $TargetEnvironment -CSEResultFilePath $CSEResultFilePath"
|
||||
|
||||
# Exit early if the script has been executed
|
||||
if (Test-Path -Path $CSEResultFilePath -PathType Leaf) {
|
||||
|
@ -489,22 +485,19 @@ finally
|
|||
# Generate CSE result so it can be returned as the CSE response in csecmd.ps1
|
||||
$ExecutionDuration=$(New-Timespan -Start $StartTime -End $(Get-Date))
|
||||
Write-Log "CSE ExecutionDuration: $ExecutionDuration. ExitCode: $global:ExitCode"
|
||||
# $CSEResultFilePath is used to avoid running CSE multiple times
|
||||
Set-Content -Path $CSEResultFilePath -Value $global:ExitCode -Force
|
||||
|
||||
Logs-To-Event -TaskName "AKS.WindowsCSE.cse_main" -TaskMessage "ExitCode: $global:ExitCode. ErrorMessage: $global:ErrorMessage."
|
||||
# Please not use Write-Log or Logs-To-Events after Stop-Transcript
|
||||
Stop-Transcript
|
||||
|
||||
# Remove the parameters in the log file to avoid leaking secrets
|
||||
$logs=Get-Content $LogFile | Where-Object {$_ -notmatch "^Host Application: "}
|
||||
$logs | Set-Content $LogFile
|
||||
|
||||
Upload-GuestVMLogs -ExitCode $global:ExitCode
|
||||
# $CSEResultFilePath is used to avoid running CSE multiple times
|
||||
if ($global:ExitCode -ne 0) {
|
||||
# $JsonString = "ExitCode: |{0}|, Output: |{1}|, Error: |{2}|"
|
||||
# Max length of the full error message returned by Windows CSE is ~256. We use 240 to be safe.
|
||||
$errorMessageLength = "ExitCode: |$global:ExitCode|, Output: |$($global:ErrorCodeNames[$global:ExitCode])|, Error: ||".Length
|
||||
$turncatedErrorMessage = $global:ErrorMessage.Substring(0, [Math]::Min(240 - $errorMessageLength, $global:ErrorMessage.Length))
|
||||
throw "ExitCode: |$global:ExitCode|, Output: |$($global:ErrorCodeNames[$global:ExitCode])|, Error: |$turncatedErrorMessage|"
|
||||
Set-Content -Path $CSEResultFilePath -Value "ExitCode: |$global:ExitCode|, Output: |$($global:ErrorCodeNames[$global:ExitCode])|, Error: |$turncatedErrorMessage|"
|
||||
}
|
||||
else {
|
||||
Set-Content -Path $CSEResultFilePath -Value $global:ExitCode -Force
|
||||
}
|
||||
Upload-GuestVMLogs -ExitCode $global:ExitCode
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
powershell.exe -ExecutionPolicy Unrestricted -command " $arguments = ' -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 -LogFile %SYSTEMDRIVE%\AzureData\CustomDataSetupScript.log -CSEResultFilePath %SYSTEMDRIVE%\AzureData\provision.complete'; $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; Invoke-Expression('{0} {1}' -f $outputFile, $arguments); "
|
||||
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; }; "
|
|
@ -55,10 +55,6 @@ param(
|
|||
[ValidateNotNullOrEmpty()]
|
||||
$TargetEnvironment,
|
||||
|
||||
[parameter(Mandatory=$true)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
$LogFile,
|
||||
|
||||
# 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
|
||||
|
@ -74,7 +70,7 @@ param(
|
|||
$StartTime=Get-Date
|
||||
$global:ExitCode=0
|
||||
$global:ErrorMessage=""
|
||||
Start-Transcript -Path $LogFile
|
||||
|
||||
# These globals will not change between nodes in the same cluster, so they are not
|
||||
# passed as powershell parameters
|
||||
|
||||
|
@ -225,7 +221,7 @@ $global:OperationId = New-Guid
|
|||
|
||||
try
|
||||
{
|
||||
Logs-To-Event -TaskName "AKS.WindowsCSE.ExecuteCustomDataSetupScript" -TaskMessage ".\CustomDataSetupScript.ps1 -MasterIP $MasterIP -KubeDnsServiceIp $KubeDnsServiceIp -MasterFQDNPrefix $MasterFQDNPrefix -Location $Location -AADClientId $AADClientId -NetworkAPIVersion $NetworkAPIVersion -TargetEnvironment $TargetEnvironment"
|
||||
Logs-To-Event -TaskName "AKS.WindowsCSE.ExecuteCustomDataSetupScript" -TaskMessage ".\CustomDataSetupScript.ps1 -MasterIP $MasterIP -KubeDnsServiceIp $KubeDnsServiceIp -MasterFQDNPrefix $MasterFQDNPrefix -Location $Location -AADClientId $AADClientId -NetworkAPIVersion $NetworkAPIVersion -TargetEnvironment $TargetEnvironment -CSEResultFilePath $CSEResultFilePath"
|
||||
|
||||
# Exit early if the script has been executed
|
||||
if (Test-Path -Path $CSEResultFilePath -PathType Leaf) {
|
||||
|
@ -489,22 +485,19 @@ finally
|
|||
# Generate CSE result so it can be returned as the CSE response in csecmd.ps1
|
||||
$ExecutionDuration=$(New-Timespan -Start $StartTime -End $(Get-Date))
|
||||
Write-Log "CSE ExecutionDuration: $ExecutionDuration. ExitCode: $global:ExitCode"
|
||||
# $CSEResultFilePath is used to avoid running CSE multiple times
|
||||
Set-Content -Path $CSEResultFilePath -Value $global:ExitCode -Force
|
||||
|
||||
Logs-To-Event -TaskName "AKS.WindowsCSE.cse_main" -TaskMessage "ExitCode: $global:ExitCode. ErrorMessage: $global:ErrorMessage."
|
||||
# Please not use Write-Log or Logs-To-Events after Stop-Transcript
|
||||
Stop-Transcript
|
||||
|
||||
# Remove the parameters in the log file to avoid leaking secrets
|
||||
$logs=Get-Content $LogFile | Where-Object {$_ -notmatch "^Host Application: "}
|
||||
$logs | Set-Content $LogFile
|
||||
|
||||
Upload-GuestVMLogs -ExitCode $global:ExitCode
|
||||
# $CSEResultFilePath is used to avoid running CSE multiple times
|
||||
if ($global:ExitCode -ne 0) {
|
||||
# $JsonString = "ExitCode: |{0}|, Output: |{1}|, Error: |{2}|"
|
||||
# Max length of the full error message returned by Windows CSE is ~256. We use 240 to be safe.
|
||||
$errorMessageLength = "ExitCode: |$global:ExitCode|, Output: |$($global:ErrorCodeNames[$global:ExitCode])|, Error: ||".Length
|
||||
$turncatedErrorMessage = $global:ErrorMessage.Substring(0, [Math]::Min(240 - $errorMessageLength, $global:ErrorMessage.Length))
|
||||
throw "ExitCode: |$global:ExitCode|, Output: |$($global:ErrorCodeNames[$global:ExitCode])|, Error: |$turncatedErrorMessage|"
|
||||
Set-Content -Path $CSEResultFilePath -Value "ExitCode: |$global:ExitCode|, Output: |$($global:ErrorCodeNames[$global:ExitCode])|, Error: |$turncatedErrorMessage|"
|
||||
}
|
||||
else {
|
||||
Set-Content -Path $CSEResultFilePath -Value $global:ExitCode -Force
|
||||
}
|
||||
Upload-GuestVMLogs -ExitCode $global:ExitCode
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
powershell.exe -ExecutionPolicy Unrestricted -command " $arguments = ' -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 -LogFile %SYSTEMDRIVE%\AzureData\CustomDataSetupScript.log -CSEResultFilePath %SYSTEMDRIVE%\AzureData\provision.complete'; $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; Invoke-Expression('{0} {1}' -f $outputFile, $arguments); "
|
||||
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; }; "
|
|
@ -55,10 +55,6 @@ param(
|
|||
[ValidateNotNullOrEmpty()]
|
||||
$TargetEnvironment,
|
||||
|
||||
[parameter(Mandatory=$true)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
$LogFile,
|
||||
|
||||
# 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
|
||||
|
@ -74,7 +70,7 @@ param(
|
|||
$StartTime=Get-Date
|
||||
$global:ExitCode=0
|
||||
$global:ErrorMessage=""
|
||||
Start-Transcript -Path $LogFile
|
||||
|
||||
# These globals will not change between nodes in the same cluster, so they are not
|
||||
# passed as powershell parameters
|
||||
|
||||
|
@ -225,7 +221,7 @@ $global:OperationId = New-Guid
|
|||
|
||||
try
|
||||
{
|
||||
Logs-To-Event -TaskName "AKS.WindowsCSE.ExecuteCustomDataSetupScript" -TaskMessage ".\CustomDataSetupScript.ps1 -MasterIP $MasterIP -KubeDnsServiceIp $KubeDnsServiceIp -MasterFQDNPrefix $MasterFQDNPrefix -Location $Location -AADClientId $AADClientId -NetworkAPIVersion $NetworkAPIVersion -TargetEnvironment $TargetEnvironment"
|
||||
Logs-To-Event -TaskName "AKS.WindowsCSE.ExecuteCustomDataSetupScript" -TaskMessage ".\CustomDataSetupScript.ps1 -MasterIP $MasterIP -KubeDnsServiceIp $KubeDnsServiceIp -MasterFQDNPrefix $MasterFQDNPrefix -Location $Location -AADClientId $AADClientId -NetworkAPIVersion $NetworkAPIVersion -TargetEnvironment $TargetEnvironment -CSEResultFilePath $CSEResultFilePath"
|
||||
|
||||
# Exit early if the script has been executed
|
||||
if (Test-Path -Path $CSEResultFilePath -PathType Leaf) {
|
||||
|
@ -489,22 +485,19 @@ finally
|
|||
# Generate CSE result so it can be returned as the CSE response in csecmd.ps1
|
||||
$ExecutionDuration=$(New-Timespan -Start $StartTime -End $(Get-Date))
|
||||
Write-Log "CSE ExecutionDuration: $ExecutionDuration. ExitCode: $global:ExitCode"
|
||||
# $CSEResultFilePath is used to avoid running CSE multiple times
|
||||
Set-Content -Path $CSEResultFilePath -Value $global:ExitCode -Force
|
||||
|
||||
Logs-To-Event -TaskName "AKS.WindowsCSE.cse_main" -TaskMessage "ExitCode: $global:ExitCode. ErrorMessage: $global:ErrorMessage."
|
||||
# Please not use Write-Log or Logs-To-Events after Stop-Transcript
|
||||
Stop-Transcript
|
||||
|
||||
# Remove the parameters in the log file to avoid leaking secrets
|
||||
$logs=Get-Content $LogFile | Where-Object {$_ -notmatch "^Host Application: "}
|
||||
$logs | Set-Content $LogFile
|
||||
|
||||
Upload-GuestVMLogs -ExitCode $global:ExitCode
|
||||
# $CSEResultFilePath is used to avoid running CSE multiple times
|
||||
if ($global:ExitCode -ne 0) {
|
||||
# $JsonString = "ExitCode: |{0}|, Output: |{1}|, Error: |{2}|"
|
||||
# Max length of the full error message returned by Windows CSE is ~256. We use 240 to be safe.
|
||||
$errorMessageLength = "ExitCode: |$global:ExitCode|, Output: |$($global:ErrorCodeNames[$global:ExitCode])|, Error: ||".Length
|
||||
$turncatedErrorMessage = $global:ErrorMessage.Substring(0, [Math]::Min(240 - $errorMessageLength, $global:ErrorMessage.Length))
|
||||
throw "ExitCode: |$global:ExitCode|, Output: |$($global:ErrorCodeNames[$global:ExitCode])|, Error: |$turncatedErrorMessage|"
|
||||
Set-Content -Path $CSEResultFilePath -Value "ExitCode: |$global:ExitCode|, Output: |$($global:ErrorCodeNames[$global:ExitCode])|, Error: |$turncatedErrorMessage|"
|
||||
}
|
||||
else {
|
||||
Set-Content -Path $CSEResultFilePath -Value $global:ExitCode -Force
|
||||
}
|
||||
Upload-GuestVMLogs -ExitCode $global:ExitCode
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
powershell.exe -ExecutionPolicy Unrestricted -command " $arguments = ' -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 -LogFile %SYSTEMDRIVE%\AzureData\CustomDataSetupScript.log -CSEResultFilePath %SYSTEMDRIVE%\AzureData\provision.complete'; $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; Invoke-Expression('{0} {1}' -f $outputFile, $arguments); "
|
||||
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; }; "
|
|
@ -55,10 +55,6 @@ param(
|
|||
[ValidateNotNullOrEmpty()]
|
||||
$TargetEnvironment,
|
||||
|
||||
[parameter(Mandatory=$true)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
$LogFile,
|
||||
|
||||
# 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
|
||||
|
@ -74,7 +70,7 @@ param(
|
|||
$StartTime=Get-Date
|
||||
$global:ExitCode=0
|
||||
$global:ErrorMessage=""
|
||||
Start-Transcript -Path $LogFile
|
||||
|
||||
# These globals will not change between nodes in the same cluster, so they are not
|
||||
# passed as powershell parameters
|
||||
|
||||
|
@ -225,7 +221,7 @@ $global:OperationId = New-Guid
|
|||
|
||||
try
|
||||
{
|
||||
Logs-To-Event -TaskName "AKS.WindowsCSE.ExecuteCustomDataSetupScript" -TaskMessage ".\CustomDataSetupScript.ps1 -MasterIP $MasterIP -KubeDnsServiceIp $KubeDnsServiceIp -MasterFQDNPrefix $MasterFQDNPrefix -Location $Location -AADClientId $AADClientId -NetworkAPIVersion $NetworkAPIVersion -TargetEnvironment $TargetEnvironment"
|
||||
Logs-To-Event -TaskName "AKS.WindowsCSE.ExecuteCustomDataSetupScript" -TaskMessage ".\CustomDataSetupScript.ps1 -MasterIP $MasterIP -KubeDnsServiceIp $KubeDnsServiceIp -MasterFQDNPrefix $MasterFQDNPrefix -Location $Location -AADClientId $AADClientId -NetworkAPIVersion $NetworkAPIVersion -TargetEnvironment $TargetEnvironment -CSEResultFilePath $CSEResultFilePath"
|
||||
|
||||
# Exit early if the script has been executed
|
||||
if (Test-Path -Path $CSEResultFilePath -PathType Leaf) {
|
||||
|
@ -489,22 +485,19 @@ finally
|
|||
# Generate CSE result so it can be returned as the CSE response in csecmd.ps1
|
||||
$ExecutionDuration=$(New-Timespan -Start $StartTime -End $(Get-Date))
|
||||
Write-Log "CSE ExecutionDuration: $ExecutionDuration. ExitCode: $global:ExitCode"
|
||||
# $CSEResultFilePath is used to avoid running CSE multiple times
|
||||
Set-Content -Path $CSEResultFilePath -Value $global:ExitCode -Force
|
||||
|
||||
Logs-To-Event -TaskName "AKS.WindowsCSE.cse_main" -TaskMessage "ExitCode: $global:ExitCode. ErrorMessage: $global:ErrorMessage."
|
||||
# Please not use Write-Log or Logs-To-Events after Stop-Transcript
|
||||
Stop-Transcript
|
||||
|
||||
# Remove the parameters in the log file to avoid leaking secrets
|
||||
$logs=Get-Content $LogFile | Where-Object {$_ -notmatch "^Host Application: "}
|
||||
$logs | Set-Content $LogFile
|
||||
|
||||
Upload-GuestVMLogs -ExitCode $global:ExitCode
|
||||
# $CSEResultFilePath is used to avoid running CSE multiple times
|
||||
if ($global:ExitCode -ne 0) {
|
||||
# $JsonString = "ExitCode: |{0}|, Output: |{1}|, Error: |{2}|"
|
||||
# Max length of the full error message returned by Windows CSE is ~256. We use 240 to be safe.
|
||||
$errorMessageLength = "ExitCode: |$global:ExitCode|, Output: |$($global:ErrorCodeNames[$global:ExitCode])|, Error: ||".Length
|
||||
$turncatedErrorMessage = $global:ErrorMessage.Substring(0, [Math]::Min(240 - $errorMessageLength, $global:ErrorMessage.Length))
|
||||
throw "ExitCode: |$global:ExitCode|, Output: |$($global:ErrorCodeNames[$global:ExitCode])|, Error: |$turncatedErrorMessage|"
|
||||
Set-Content -Path $CSEResultFilePath -Value "ExitCode: |$global:ExitCode|, Output: |$($global:ErrorCodeNames[$global:ExitCode])|, Error: |$turncatedErrorMessage|"
|
||||
}
|
||||
else {
|
||||
Set-Content -Path $CSEResultFilePath -Value $global:ExitCode -Force
|
||||
}
|
||||
Upload-GuestVMLogs -ExitCode $global:ExitCode
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
powershell.exe -ExecutionPolicy Unrestricted -command " $arguments = ' -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 -LogFile %SYSTEMDRIVE%\AzureData\CustomDataSetupScript.log -CSEResultFilePath %SYSTEMDRIVE%\AzureData\provision.complete'; $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; Invoke-Expression('{0} {1}' -f $outputFile, $arguments); "
|
||||
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; }; "
|
|
@ -55,10 +55,6 @@ param(
|
|||
[ValidateNotNullOrEmpty()]
|
||||
$TargetEnvironment,
|
||||
|
||||
[parameter(Mandatory=$true)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
$LogFile,
|
||||
|
||||
# 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
|
||||
|
@ -74,7 +70,7 @@ param(
|
|||
$StartTime=Get-Date
|
||||
$global:ExitCode=0
|
||||
$global:ErrorMessage=""
|
||||
Start-Transcript -Path $LogFile
|
||||
|
||||
# These globals will not change between nodes in the same cluster, so they are not
|
||||
# passed as powershell parameters
|
||||
|
||||
|
@ -225,7 +221,7 @@ $global:OperationId = New-Guid
|
|||
|
||||
try
|
||||
{
|
||||
Logs-To-Event -TaskName "AKS.WindowsCSE.ExecuteCustomDataSetupScript" -TaskMessage ".\CustomDataSetupScript.ps1 -MasterIP $MasterIP -KubeDnsServiceIp $KubeDnsServiceIp -MasterFQDNPrefix $MasterFQDNPrefix -Location $Location -AADClientId $AADClientId -NetworkAPIVersion $NetworkAPIVersion -TargetEnvironment $TargetEnvironment"
|
||||
Logs-To-Event -TaskName "AKS.WindowsCSE.ExecuteCustomDataSetupScript" -TaskMessage ".\CustomDataSetupScript.ps1 -MasterIP $MasterIP -KubeDnsServiceIp $KubeDnsServiceIp -MasterFQDNPrefix $MasterFQDNPrefix -Location $Location -AADClientId $AADClientId -NetworkAPIVersion $NetworkAPIVersion -TargetEnvironment $TargetEnvironment -CSEResultFilePath $CSEResultFilePath"
|
||||
|
||||
# Exit early if the script has been executed
|
||||
if (Test-Path -Path $CSEResultFilePath -PathType Leaf) {
|
||||
|
@ -489,22 +485,19 @@ finally
|
|||
# Generate CSE result so it can be returned as the CSE response in csecmd.ps1
|
||||
$ExecutionDuration=$(New-Timespan -Start $StartTime -End $(Get-Date))
|
||||
Write-Log "CSE ExecutionDuration: $ExecutionDuration. ExitCode: $global:ExitCode"
|
||||
# $CSEResultFilePath is used to avoid running CSE multiple times
|
||||
Set-Content -Path $CSEResultFilePath -Value $global:ExitCode -Force
|
||||
|
||||
Logs-To-Event -TaskName "AKS.WindowsCSE.cse_main" -TaskMessage "ExitCode: $global:ExitCode. ErrorMessage: $global:ErrorMessage."
|
||||
# Please not use Write-Log or Logs-To-Events after Stop-Transcript
|
||||
Stop-Transcript
|
||||
|
||||
# Remove the parameters in the log file to avoid leaking secrets
|
||||
$logs=Get-Content $LogFile | Where-Object {$_ -notmatch "^Host Application: "}
|
||||
$logs | Set-Content $LogFile
|
||||
|
||||
Upload-GuestVMLogs -ExitCode $global:ExitCode
|
||||
# $CSEResultFilePath is used to avoid running CSE multiple times
|
||||
if ($global:ExitCode -ne 0) {
|
||||
# $JsonString = "ExitCode: |{0}|, Output: |{1}|, Error: |{2}|"
|
||||
# Max length of the full error message returned by Windows CSE is ~256. We use 240 to be safe.
|
||||
$errorMessageLength = "ExitCode: |$global:ExitCode|, Output: |$($global:ErrorCodeNames[$global:ExitCode])|, Error: ||".Length
|
||||
$turncatedErrorMessage = $global:ErrorMessage.Substring(0, [Math]::Min(240 - $errorMessageLength, $global:ErrorMessage.Length))
|
||||
throw "ExitCode: |$global:ExitCode|, Output: |$($global:ErrorCodeNames[$global:ExitCode])|, Error: |$turncatedErrorMessage|"
|
||||
Set-Content -Path $CSEResultFilePath -Value "ExitCode: |$global:ExitCode|, Output: |$($global:ErrorCodeNames[$global:ExitCode])|, Error: |$turncatedErrorMessage|"
|
||||
}
|
||||
else {
|
||||
Set-Content -Path $CSEResultFilePath -Value $global:ExitCode -Force
|
||||
}
|
||||
Upload-GuestVMLogs -ExitCode $global:ExitCode
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
powershell.exe -ExecutionPolicy Unrestricted -command " $arguments = ' -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 -LogFile %SYSTEMDRIVE%\AzureData\CustomDataSetupScript.log -CSEResultFilePath %SYSTEMDRIVE%\AzureData\provision.complete'; $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; Invoke-Expression('{0} {1}' -f $outputFile, $arguments); "
|
||||
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; }; "
|
|
@ -55,10 +55,6 @@ param(
|
|||
[ValidateNotNullOrEmpty()]
|
||||
$TargetEnvironment,
|
||||
|
||||
[parameter(Mandatory=$true)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
$LogFile,
|
||||
|
||||
# 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
|
||||
|
@ -74,7 +70,7 @@ param(
|
|||
$StartTime=Get-Date
|
||||
$global:ExitCode=0
|
||||
$global:ErrorMessage=""
|
||||
Start-Transcript -Path $LogFile
|
||||
|
||||
# These globals will not change between nodes in the same cluster, so they are not
|
||||
# passed as powershell parameters
|
||||
|
||||
|
@ -225,7 +221,7 @@ $global:OperationId = New-Guid
|
|||
|
||||
try
|
||||
{
|
||||
Logs-To-Event -TaskName "AKS.WindowsCSE.ExecuteCustomDataSetupScript" -TaskMessage ".\CustomDataSetupScript.ps1 -MasterIP $MasterIP -KubeDnsServiceIp $KubeDnsServiceIp -MasterFQDNPrefix $MasterFQDNPrefix -Location $Location -AADClientId $AADClientId -NetworkAPIVersion $NetworkAPIVersion -TargetEnvironment $TargetEnvironment"
|
||||
Logs-To-Event -TaskName "AKS.WindowsCSE.ExecuteCustomDataSetupScript" -TaskMessage ".\CustomDataSetupScript.ps1 -MasterIP $MasterIP -KubeDnsServiceIp $KubeDnsServiceIp -MasterFQDNPrefix $MasterFQDNPrefix -Location $Location -AADClientId $AADClientId -NetworkAPIVersion $NetworkAPIVersion -TargetEnvironment $TargetEnvironment -CSEResultFilePath $CSEResultFilePath"
|
||||
|
||||
# Exit early if the script has been executed
|
||||
if (Test-Path -Path $CSEResultFilePath -PathType Leaf) {
|
||||
|
@ -489,22 +485,19 @@ finally
|
|||
# Generate CSE result so it can be returned as the CSE response in csecmd.ps1
|
||||
$ExecutionDuration=$(New-Timespan -Start $StartTime -End $(Get-Date))
|
||||
Write-Log "CSE ExecutionDuration: $ExecutionDuration. ExitCode: $global:ExitCode"
|
||||
# $CSEResultFilePath is used to avoid running CSE multiple times
|
||||
Set-Content -Path $CSEResultFilePath -Value $global:ExitCode -Force
|
||||
|
||||
Logs-To-Event -TaskName "AKS.WindowsCSE.cse_main" -TaskMessage "ExitCode: $global:ExitCode. ErrorMessage: $global:ErrorMessage."
|
||||
# Please not use Write-Log or Logs-To-Events after Stop-Transcript
|
||||
Stop-Transcript
|
||||
|
||||
# Remove the parameters in the log file to avoid leaking secrets
|
||||
$logs=Get-Content $LogFile | Where-Object {$_ -notmatch "^Host Application: "}
|
||||
$logs | Set-Content $LogFile
|
||||
|
||||
Upload-GuestVMLogs -ExitCode $global:ExitCode
|
||||
# $CSEResultFilePath is used to avoid running CSE multiple times
|
||||
if ($global:ExitCode -ne 0) {
|
||||
# $JsonString = "ExitCode: |{0}|, Output: |{1}|, Error: |{2}|"
|
||||
# Max length of the full error message returned by Windows CSE is ~256. We use 240 to be safe.
|
||||
$errorMessageLength = "ExitCode: |$global:ExitCode|, Output: |$($global:ErrorCodeNames[$global:ExitCode])|, Error: ||".Length
|
||||
$turncatedErrorMessage = $global:ErrorMessage.Substring(0, [Math]::Min(240 - $errorMessageLength, $global:ErrorMessage.Length))
|
||||
throw "ExitCode: |$global:ExitCode|, Output: |$($global:ErrorCodeNames[$global:ExitCode])|, Error: |$turncatedErrorMessage|"
|
||||
Set-Content -Path $CSEResultFilePath -Value "ExitCode: |$global:ExitCode|, Output: |$($global:ErrorCodeNames[$global:ExitCode])|, Error: |$turncatedErrorMessage|"
|
||||
}
|
||||
else {
|
||||
Set-Content -Path $CSEResultFilePath -Value $global:ExitCode -Force
|
||||
}
|
||||
Upload-GuestVMLogs -ExitCode $global:ExitCode
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
powershell.exe -ExecutionPolicy Unrestricted -command " $arguments = ' -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 -LogFile %SYSTEMDRIVE%\AzureData\CustomDataSetupScript.log -CSEResultFilePath %SYSTEMDRIVE%\AzureData\provision.complete'; $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; Invoke-Expression('{0} {1}' -f $outputFile, $arguments); "
|
||||
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; }; "
|
|
@ -55,10 +55,6 @@ param(
|
|||
[ValidateNotNullOrEmpty()]
|
||||
$TargetEnvironment,
|
||||
|
||||
[parameter(Mandatory=$true)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
$LogFile,
|
||||
|
||||
# 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
|
||||
|
@ -74,7 +70,7 @@ param(
|
|||
$StartTime=Get-Date
|
||||
$global:ExitCode=0
|
||||
$global:ErrorMessage=""
|
||||
Start-Transcript -Path $LogFile
|
||||
|
||||
# These globals will not change between nodes in the same cluster, so they are not
|
||||
# passed as powershell parameters
|
||||
|
||||
|
@ -225,7 +221,7 @@ $global:OperationId = New-Guid
|
|||
|
||||
try
|
||||
{
|
||||
Logs-To-Event -TaskName "AKS.WindowsCSE.ExecuteCustomDataSetupScript" -TaskMessage ".\CustomDataSetupScript.ps1 -MasterIP $MasterIP -KubeDnsServiceIp $KubeDnsServiceIp -MasterFQDNPrefix $MasterFQDNPrefix -Location $Location -AADClientId $AADClientId -NetworkAPIVersion $NetworkAPIVersion -TargetEnvironment $TargetEnvironment"
|
||||
Logs-To-Event -TaskName "AKS.WindowsCSE.ExecuteCustomDataSetupScript" -TaskMessage ".\CustomDataSetupScript.ps1 -MasterIP $MasterIP -KubeDnsServiceIp $KubeDnsServiceIp -MasterFQDNPrefix $MasterFQDNPrefix -Location $Location -AADClientId $AADClientId -NetworkAPIVersion $NetworkAPIVersion -TargetEnvironment $TargetEnvironment -CSEResultFilePath $CSEResultFilePath"
|
||||
|
||||
# Exit early if the script has been executed
|
||||
if (Test-Path -Path $CSEResultFilePath -PathType Leaf) {
|
||||
|
@ -489,22 +485,19 @@ finally
|
|||
# Generate CSE result so it can be returned as the CSE response in csecmd.ps1
|
||||
$ExecutionDuration=$(New-Timespan -Start $StartTime -End $(Get-Date))
|
||||
Write-Log "CSE ExecutionDuration: $ExecutionDuration. ExitCode: $global:ExitCode"
|
||||
# $CSEResultFilePath is used to avoid running CSE multiple times
|
||||
Set-Content -Path $CSEResultFilePath -Value $global:ExitCode -Force
|
||||
|
||||
Logs-To-Event -TaskName "AKS.WindowsCSE.cse_main" -TaskMessage "ExitCode: $global:ExitCode. ErrorMessage: $global:ErrorMessage."
|
||||
# Please not use Write-Log or Logs-To-Events after Stop-Transcript
|
||||
Stop-Transcript
|
||||
|
||||
# Remove the parameters in the log file to avoid leaking secrets
|
||||
$logs=Get-Content $LogFile | Where-Object {$_ -notmatch "^Host Application: "}
|
||||
$logs | Set-Content $LogFile
|
||||
|
||||
Upload-GuestVMLogs -ExitCode $global:ExitCode
|
||||
# $CSEResultFilePath is used to avoid running CSE multiple times
|
||||
if ($global:ExitCode -ne 0) {
|
||||
# $JsonString = "ExitCode: |{0}|, Output: |{1}|, Error: |{2}|"
|
||||
# Max length of the full error message returned by Windows CSE is ~256. We use 240 to be safe.
|
||||
$errorMessageLength = "ExitCode: |$global:ExitCode|, Output: |$($global:ErrorCodeNames[$global:ExitCode])|, Error: ||".Length
|
||||
$turncatedErrorMessage = $global:ErrorMessage.Substring(0, [Math]::Min(240 - $errorMessageLength, $global:ErrorMessage.Length))
|
||||
throw "ExitCode: |$global:ExitCode|, Output: |$($global:ErrorCodeNames[$global:ExitCode])|, Error: |$turncatedErrorMessage|"
|
||||
Set-Content -Path $CSEResultFilePath -Value "ExitCode: |$global:ExitCode|, Output: |$($global:ErrorCodeNames[$global:ExitCode])|, Error: |$turncatedErrorMessage|"
|
||||
}
|
||||
else {
|
||||
Set-Content -Path $CSEResultFilePath -Value $global:ExitCode -Force
|
||||
}
|
||||
Upload-GuestVMLogs -ExitCode $global:ExitCode
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
powershell.exe -ExecutionPolicy Unrestricted -command " $arguments = ' -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 -LogFile %SYSTEMDRIVE%\AzureData\CustomDataSetupScript.log -CSEResultFilePath %SYSTEMDRIVE%\AzureData\provision.complete'; $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; Invoke-Expression('{0} {1}' -f $outputFile, $arguments); "
|
||||
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; }; "
|
|
@ -55,10 +55,6 @@ param(
|
|||
[ValidateNotNullOrEmpty()]
|
||||
$TargetEnvironment,
|
||||
|
||||
[parameter(Mandatory=$true)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
$LogFile,
|
||||
|
||||
# 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
|
||||
|
@ -74,7 +70,7 @@ param(
|
|||
$StartTime=Get-Date
|
||||
$global:ExitCode=0
|
||||
$global:ErrorMessage=""
|
||||
Start-Transcript -Path $LogFile
|
||||
|
||||
# These globals will not change between nodes in the same cluster, so they are not
|
||||
# passed as powershell parameters
|
||||
|
||||
|
@ -225,7 +221,7 @@ $global:OperationId = New-Guid
|
|||
|
||||
try
|
||||
{
|
||||
Logs-To-Event -TaskName "AKS.WindowsCSE.ExecuteCustomDataSetupScript" -TaskMessage ".\CustomDataSetupScript.ps1 -MasterIP $MasterIP -KubeDnsServiceIp $KubeDnsServiceIp -MasterFQDNPrefix $MasterFQDNPrefix -Location $Location -AADClientId $AADClientId -NetworkAPIVersion $NetworkAPIVersion -TargetEnvironment $TargetEnvironment"
|
||||
Logs-To-Event -TaskName "AKS.WindowsCSE.ExecuteCustomDataSetupScript" -TaskMessage ".\CustomDataSetupScript.ps1 -MasterIP $MasterIP -KubeDnsServiceIp $KubeDnsServiceIp -MasterFQDNPrefix $MasterFQDNPrefix -Location $Location -AADClientId $AADClientId -NetworkAPIVersion $NetworkAPIVersion -TargetEnvironment $TargetEnvironment -CSEResultFilePath $CSEResultFilePath"
|
||||
|
||||
# Exit early if the script has been executed
|
||||
if (Test-Path -Path $CSEResultFilePath -PathType Leaf) {
|
||||
|
@ -489,22 +485,19 @@ finally
|
|||
# Generate CSE result so it can be returned as the CSE response in csecmd.ps1
|
||||
$ExecutionDuration=$(New-Timespan -Start $StartTime -End $(Get-Date))
|
||||
Write-Log "CSE ExecutionDuration: $ExecutionDuration. ExitCode: $global:ExitCode"
|
||||
# $CSEResultFilePath is used to avoid running CSE multiple times
|
||||
Set-Content -Path $CSEResultFilePath -Value $global:ExitCode -Force
|
||||
|
||||
Logs-To-Event -TaskName "AKS.WindowsCSE.cse_main" -TaskMessage "ExitCode: $global:ExitCode. ErrorMessage: $global:ErrorMessage."
|
||||
# Please not use Write-Log or Logs-To-Events after Stop-Transcript
|
||||
Stop-Transcript
|
||||
|
||||
# Remove the parameters in the log file to avoid leaking secrets
|
||||
$logs=Get-Content $LogFile | Where-Object {$_ -notmatch "^Host Application: "}
|
||||
$logs | Set-Content $LogFile
|
||||
|
||||
Upload-GuestVMLogs -ExitCode $global:ExitCode
|
||||
# $CSEResultFilePath is used to avoid running CSE multiple times
|
||||
if ($global:ExitCode -ne 0) {
|
||||
# $JsonString = "ExitCode: |{0}|, Output: |{1}|, Error: |{2}|"
|
||||
# Max length of the full error message returned by Windows CSE is ~256. We use 240 to be safe.
|
||||
$errorMessageLength = "ExitCode: |$global:ExitCode|, Output: |$($global:ErrorCodeNames[$global:ExitCode])|, Error: ||".Length
|
||||
$turncatedErrorMessage = $global:ErrorMessage.Substring(0, [Math]::Min(240 - $errorMessageLength, $global:ErrorMessage.Length))
|
||||
throw "ExitCode: |$global:ExitCode|, Output: |$($global:ErrorCodeNames[$global:ExitCode])|, Error: |$turncatedErrorMessage|"
|
||||
Set-Content -Path $CSEResultFilePath -Value "ExitCode: |$global:ExitCode|, Output: |$($global:ErrorCodeNames[$global:ExitCode])|, Error: |$turncatedErrorMessage|"
|
||||
}
|
||||
else {
|
||||
Set-Content -Path $CSEResultFilePath -Value $global:ExitCode -Force
|
||||
}
|
||||
Upload-GuestVMLogs -ExitCode $global:ExitCode
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
powershell.exe -ExecutionPolicy Unrestricted -command " $arguments = ' -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 -LogFile %SYSTEMDRIVE%\AzureData\CustomDataSetupScript.log -CSEResultFilePath %SYSTEMDRIVE%\AzureData\provision.complete'; $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; Invoke-Expression('{0} {1}' -f $outputFile, $arguments); "
|
||||
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; }; "
|
|
@ -55,10 +55,6 @@ param(
|
|||
[ValidateNotNullOrEmpty()]
|
||||
$TargetEnvironment,
|
||||
|
||||
[parameter(Mandatory=$true)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
$LogFile,
|
||||
|
||||
# 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
|
||||
|
@ -74,7 +70,7 @@ param(
|
|||
$StartTime=Get-Date
|
||||
$global:ExitCode=0
|
||||
$global:ErrorMessage=""
|
||||
Start-Transcript -Path $LogFile
|
||||
|
||||
# These globals will not change between nodes in the same cluster, so they are not
|
||||
# passed as powershell parameters
|
||||
|
||||
|
@ -225,7 +221,7 @@ $global:OperationId = New-Guid
|
|||
|
||||
try
|
||||
{
|
||||
Logs-To-Event -TaskName "AKS.WindowsCSE.ExecuteCustomDataSetupScript" -TaskMessage ".\CustomDataSetupScript.ps1 -MasterIP $MasterIP -KubeDnsServiceIp $KubeDnsServiceIp -MasterFQDNPrefix $MasterFQDNPrefix -Location $Location -AADClientId $AADClientId -NetworkAPIVersion $NetworkAPIVersion -TargetEnvironment $TargetEnvironment"
|
||||
Logs-To-Event -TaskName "AKS.WindowsCSE.ExecuteCustomDataSetupScript" -TaskMessage ".\CustomDataSetupScript.ps1 -MasterIP $MasterIP -KubeDnsServiceIp $KubeDnsServiceIp -MasterFQDNPrefix $MasterFQDNPrefix -Location $Location -AADClientId $AADClientId -NetworkAPIVersion $NetworkAPIVersion -TargetEnvironment $TargetEnvironment -CSEResultFilePath $CSEResultFilePath"
|
||||
|
||||
# Exit early if the script has been executed
|
||||
if (Test-Path -Path $CSEResultFilePath -PathType Leaf) {
|
||||
|
@ -489,22 +485,19 @@ finally
|
|||
# Generate CSE result so it can be returned as the CSE response in csecmd.ps1
|
||||
$ExecutionDuration=$(New-Timespan -Start $StartTime -End $(Get-Date))
|
||||
Write-Log "CSE ExecutionDuration: $ExecutionDuration. ExitCode: $global:ExitCode"
|
||||
# $CSEResultFilePath is used to avoid running CSE multiple times
|
||||
Set-Content -Path $CSEResultFilePath -Value $global:ExitCode -Force
|
||||
|
||||
Logs-To-Event -TaskName "AKS.WindowsCSE.cse_main" -TaskMessage "ExitCode: $global:ExitCode. ErrorMessage: $global:ErrorMessage."
|
||||
# Please not use Write-Log or Logs-To-Events after Stop-Transcript
|
||||
Stop-Transcript
|
||||
|
||||
# Remove the parameters in the log file to avoid leaking secrets
|
||||
$logs=Get-Content $LogFile | Where-Object {$_ -notmatch "^Host Application: "}
|
||||
$logs | Set-Content $LogFile
|
||||
|
||||
Upload-GuestVMLogs -ExitCode $global:ExitCode
|
||||
# $CSEResultFilePath is used to avoid running CSE multiple times
|
||||
if ($global:ExitCode -ne 0) {
|
||||
# $JsonString = "ExitCode: |{0}|, Output: |{1}|, Error: |{2}|"
|
||||
# Max length of the full error message returned by Windows CSE is ~256. We use 240 to be safe.
|
||||
$errorMessageLength = "ExitCode: |$global:ExitCode|, Output: |$($global:ErrorCodeNames[$global:ExitCode])|, Error: ||".Length
|
||||
$turncatedErrorMessage = $global:ErrorMessage.Substring(0, [Math]::Min(240 - $errorMessageLength, $global:ErrorMessage.Length))
|
||||
throw "ExitCode: |$global:ExitCode|, Output: |$($global:ErrorCodeNames[$global:ExitCode])|, Error: |$turncatedErrorMessage|"
|
||||
Set-Content -Path $CSEResultFilePath -Value "ExitCode: |$global:ExitCode|, Output: |$($global:ErrorCodeNames[$global:ExitCode])|, Error: |$turncatedErrorMessage|"
|
||||
}
|
||||
else {
|
||||
Set-Content -Path $CSEResultFilePath -Value $global:ExitCode -Force
|
||||
}
|
||||
Upload-GuestVMLogs -ExitCode $global:ExitCode
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
powershell.exe -ExecutionPolicy Unrestricted -command " $arguments = ' -MasterIP ''uttestdom-dns-5d7c849e.hcp.southcentralus.azmk8s.io'' -KubeDnsServiceIp ''10.0.0.10'' -MasterFQDNPrefix ''uttestdom'' -Location ''southcentralus'' -UserAssignedClientID ''userAssignedID'' -TargetEnvironment ''AzurePublicCloud'' -AgentKey '''' -AADClientId ''msi'' -AADClientSecret '''' -NetworkAPIVersion 2018-08-01 -LogFile %SYSTEMDRIVE%\AzureData\CustomDataSetupScript.log -CSEResultFilePath %SYSTEMDRIVE%\AzureData\provision.complete'; $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; Invoke-Expression('{0} {1}' -f $outputFile, $arguments); "
|
||||
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'' -UserAssignedClientID ''userAssignedID'' -TargetEnvironment ''AzurePublicCloud'' -AgentKey '''' -AADClientId ''msi'' -AADClientSecret '''' -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; }; "
|
|
@ -55,10 +55,6 @@ param(
|
|||
[ValidateNotNullOrEmpty()]
|
||||
$TargetEnvironment,
|
||||
|
||||
[parameter(Mandatory=$true)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
$LogFile,
|
||||
|
||||
# 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
|
||||
|
@ -74,7 +70,7 @@ param(
|
|||
$StartTime=Get-Date
|
||||
$global:ExitCode=0
|
||||
$global:ErrorMessage=""
|
||||
Start-Transcript -Path $LogFile
|
||||
|
||||
# These globals will not change between nodes in the same cluster, so they are not
|
||||
# passed as powershell parameters
|
||||
|
||||
|
@ -225,7 +221,7 @@ $global:OperationId = New-Guid
|
|||
|
||||
try
|
||||
{
|
||||
Logs-To-Event -TaskName "AKS.WindowsCSE.ExecuteCustomDataSetupScript" -TaskMessage ".\CustomDataSetupScript.ps1 -MasterIP $MasterIP -KubeDnsServiceIp $KubeDnsServiceIp -MasterFQDNPrefix $MasterFQDNPrefix -Location $Location -AADClientId $AADClientId -NetworkAPIVersion $NetworkAPIVersion -TargetEnvironment $TargetEnvironment"
|
||||
Logs-To-Event -TaskName "AKS.WindowsCSE.ExecuteCustomDataSetupScript" -TaskMessage ".\CustomDataSetupScript.ps1 -MasterIP $MasterIP -KubeDnsServiceIp $KubeDnsServiceIp -MasterFQDNPrefix $MasterFQDNPrefix -Location $Location -AADClientId $AADClientId -NetworkAPIVersion $NetworkAPIVersion -TargetEnvironment $TargetEnvironment -CSEResultFilePath $CSEResultFilePath"
|
||||
|
||||
# Exit early if the script has been executed
|
||||
if (Test-Path -Path $CSEResultFilePath -PathType Leaf) {
|
||||
|
@ -489,22 +485,19 @@ finally
|
|||
# Generate CSE result so it can be returned as the CSE response in csecmd.ps1
|
||||
$ExecutionDuration=$(New-Timespan -Start $StartTime -End $(Get-Date))
|
||||
Write-Log "CSE ExecutionDuration: $ExecutionDuration. ExitCode: $global:ExitCode"
|
||||
# $CSEResultFilePath is used to avoid running CSE multiple times
|
||||
Set-Content -Path $CSEResultFilePath -Value $global:ExitCode -Force
|
||||
|
||||
Logs-To-Event -TaskName "AKS.WindowsCSE.cse_main" -TaskMessage "ExitCode: $global:ExitCode. ErrorMessage: $global:ErrorMessage."
|
||||
# Please not use Write-Log or Logs-To-Events after Stop-Transcript
|
||||
Stop-Transcript
|
||||
|
||||
# Remove the parameters in the log file to avoid leaking secrets
|
||||
$logs=Get-Content $LogFile | Where-Object {$_ -notmatch "^Host Application: "}
|
||||
$logs | Set-Content $LogFile
|
||||
|
||||
Upload-GuestVMLogs -ExitCode $global:ExitCode
|
||||
# $CSEResultFilePath is used to avoid running CSE multiple times
|
||||
if ($global:ExitCode -ne 0) {
|
||||
# $JsonString = "ExitCode: |{0}|, Output: |{1}|, Error: |{2}|"
|
||||
# Max length of the full error message returned by Windows CSE is ~256. We use 240 to be safe.
|
||||
$errorMessageLength = "ExitCode: |$global:ExitCode|, Output: |$($global:ErrorCodeNames[$global:ExitCode])|, Error: ||".Length
|
||||
$turncatedErrorMessage = $global:ErrorMessage.Substring(0, [Math]::Min(240 - $errorMessageLength, $global:ErrorMessage.Length))
|
||||
throw "ExitCode: |$global:ExitCode|, Output: |$($global:ErrorCodeNames[$global:ExitCode])|, Error: |$turncatedErrorMessage|"
|
||||
Set-Content -Path $CSEResultFilePath -Value "ExitCode: |$global:ExitCode|, Output: |$($global:ErrorCodeNames[$global:ExitCode])|, Error: |$turncatedErrorMessage|"
|
||||
}
|
||||
else {
|
||||
Set-Content -Path $CSEResultFilePath -Value $global:ExitCode -Force
|
||||
}
|
||||
Upload-GuestVMLogs -ExitCode $global:ExitCode
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
powershell.exe -ExecutionPolicy Unrestricted -command " $arguments = ' -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 -LogFile %SYSTEMDRIVE%\AzureData\CustomDataSetupScript.log -CSEResultFilePath %SYSTEMDRIVE%\AzureData\provision.complete'; $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; Invoke-Expression('{0} {1}' -f $outputFile, $arguments); "
|
||||
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; }; "
|
|
@ -55,10 +55,6 @@ param(
|
|||
[ValidateNotNullOrEmpty()]
|
||||
$TargetEnvironment,
|
||||
|
||||
[parameter(Mandatory=$true)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
$LogFile,
|
||||
|
||||
# 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
|
||||
|
@ -74,7 +70,7 @@ param(
|
|||
$StartTime=Get-Date
|
||||
$global:ExitCode=0
|
||||
$global:ErrorMessage=""
|
||||
Start-Transcript -Path $LogFile
|
||||
|
||||
# These globals will not change between nodes in the same cluster, so they are not
|
||||
# passed as powershell parameters
|
||||
|
||||
|
@ -225,7 +221,7 @@ $global:OperationId = New-Guid
|
|||
|
||||
try
|
||||
{
|
||||
Logs-To-Event -TaskName "AKS.WindowsCSE.ExecuteCustomDataSetupScript" -TaskMessage ".\CustomDataSetupScript.ps1 -MasterIP $MasterIP -KubeDnsServiceIp $KubeDnsServiceIp -MasterFQDNPrefix $MasterFQDNPrefix -Location $Location -AADClientId $AADClientId -NetworkAPIVersion $NetworkAPIVersion -TargetEnvironment $TargetEnvironment"
|
||||
Logs-To-Event -TaskName "AKS.WindowsCSE.ExecuteCustomDataSetupScript" -TaskMessage ".\CustomDataSetupScript.ps1 -MasterIP $MasterIP -KubeDnsServiceIp $KubeDnsServiceIp -MasterFQDNPrefix $MasterFQDNPrefix -Location $Location -AADClientId $AADClientId -NetworkAPIVersion $NetworkAPIVersion -TargetEnvironment $TargetEnvironment -CSEResultFilePath $CSEResultFilePath"
|
||||
|
||||
# Exit early if the script has been executed
|
||||
if (Test-Path -Path $CSEResultFilePath -PathType Leaf) {
|
||||
|
@ -489,22 +485,19 @@ finally
|
|||
# Generate CSE result so it can be returned as the CSE response in csecmd.ps1
|
||||
$ExecutionDuration=$(New-Timespan -Start $StartTime -End $(Get-Date))
|
||||
Write-Log "CSE ExecutionDuration: $ExecutionDuration. ExitCode: $global:ExitCode"
|
||||
# $CSEResultFilePath is used to avoid running CSE multiple times
|
||||
Set-Content -Path $CSEResultFilePath -Value $global:ExitCode -Force
|
||||
|
||||
Logs-To-Event -TaskName "AKS.WindowsCSE.cse_main" -TaskMessage "ExitCode: $global:ExitCode. ErrorMessage: $global:ErrorMessage."
|
||||
# Please not use Write-Log or Logs-To-Events after Stop-Transcript
|
||||
Stop-Transcript
|
||||
|
||||
# Remove the parameters in the log file to avoid leaking secrets
|
||||
$logs=Get-Content $LogFile | Where-Object {$_ -notmatch "^Host Application: "}
|
||||
$logs | Set-Content $LogFile
|
||||
|
||||
Upload-GuestVMLogs -ExitCode $global:ExitCode
|
||||
# $CSEResultFilePath is used to avoid running CSE multiple times
|
||||
if ($global:ExitCode -ne 0) {
|
||||
# $JsonString = "ExitCode: |{0}|, Output: |{1}|, Error: |{2}|"
|
||||
# Max length of the full error message returned by Windows CSE is ~256. We use 240 to be safe.
|
||||
$errorMessageLength = "ExitCode: |$global:ExitCode|, Output: |$($global:ErrorCodeNames[$global:ExitCode])|, Error: ||".Length
|
||||
$turncatedErrorMessage = $global:ErrorMessage.Substring(0, [Math]::Min(240 - $errorMessageLength, $global:ErrorMessage.Length))
|
||||
throw "ExitCode: |$global:ExitCode|, Output: |$($global:ErrorCodeNames[$global:ExitCode])|, Error: |$turncatedErrorMessage|"
|
||||
Set-Content -Path $CSEResultFilePath -Value "ExitCode: |$global:ExitCode|, Output: |$($global:ErrorCodeNames[$global:ExitCode])|, Error: |$turncatedErrorMessage|"
|
||||
}
|
||||
else {
|
||||
Set-Content -Path $CSEResultFilePath -Value $global:ExitCode -Force
|
||||
}
|
||||
Upload-GuestVMLogs -ExitCode $global:ExitCode
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
powershell.exe -ExecutionPolicy Unrestricted -command " $arguments = ' -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 -LogFile %SYSTEMDRIVE%\AzureData\CustomDataSetupScript.log -CSEResultFilePath %SYSTEMDRIVE%\AzureData\provision.complete'; $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; Invoke-Expression('{0} {1}' -f $outputFile, $arguments); "
|
||||
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; }; "
|
|
@ -55,10 +55,6 @@ param(
|
|||
[ValidateNotNullOrEmpty()]
|
||||
$TargetEnvironment,
|
||||
|
||||
[parameter(Mandatory=$true)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
$LogFile,
|
||||
|
||||
# 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
|
||||
|
@ -74,7 +70,7 @@ param(
|
|||
$StartTime=Get-Date
|
||||
$global:ExitCode=0
|
||||
$global:ErrorMessage=""
|
||||
Start-Transcript -Path $LogFile
|
||||
|
||||
# These globals will not change between nodes in the same cluster, so they are not
|
||||
# passed as powershell parameters
|
||||
|
||||
|
@ -225,7 +221,7 @@ $global:OperationId = New-Guid
|
|||
|
||||
try
|
||||
{
|
||||
Logs-To-Event -TaskName "AKS.WindowsCSE.ExecuteCustomDataSetupScript" -TaskMessage ".\CustomDataSetupScript.ps1 -MasterIP $MasterIP -KubeDnsServiceIp $KubeDnsServiceIp -MasterFQDNPrefix $MasterFQDNPrefix -Location $Location -AADClientId $AADClientId -NetworkAPIVersion $NetworkAPIVersion -TargetEnvironment $TargetEnvironment"
|
||||
Logs-To-Event -TaskName "AKS.WindowsCSE.ExecuteCustomDataSetupScript" -TaskMessage ".\CustomDataSetupScript.ps1 -MasterIP $MasterIP -KubeDnsServiceIp $KubeDnsServiceIp -MasterFQDNPrefix $MasterFQDNPrefix -Location $Location -AADClientId $AADClientId -NetworkAPIVersion $NetworkAPIVersion -TargetEnvironment $TargetEnvironment -CSEResultFilePath $CSEResultFilePath"
|
||||
|
||||
# Exit early if the script has been executed
|
||||
if (Test-Path -Path $CSEResultFilePath -PathType Leaf) {
|
||||
|
@ -489,22 +485,19 @@ finally
|
|||
# Generate CSE result so it can be returned as the CSE response in csecmd.ps1
|
||||
$ExecutionDuration=$(New-Timespan -Start $StartTime -End $(Get-Date))
|
||||
Write-Log "CSE ExecutionDuration: $ExecutionDuration. ExitCode: $global:ExitCode"
|
||||
# $CSEResultFilePath is used to avoid running CSE multiple times
|
||||
Set-Content -Path $CSEResultFilePath -Value $global:ExitCode -Force
|
||||
|
||||
Logs-To-Event -TaskName "AKS.WindowsCSE.cse_main" -TaskMessage "ExitCode: $global:ExitCode. ErrorMessage: $global:ErrorMessage."
|
||||
# Please not use Write-Log or Logs-To-Events after Stop-Transcript
|
||||
Stop-Transcript
|
||||
|
||||
# Remove the parameters in the log file to avoid leaking secrets
|
||||
$logs=Get-Content $LogFile | Where-Object {$_ -notmatch "^Host Application: "}
|
||||
$logs | Set-Content $LogFile
|
||||
|
||||
Upload-GuestVMLogs -ExitCode $global:ExitCode
|
||||
# $CSEResultFilePath is used to avoid running CSE multiple times
|
||||
if ($global:ExitCode -ne 0) {
|
||||
# $JsonString = "ExitCode: |{0}|, Output: |{1}|, Error: |{2}|"
|
||||
# Max length of the full error message returned by Windows CSE is ~256. We use 240 to be safe.
|
||||
$errorMessageLength = "ExitCode: |$global:ExitCode|, Output: |$($global:ErrorCodeNames[$global:ExitCode])|, Error: ||".Length
|
||||
$turncatedErrorMessage = $global:ErrorMessage.Substring(0, [Math]::Min(240 - $errorMessageLength, $global:ErrorMessage.Length))
|
||||
throw "ExitCode: |$global:ExitCode|, Output: |$($global:ErrorCodeNames[$global:ExitCode])|, Error: |$turncatedErrorMessage|"
|
||||
Set-Content -Path $CSEResultFilePath -Value "ExitCode: |$global:ExitCode|, Output: |$($global:ErrorCodeNames[$global:ExitCode])|, Error: |$turncatedErrorMessage|"
|
||||
}
|
||||
else {
|
||||
Set-Content -Path $CSEResultFilePath -Value $global:ExitCode -Force
|
||||
}
|
||||
Upload-GuestVMLogs -ExitCode $global:ExitCode
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче