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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ function xharness() {
function report_infrastructure_failure($message) {
Comment thread
premun marked this conversation as resolved.
Write-Output "Infrastructural problem reported by the user, requesting retry+reboot: $message"

& "$Env:HELIX_PYTHONPATH" -c "from helix.workitemutil import request_infra_retry; request_infra_retry('Retrying because we could not enumerate all Android devices')"
& "$Env:HELIX_PYTHONPATH" -c "from helix.workitemutil import request_reboot; request_reboot('Rebooting to allow Android emulator or device to restart')"
New-Item -Path "$Env:HELIX_WORKITEM_ROOT" -Name ".retry" -ItemType "file" -Force
New-Item -Path "$Env:HELIX_WORKITEM_ROOT" -Name ".reboot" -ItemType "file" -Force

$message | Out-File -FilePath "$Env:HELIX_WORKITEM_ROOT\.retry"
$message | Out-File -FilePath "$Env:HELIX_WORKITEM_ROOT\.reboot"
}

Original file line number Diff line number Diff line change
Expand Up @@ -52,35 +52,53 @@ if ($ev) {
Write-Output "User command ended with $exit_code"
}

$retry=$false
$reboot=$false
$retry = $false
$reboot = $false

switch ($exit_code)
{
# ADB_DEVICE_ENUMERATION_FAILURE
85 {
Write-Error "Encountered ADB_DEVICE_ENUMERATION_FAILURE. This is typically not a failure of the work item. We will run it again and reboot this computer to help its devices"
Write-Error "If this occurs repeatedly, please check for architectural mismatch, e.g. sending x86 or x86_64 APKs to an arm64_v8a-only queue."
$retry=$true
$reboot=$true
$retry = $true
$reboot = $true
Break
}

# PACKAGE_INSTALLATION_FAILURE
78 {
Write-Error "Encountered PACKAGE_INSTALLATION_FAILURE. This is typically not a failure of the work item. We will try it again on another Helix agent"
Write-Error "If this occurs repeatedly, please check for architectural mismatch, e.g. requesting installation on arm64_v8a-only queue for x86 or x86_64 APKs."
$retry=$true
$retry = $true
Break
}
}

if (Test-Path -Path "$Env:HELIX_WORKITEM_ROOT\.retry" -PathType Leaf) {
$retry = $true;
$retry_message = Get-Content -Path "$Env:HELIX_WORKITEM_ROOT\.retry"
}

if (Test-Path -Path "$Env:HELIX_WORKITEM_ROOT\.reboot" -PathType Leaf) {
$reboot = $true;
$reboot_message = Get-Content -Path "$Env:HELIX_WORKITEM_ROOT\.reboot"
}

if ($retry) {
& "$Env:HELIX_PYTHONPATH" -c "from helix.workitemutil import request_infra_retry; request_infra_retry('Retrying because we could not enumerate all Android devices')"
if ([string]::IsNullOrEmpty($retry_message)) {
$retry_message = 'Retrying because we could not enumerate all Android devices'
}

& "$Env:HELIX_PYTHONPATH" -c "from helix.workitemutil import request_infra_retry; request_infra_retry('$retry_message')"
Comment thread
premun marked this conversation as resolved.
}

if ($reboot) {
& "$Env:HELIX_PYTHONPATH" -c "from helix.workitemutil import request_reboot; request_reboot('Rebooting to allow Android emulator or device to restart')"
if ([string]::IsNullOrEmpty($reboot_message)) {
$reboot_message = 'Rebooting to allow Android emulator to restart'
}

& "$Env:HELIX_PYTHONPATH" -c "from helix.workitemutil import request_reboot; request_reboot('$reboot_message')"
}

exit $exit_code
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ function xharness() {
dotnet exec $XHARNESS_CLI_PATH "$@"
}

function report_infrastructure_failure() {
echo "Infrastructural problem reported by the user, requesting retry+reboot: $1"

echo "$1" > "$HELIX_WORKITEM_ROOT/.retry"
echo "$1" > "$HELIX_WORKITEM_ROOT/.reboot"
}

# Act out the actual commands (and time constrain them to create buffer for the end of this script)
source command.sh & PID=$! ; (sleep $command_timeout && kill $PID 2> /dev/null & ) ; wait $PID

Expand Down Expand Up @@ -105,12 +112,30 @@ case "$exit_code" in
;;
esac

if [ -f "$HELIX_WORKITEM_ROOT/.retry" ]; then
retry=true
retry_message=$(cat "$HELIX_WORKITEM_ROOT/.retry")
fi

if [ -f "$HELIX_WORKITEM_ROOT/.reboot" ]; then
reboot=true
reboot_message=$(cat "$HELIX_WORKITEM_ROOT/.reboot")
fi

if [ "$retry" == true ]; then
"$HELIX_PYTHONPATH" -c "from helix.workitemutil import request_infra_retry; request_infra_retry('Retrying because we could not enumerate all Android devices')"
if [ -z "$retry_message" ]; then
retry_message='Retrying because we could not enumerate all Android devices'
fi

"$HELIX_PYTHONPATH" -c "from helix.workitemutil import request_infra_retry; request_infra_retry('$retry_message')"
fi

if [ "$reboot" == true ]; then
"$HELIX_PYTHONPATH" -c "from helix.workitemutil import request_reboot; request_reboot('Rebooting to allow Android emulator to restart')"
if [ -z "$reboot_message" ]; then
reboot_message='Rebooting to allow Android emulator to restart'
fi

"$HELIX_PYTHONPATH" -c "from helix.workitemutil import request_reboot; request_reboot('$reboot_message')"
fi

exit $exit_code
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,24 @@ exit_code=$?
# We usually also ask the work item to be re-tried on a different machine
# Since we run the payload script using launchctl, env vars such as PYTHON_PATH are not set there and we have to do this part here
# We signal this by creating files
if [ -f './.retry' ]; then
"$HELIX_PYTHONPATH" -c "from helix.workitemutil import request_infra_retry; request_infra_retry('Retrying work item because XHarness workload requested it')"
if [ -f "$HELIX_WORKITEM_ROOT/.retry" ]; then
retry_message=$(cat "$HELIX_WORKITEM_ROOT/.retry")

if [ -z "$retry_message" ]; then
retry_message='Retrying because we could not enumerate all Android devices'
fi

"$HELIX_PYTHONPATH" -c "from helix.workitemutil import request_infra_retry; request_infra_retry('$retry_message')"
fi

if [ -f './.reboot' ]; then
"$HELIX_PYTHONPATH" -c "from helix.workitemutil import request_reboot; request_reboot('Rebooting because XHarness workload requested it)"
if [ -f "$HELIX_WORKITEM_ROOT/.reboot" ]; then
reboot_message=$(cat "$HELIX_WORKITEM_ROOT/.reboot")

if [ -z "$reboot_message" ]; then
reboot_message='Rebooting to allow Android emulator to restart'
fi

"$HELIX_PYTHONPATH" -c "from helix.workitemutil import request_reboot; request_reboot('$reboot_message')"
fi

exit $exit_code
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ function xharness() {
function report_infrastructure_failure() {
echo "Infrastructural problem reported by the user, requesting retry+reboot: $1"

touch './.retry'
touch './.reboot'
echo "$1" > "$HELIX_WORKITEM_ROOT/.retry"
echo "$1" > "$HELIX_WORKITEM_ROOT/.reboot"
}

# Act out the actual commands (and time constrain them to create buffer for the end of this script)
Expand Down