Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
junjiezhang1997 committed Jan 5, 2024
1 parent 67c5b49 commit 7eb1dee
Show file tree
Hide file tree
Showing 27 changed files with 309 additions and 89 deletions.
25 changes: 1 addition & 24 deletions parts/windows/csecmd.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
$cseStartTime=$(Get-Date);
$cseFormattedStartTime=$(Get-Date -Format "yyyy-mm-dd HH:mm:ss.fff");
powershell.exe -ExecutionPolicy Unrestricted -command \"
$arguments = '
-MasterIP ''{{ GetKubernetesEndpoint }}''
Expand All @@ -21,25 +19,4 @@ $outputFile = '%SYSTEMDRIVE%\AzureData\CustomDataSetupScript.ps1';
if (!(Test-Path $inputFile)) { echo 49 | Out-File -FilePath '%SYSTEMDRIVE%\AzureData\CSEResult.log' -Encoding utf8; exit; };
Copy-Item $inputFile $outputFile;
Invoke-Expression('{0} {1}' -f $outputFile, $arguments);
\" >> %SYSTEMDRIVE%\AzureData\CustomDataSetupScript.log 2>&1;
if (!(Test-Path %SYSTEMDRIVE%\AzureData\CSEResult.log)) { exit 50; };
$code=(Get-Content %SYSTEMDRIVE%\AzureData\CSEResult.log);
$cseFormattedEndTime=$(Get-Date -Format "yyyy-mm-dd HH:mm:ss.fff");
$eventsLoggingDir="C:\WindowsAzure\Logs\Plugins\Microsoft.Compute.CustomScriptExtension\Events\";
$eventsFileName=[DateTimeOffset]::UtcNow.ToUnixTimeMilliseconds();
$executionDuration=[int]$($(Get-Date -UFormat "%s") - $(Get-Date -Date $cseStartTime -UFormat "%s"));
$messageString="ExitCode:$code, E2E: $executionDuration";
$eventJson=@"
{
"Timestamp": "$cseFormattedStartTime",
"OperationId": "$cseFormattedEndTime",
"Version": "1.23",
"TaskName": "AKS.WindowsCSE.cse_start",
"EventLevel": "Informational",
"Message": "$messageString",
"EventPid": "0",
"EventTid": "0"
}
"@;
echo $eventJson | Set-Content ${eventsLoggingDir}${eventsFileName}.json;
exit $code
\" >> %SYSTEMDRIVE%\AzureData\CustomDataSetupScript.log 2>&1; if (!(Test-Path %SYSTEMDRIVE%\AzureData\CSEResult.log)) { exit 50; }; $code=(Get-Content %SYSTEMDRIVE%\AzureData\CSEResult.log); exit $code
23 changes: 21 additions & 2 deletions parts/windows/kuberneteswindowssetup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ param(
)
# Do not parse the start time from $LogFile to simplify the logic
$StartTime=Get-Date
$cseFormattedStartTime=$(Get-Date -Format "yyyy-mm-dd HH:mm:ss.fff")
$global:ExitCode=0
$global:ErrorMessage=""

Expand Down Expand Up @@ -157,8 +158,8 @@ $global:AzureCNIConfDir = [Io.path]::Combine("$global:AzureCNIDir", "netconf")
# $global:NetworkPolicy = "{{GetParameter "networkPolicy"}}" # BUG: unused
$global:NetworkPlugin = "{{GetParameter "networkPlugin"}}"
$global:VNetCNIPluginsURL = "{{GetParameter "vnetCniWindowsPluginsURL"}}"
$global:IsDualStackEnabled = {{if IsIPv6DualStackFeatureEnabled}}$true{{else}}$false{{end}}
$global:IsAzureCNIOverlayEnabled = {{if IsAzureCNIOverlayFeatureEnabled}}$true{{else}}$false{{end}}
$global:IsDualStackEnabled = {{if IsIPv6DualStackFeatureEnabled}}1{{else}}0{{end}}
$global:IsAzureCNIOverlayEnabled = {{if IsAzureCNIOverlayFeatureEnabled}}1{{else}}0{{end}}

