Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable requesting retry/reboot on Windows XHarness workloads #7983

Merged
merged 5 commits into from
Oct 4, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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,7 @@ function xharness() {
function report_infrastructure_failure($message) {
premun marked this conversation as resolved.
Show resolved Hide 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"
New-Item -Path "$Env:HELIX_WORKITEM_ROOT" -Name ".reboot" -ItemType "file"
premun marked this conversation as resolved.
Show resolved Hide resolved
}

Original file line number Diff line number Diff line change
Expand Up @@ -52,29 +52,37 @@ 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;
}

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

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')"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,14 @@ case "$exit_code" in
;;
esac

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

if [ -f "$HELIX_WORKITEM_ROOT/.reboot" ]; then
reboot=true
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')"
fi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ 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
if [ -f "$HELIX_WORKITEM_ROOT/.retry" ]; then
"$HELIX_PYTHONPATH" -c "from helix.workitemutil import request_infra_retry; request_infra_retry('Retrying work item because XHarness workload requested it')"
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
"$HELIX_PYTHONPATH" -c "from helix.workitemutil import request_reboot; request_reboot('Rebooting because XHarness workload requested it')"
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'
touch "$HELIX_WORKITEM_ROOT/.retry"
touch "$HELIX_WORKITEM_ROOT/.reboot"
}

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