check_ethernet: perform ping check more selectively
We only intend to do this check
(a) initially; to see whether we need to do any recovery at all and
(b) after a recovery_method claims to have performed an action
For (b), this comes when the recovery_method returns 0 (success), and so
we move on to the latter phase of the loop.
Therefore, (a) can be moved outside the loop, saving time.
BUG=none
TEST=manual tests
Change-Id: I7f7ad380abca4675fc46bef4d125235c8f63dfa4
Reviewed-on: https://chromium-review.googlesource.com/1714127
Tested-by: Brian Norris <briannorris@chromium.org>
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
Reviewed-by: Grant Grundler <grundler@chromium.org>
diff --git a/recover_duts/hooks/check_ethernet.hook b/recover_duts/hooks/check_ethernet.hook
index 227297c..77e966e 100755
--- a/recover_duts/hooks/check_ethernet.hook
+++ b/recover_duts/hooks/check_ethernet.hook
@@ -291,14 +291,13 @@
return 0
fi
+ # Attempt to ping our controlling autotest server over ethernet.
+ if ping_controlling_server; then
+ return 0
+ fi
+
local recovery_method
-
for recovery_method in toggle_usb_ports reload_ethernet_drivers; do
- # Attempt to ping our controlling autotest server over ethernet.
- if ping_controlling_server; then
- return 0
- fi
-
critical_msg "Attempting recovery method \"${recovery_method}\""
# A success return from the recovery method implies that it successfully