# CSI Proxy settings
$global:EnableCsiProxy = [System.Convert]::ToBoolean("{{GetVariable "windowsEnableCSIProxy" }}");
Expand Down Expand Up @@ -511,13 +512,31 @@ finally
{
# Generate CSE result so it can be returned as the CSE response in csecmd.ps1
$ExecutionDuration=$(New-Timespan -Start $StartTime -End $(Get-Date))
$cseFormattedEndTime=$(Get-Date -Format "yyyy-mm-dd HH:mm:ss.fff")
$eventsFileName=[DateTimeOffset]::UtcNow.ToUnixTimeMilliseconds()

Write-Log "CSE ExecutionDuration: $ExecutionDuration"

# Windows CSE does not return any error message so we cannot generate below content as the response
# $JsonString = "ExitCode: `"{0}`", Output: `"{1}`", Error: `"{2}`", ExecDuration: `"{3}`"" -f $global:ExitCode, "", $global:ErrorMessage, $ExecutionDuration.TotalSeconds
Write-Log "Generate CSE result to $CSEResultFilePath : $global:ExitCode"
echo $global:ExitCode | Out-File -FilePath $CSEResultFilePath -Encoding utf8

$messageString="ExitCode: $global:ExitCode, E2E: $ExecutionDuration";
$eventJson=@"
{
"Timestamp": "$cseFormattedStartTime",
"OperationId": "$cseFormattedEndTime",
"Version": "1.23",
"TaskName": "AKS.WindowsCSE.cse_start",
"EventLevel": "Informational",
"Message": "$messageString",
"EventPid": "0",
"EventTid": "0"
}
"@
echo $eventJson | Set-Content ${global:EventsLoggingDir}${eventsFileName}.json

# Flush stdout to C:\AzureData\CustomDataSetupScript.log
[Console]::Out.Flush()

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 @@
$cseStartTime=$(Get-Date); $cseFormattedStartTime=$(Get-Date -Format "yyyy-mm-dd HH:mm:ss.fff"); 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\CSEResult.log'; $inputFile = '%SYSTEMDRIVE%\AzureData\CustomData.bin'; $outputFile = '%SYSTEMDRIVE%\AzureData\CustomDataSetupScript.ps1'; if (!(Test-Path $inputFile)) { echo 49 | Out-File -FilePath '%SYSTEMDRIVE%\AzureData\CSEResult.log' -Encoding utf8; exit; }; Copy-Item $inputFile $outputFile; Invoke-Expression('{0} {1}' -f $outputFile, $arguments); " >> %SYSTEMDRIVE%\AzureData\CustomDataSetupScript.log 2>&1; if (!(Test-Path %SYSTEMDRIVE%\AzureData\CSEResult.log)) { exit 50; }; $code=(Get-Content %SYSTEMDRIVE%\AzureData\CSEResult.log); $cseFormattedEndTime=$(Get-Date -Format "yyyy-mm-dd HH:mm:ss.fff"); $eventsLoggingDir="C:\WindowsAzure\Logs\Plugins\Microsoft.Compute.CustomScriptExtension\Events"; $eventsFileName=[DateTimeOffset]::UtcNow.ToUnixTimeMilliseconds(); $executionDuration=[int]$($(Get-Date -UFormat "%s") - $(Get-Date -Date $cseStartTime -UFormat "%s")); $messageString="ExitCode:$code, E2E: $executionDuration"; $eventJson=@" { "Timestamp": "$cseFormattedStartTime", "OperationId": "$cseFormattedEndTime", "Version": "1.23", "TaskName": "AKS.WindowsCSE.cse_start", "EventLevel": "Informational", "Message": "$messageString", "EventPid": "0", "EventTid": "0" } "@; echo $eventJson | Set-Content ${eventsLoggingDir}${eventsFileName}.json; exit $code
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\CSEResult.log'; $inputFile = '%SYSTEMDRIVE%\AzureData\CustomData.bin'; $outputFile = '%SYSTEMDRIVE%\AzureData\CustomDataSetupScript.ps1'; if (!(Test-Path $inputFile)) { echo 49 | Out-File -FilePath '%SYSTEMDRIVE%\AzureData\CSEResult.log' -Encoding utf8; exit; }; Copy-Item $inputFile $outputFile; Invoke-Expression('{0} {1}' -f $outputFile, $arguments); " >> %SYSTEMDRIVE%\AzureData\CustomDataSetupScript.log 2>&1; if (!(Test-Path %SYSTEMDRIVE%\AzureData\CSEResult.log)) { exit 50; }; $code=(Get-Content %SYSTEMDRIVE%\AzureData\CSEResult.log); exit $code
23 changes: 21 additions & 2 deletions pkg/agent/testdata/AKSWindows2019+CustomCloud/CustomData
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ param(
)
# Do not parse the start time from $LogFile to simplify the logic
$StartTime=Get-Date
$cseFormattedStartTime=$(Get-Date -Format "yyyy-mm-dd HH:mm:ss.fff")
$global:ExitCode=0
$global:ErrorMessage=""

Expand Down Expand Up @@ -153,8 +154,8 @@ $global:AzureCNIConfDir = [Io.path]::Combine("$global:AzureCNIDir", "netconf")
# $global:NetworkPolicy = "" # BUG: unused
$global:NetworkPlugin = "azure"
$global:VNetCNIPluginsURL = "https://acs-mirror.azureedge.net/azure-cni/v1.1.3/binaries/azure-vnet-cni-singletenancy-windows-amd64-v1.1.3.zip"
$global:IsDualStackEnabled = $false
$global:IsAzureCNIOverlayEnabled = $false
$global:IsDualStackEnabled = 0
$global:IsAzureCNIOverlayEnabled = 0

# CSI Proxy settings
$global:EnableCsiProxy = [System.Convert]::ToBoolean("false");
Expand Down Expand Up @@ -507,13 +508,31 @@ finally
{
# Generate CSE result so it can be returned as the CSE response in csecmd.ps1
$ExecutionDuration=$(New-Timespan -Start $StartTime -End $(Get-Date))
$cseFormattedEndTime=$(Get-Date -Format "yyyy-mm-dd HH:mm:ss.fff")
$eventsFileName=[DateTimeOffset]::UtcNow.ToUnixTimeMilliseconds()

Write-Log "CSE ExecutionDuration: $ExecutionDuration"

# Windows CSE does not return any error message so we cannot generate below content as the response
# $JsonString = "ExitCode: `"{0}`", Output: `"{1}`", Error: `"{2}`", ExecDuration: `"{3}`"" -f $global:ExitCode, "", $global:ErrorMessage, $ExecutionDuration.TotalSeconds
Write-Log "Generate CSE result to $CSEResultFilePath : $global:ExitCode"
echo $global:ExitCode | Out-File -FilePath $CSEResultFilePath -Encoding utf8

$messageString="ExitCode: $global:ExitCode, E2E: $ExecutionDuration";
$eventJson=@"
{
"Timestamp": "$cseFormattedStartTime",
"OperationId": "$cseFormattedEndTime",
"Version": "1.23",
"TaskName": "AKS.WindowsCSE.cse_start",
"EventLevel": "Informational",
"Message": "$messageString",
"EventPid": "0",
"EventTid": "0"
}
"@
echo $eventJson | Set-Content ${global:EventsLoggingDir}${eventsFileName}.json

# Flush stdout to C:\AzureData\CustomDataSetupScript.log
[Console]::Out.Flush()

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 @@
$cseStartTime=$(Get-Date); $cseFormattedStartTime=$(Get-Date -Format "yyyy-mm-dd HH:mm:ss.fff"); 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\CSEResult.log'; $inputFile = '%SYSTEMDRIVE%\AzureData\CustomData.bin'; $outputFile = '%SYSTEMDRIVE%\AzureData\CustomDataSetupScript.ps1'; if (!(Test-Path $inputFile)) { echo 49 | Out-File -FilePath '%SYSTEMDRIVE%\AzureData\CSEResult.log' -Encoding utf8; exit; }; Copy-Item $inputFile $outputFile; Invoke-Expression('{0} {1}' -f $outputFile, $arguments); " >> %SYSTEMDRIVE%\AzureData\CustomDataSetupScript.log 2>&1; if (!(Test-Path %SYSTEMDRIVE%\AzureData\CSEResult.log)) { exit 50; }; $code=(Get-Content %SYSTEMDRIVE%\AzureData\CSEResult.log); $cseFormattedEndTime=$(Get-Date -Format "yyyy-mm-dd HH:mm:ss.fff"); $eventsLoggingDir="C:\WindowsAzure\Logs\Plugins\Microsoft.Compute.CustomScriptExtension\Events"; $eventsFileName=[DateTimeOffset]::UtcNow.ToUnixTimeMilliseconds(); $executionDuration=[int]$($(Get-Date -UFormat "%s") - $(Get-Date -Date $cseStartTime -UFormat "%s")); $messageString="ExitCode:$code, E2E: $executionDuration"; $eventJson=@" { "Timestamp": "$cseFormattedStartTime", "OperationId": "$cseFormattedEndTime", "Version": "1.23", "TaskName": "AKS.WindowsCSE.cse_start", "EventLevel": "Informational", "Message": "$messageString", "EventPid": "0", "EventTid": "0" } "@; echo $eventJson | Set-Content ${eventsLoggingDir}${eventsFileName}.json; exit $code
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\CSEResult.log'; $inputFile = '%SYSTEMDRIVE%\AzureData\CustomData.bin'; $outputFile = '%SYSTEMDRIVE%\AzureData\CustomDataSetupScript.ps1'; if (!(Test-Path $inputFile)) { echo 49 | Out-File -FilePath '%SYSTEMDRIVE%\AzureData\CSEResult.log' -Encoding utf8; exit; }; Copy-Item $inputFile $outputFile; Invoke-Expression('{0} {1}' -f $outputFile, $arguments); " >> %SYSTEMDRIVE%\AzureData\CustomDataSetupScript.log 2>&1; if (!(Test-Path %SYSTEMDRIVE%\AzureData\CSEResult.log)) { exit 50; }; $code=(Get-Content %SYSTEMDRIVE%\AzureData\CSEResult.log); exit $code
23 changes: 21 additions & 2 deletions pkg/agent/testdata/AKSWindows2019+CustomVnet/CustomData
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ param(
)
# Do not parse the start time from $LogFile to simplify the logic
$StartTime=Get-Date
$cseFormattedStartTime=$(Get-Date -Format "yyyy-mm-dd HH:mm:ss.fff")
$global:ExitCode=0
$global:ErrorMessage=""

Expand Down Expand Up @@ -153,8 +154,8 @@ $global:AzureCNIConfDir = [Io.path]::Combine("$global:AzureCNIDir", "netconf")
# $global:NetworkPolicy = "" # BUG: unused
$global:NetworkPlugin = "azure"
$global:VNetCNIPluginsURL = "https://acs-mirror.azureedge.net/azure-cni/v1.1.3/binaries/azure-vnet-cni-singletenancy-windows-amd64-v1.1.3.zip"
$global:IsDualStackEnabled = $false
$global:IsAzureCNIOverlayEnabled = $false
$global:IsDualStackEnabled = 0
$global:IsAzureCNIOverlayEnabled = 0

# CSI Proxy settings
$global:EnableCsiProxy = [System.Convert]::ToBoolean("false");
Expand Down Expand Up @@ -501,13 +502,31 @@ finally
{
# Generate CSE result so it can be returned as the CSE response in csecmd.ps1
$ExecutionDuration=$(New-Timespan -Start $StartTime -End $(Get-Date))
$cseFormattedEndTime=$(Get-Date -Format "yyyy-mm-dd HH:mm:ss.fff")
$eventsFileName=[DateTimeOffset]::UtcNow.ToUnixTimeMilliseconds()

Write-Log "CSE ExecutionDuration: $ExecutionDuration"

# Windows CSE does not return any error message so we cannot generate below content as the response
# $JsonString = "ExitCode: `"{0}`", Output: `"{1}`", Error: `"{2}`", ExecDuration: `"{3}`"" -f $global:ExitCode, "", $global:ErrorMessage, $ExecutionDuration.TotalSeconds
Write-Log "Generate CSE result to $CSEResultFilePath : $global:ExitCode"
echo $global:ExitCode | Out-File -FilePath $CSEResultFilePath -Encoding utf8

$messageString="ExitCode: $global:ExitCode, E2E: $ExecutionDuration";
$eventJson=@"
{
"Timestamp": "$cseFormattedStartTime",
"OperationId": "$cseFormattedEndTime",
"Version": "1.23",
"TaskName": "AKS.WindowsCSE.cse_start",
"EventLevel": "Informational",
"Message": "$messageString",
"EventPid": "0",
"EventTid": "0"
}
"@
echo $eventJson | Set-Content ${global:EventsLoggingDir}${eventsFileName}.json

# Flush stdout to C:\AzureData\CustomDataSetupScript.log
[Console]::Out.Flush()

Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
$cseStartTime=$(Get-Date); $cseFormattedStartTime=$(Get-Date -Format "yyyy-mm-dd HH:mm:ss.fff"); 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\CSEResult.log'; $inputFile = '%SYSTEMDRIVE%\AzureData\CustomData.bin'; $outputFile = '%SYSTEMDRIVE%\AzureData\CustomDataSetupScript.ps1'; if (!(Test-Path $inputFile)) { echo 49 | Out-File -FilePath '%SYSTEMDRIVE%\AzureData\CSEResult.log' -Encoding utf8; exit; }; Copy-Item $inputFile $outputFile; Invoke-Expression('{0} {1}' -f $outputFile, $arguments); " >> %SYSTEMDRIVE%\AzureData\CustomDataSetupScript.log 2>&1; if (!(Test-Path %SYSTEMDRIVE%\AzureData\CSEResult.log)) { exit 50; }; $code=(Get-Content %SYSTEMDRIVE%\AzureData\CSEResult.log); $cseFormattedEndTime=$(Get-Date -Format "yyyy-mm-dd HH:mm:ss.fff"); $eventsLoggingDir="C:\WindowsAzure\Logs\Plugins\Microsoft.Compute.CustomScriptExtension\Events"; $eventsFileName=[DateTimeOffset]::UtcNow.ToUnixTimeMilliseconds(); $executionDuration=[int]$($(Get-Date -UFormat "%s") - $(Get-Date -Date $cseStartTime -UFormat "%s")); $messageString="ExitCode:$code, E2E: $executionDuration"; $eventJson=@" { "Timestamp": "$cseFormattedStartTime", "OperationId": "$cseFormattedEndTime", "Version": "1.23", "TaskName": "AKS.WindowsCSE.cse_start", "EventLevel": "Informational", "Message": "$messageString", "EventPid": "0", "EventTid": "0" } "@; echo $eventJson | Set-Content ${eventsLoggingDir}${eventsFileName}.json; exit $code
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\CSEResult.log'; $inputFile = '%SYSTEMDRIVE%\AzureData\CustomData.bin'; $outputFile = '%SYSTEMDRIVE%\AzureData\CustomDataSetupScript.ps1'; if (!(Test-Path $inputFile)) { echo 49 | Out-File -FilePath '%SYSTEMDRIVE%\AzureData\CSEResult.log' -Encoding utf8; exit; }; Copy-Item $inputFile $outputFile; Invoke-Expression('{0} {1}' -f $outputFile, $arguments); " >> %SYSTEMDRIVE%\AzureData\CustomDataSetupScript.log 2>&1; if (!(Test-Path %SYSTEMDRIVE%\AzureData\CSEResult.log)) { exit 50; }; $code=(Get-Content %SYSTEMDRIVE%\AzureData\CSEResult.log); exit $code
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ param(
)
# Do not parse the start time from $LogFile to simplify the logic
$StartTime=Get-Date
$cseFormattedStartTime=$(Get-Date -Format "yyyy-mm-dd HH:mm:ss.fff")
$global:ExitCode=0
$global:ErrorMessage=""

Expand Down Expand Up @@ -153,8 +154,8 @@ $global:AzureCNIConfDir = [Io.path]::Combine("$global:AzureCNIDir", "netconf")
# $global:NetworkPolicy = "" # BUG: unused
$global:NetworkPlugin = "azure"
$global:VNetCNIPluginsURL = "https://acs-mirror.azureedge.net/azure-cni/v1.1.3/binaries/azure-vnet-cni-singletenancy-windows-amd64-v1.1.3.zip"
$global:IsDualStackEnabled = $false
$global:IsAzureCNIOverlayEnabled = $false
$global:IsDualStackEnabled = 0
$global:IsAzureCNIOverlayEnabled = 0

# CSI Proxy settings
$global:EnableCsiProxy = [System.Convert]::ToBoolean("false");
Expand Down Expand Up @@ -501,13 +502,31 @@ finally
{
# Generate CSE result so it can be returned as the CSE response in csecmd.ps1
$ExecutionDuration=$(New-Timespan -Start $StartTime -End $(Get-Date))
$cseFormattedEndTime=$(Get-Date -Format "yyyy-mm-dd HH:mm:ss.fff")
$eventsFileName=[DateTimeOffset]::UtcNow.ToUnixTimeMilliseconds()

Write-Log "CSE ExecutionDuration: $ExecutionDuration"

# Windows CSE does not return any error message so we cannot generate below content as the response
# $JsonString = "ExitCode: `"{0}`", Output: `"{1}`", Error: `"{2}`", ExecDuration: `"{3}`"" -f $global:ExitCode, "", $global:ErrorMessage, $ExecutionDuration.TotalSeconds
Write-Log "Generate CSE result to $CSEResultFilePath : $global:ExitCode"
echo $global:ExitCode | Out-File -FilePath $CSEResultFilePath -Encoding utf8

$messageString="ExitCode: $global:ExitCode, E2E: $ExecutionDuration";
$eventJson=@"
{
"Timestamp": "$cseFormattedStartTime",
"OperationId": "$cseFormattedEndTime",
"Version": "1.23",
"TaskName": "AKS.WindowsCSE.cse_start",
"EventLevel": "Informational",
"Message": "$messageString",
"EventPid": "0",
"EventTid": "0"
}
"@
echo $eventJson | Set-Content ${global:EventsLoggingDir}${eventsFileName}.json

# Flush stdout to C:\AzureData\CustomDataSetupScript.log
[Console]::Out.Flush()

Expand Down
Loading

0 comments on commit 7eb1dee

Please sign in to comment.