[fuchsia] Ensure ipv4 addresses can be retrieved
The ipv4 addresses are not always available from ffx immediately after ffx daemon starting, wait for it for a while. A drive-by change is to remove the gssapidelegatecredentials which is never supported by the ssh server in fuchsia. Cq-Include-Trybots: luci.chrome.try:fuchsia-ava-sherlock-npi,fuchsia-ava-nelson-npi,fuchsia-smoke-sherlock Bug: 391663618 Change-Id: Ie6d5acd26685d365a4407f72f4228335323fd4ff Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6398335 Reviewed-by: David Song <wintermelons@google.com> Auto-Submit: Zijie He <zijiehe@google.com> Commit-Queue: Zijie He <zijiehe@google.com> Cr-Commit-Position: refs/heads/main@{#1445003}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
b885adf9f7
commit
998caa5ab9
@ -19,6 +19,7 @@ from typing import Iterable, List, Optional, Tuple
|
|||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
|
|
||||||
from compatible_utils import get_ssh_prefix, get_host_arch
|
from compatible_utils import get_ssh_prefix, get_host_arch
|
||||||
|
from repeating_log import RepeatingLog
|
||||||
|
|
||||||
|
|
||||||
def _find_src_root() -> str:
|
def _find_src_root() -> str:
|
||||||
@ -387,19 +388,42 @@ def get_ip_address(target_id: Optional[str], ipv4_only: bool = False):
|
|||||||
|
|
||||||
def get_ssh_address(target_id: Optional[str],
|
def get_ssh_address(target_id: Optional[str],
|
||||||
ipv4_only: bool = False) -> Tuple[str, int]:
|
ipv4_only: bool = False) -> Tuple[str, int]:
|
||||||
"""Determines SSH address for given target."""
|
"""Determines SSH address for given target, this function waits for the
|
||||||
|
device to be reachable up to 5 minutes, or throws an error if it fails."""
|
||||||
cmd = ['target', 'list']
|
cmd = ['target', 'list']
|
||||||
if ipv4_only:
|
if ipv4_only:
|
||||||
cmd.append('--no-ipv6')
|
cmd.append('--no-ipv6')
|
||||||
if target_id:
|
if target_id:
|
||||||
# target list does not respect -t / --target flag.
|
# target list does not respect -t / --target flag.
|
||||||
cmd.append(target_id)
|
cmd.append(target_id)
|
||||||
target = json.loads(
|
|
||||||
run_ffx_command(cmd=cmd, json_out=True,
|
# A temporary solution to avoid cycle dependency. The DIR_SRC_ROOT should be
|
||||||
capture_output=True).stdout.strip())
|
# moved away from common.py.
|
||||||
addr = target[0]['addresses'][0]
|
# pylint: disable=cyclic-import, import-outside-toplevel
|
||||||
if 'Ip' in addr:
|
import monitors
|
||||||
addr = addr['Ip']
|
|
||||||
|
# The initial ffx target list command may return an empty list or without
|
||||||
|
# the ipv4 address, wait for a while to allow it detecting the devices and
|
||||||
|
# their addresses.
|
||||||
|
with monitors.time_consumption('ffx', 'get_ssh_address',
|
||||||
|
ipv4_only and 'ipv4' or ''), \
|
||||||
|
RepeatingLog("Waiting for the ssh address"):
|
||||||
|
for _ in range(60):
|
||||||
|
target = json.loads(
|
||||||
|
run_ffx_command(cmd=cmd, json_out=True,
|
||||||
|
capture_output=True).stdout.strip())
|
||||||
|
if target:
|
||||||
|
addrs = target[0]['addresses']
|
||||||
|
if addrs:
|
||||||
|
addr = addrs[0]
|
||||||
|
if 'Ip' in addr:
|
||||||
|
addr = addr['Ip']
|
||||||
|
break
|
||||||
|
time.sleep(5)
|
||||||
|
else:
|
||||||
|
monitors.count('ffx', 'get_ssh_address', ipv4_only and 'ipv4' or '',
|
||||||
|
'failed').record(1)
|
||||||
|
raise RuntimeError('No addresses found for target.')
|
||||||
ssh_port = int(addr['ssh_port'])
|
ssh_port = int(addr['ssh_port'])
|
||||||
if ssh_port == 0:
|
if ssh_port == 0:
|
||||||
# Returning an unset ssh_port means the default port 22.
|
# Returning an unset ssh_port means the default port 22.
|
||||||
|
@ -55,10 +55,7 @@ class WebpageTestRunner(TestRunner):
|
|||||||
def run_test(self):
|
def run_test(self):
|
||||||
catch_sigterm()
|
catch_sigterm()
|
||||||
self._runner.start()
|
self._runner.start()
|
||||||
device_ip = get_ip_address(self._target_id, ipv4_only=True)
|
addr = get_ip_address(self._target_id, ipv4_only=True).exploded
|
||||||
addr = device_ip.exploded
|
|
||||||
if device_ip.version == 6:
|
|
||||||
addr = '[' + addr + ']'
|
|
||||||
addr += ':' + str(self._runner.devtools_port)
|
addr += ':' + str(self._runner.devtools_port)
|
||||||
if self.port_file:
|
if self.port_file:
|
||||||
with open(self.port_file, 'w') as out:
|
with open(self.port_file, 'w') as out:
|
||||||
|
@ -36,4 +36,3 @@ ControlPath=~/.ssh/fx-%C
|
|||||||
User fuchsia
|
User fuchsia
|
||||||
IdentitiesOnly yes
|
IdentitiesOnly yes
|
||||||
IdentityFile ~/.ssh/fuchsia_ed25519
|
IdentityFile ~/.ssh/fuchsia_ed25519
|
||||||
GSSAPIDelegateCredentials no
|
|
||||||
|
@ -30,7 +30,7 @@ import monitors
|
|||||||
import perf_trace
|
import perf_trace
|
||||||
import version
|
import version
|
||||||
from chrome_driver_wrapper import ChromeDriverWrapper
|
from chrome_driver_wrapper import ChromeDriverWrapper
|
||||||
from common import get_build_info, get_free_local_port, get_ip_address
|
from common import get_build_info, get_free_local_port, get_ip_address, ssh_run
|
||||||
from repeating_log import RepeatingLog
|
from repeating_log import RepeatingLog
|
||||||
|
|
||||||
|
|
||||||
@ -196,22 +196,14 @@ def main() -> int:
|
|||||||
monitors.tag(
|
monitors.tag(
|
||||||
version.chrome_version_str(), build_info.version,
|
version.chrome_version_str(), build_info.version,
|
||||||
version.chrome_version_str() + '/' + build_info.version)
|
version.chrome_version_str() + '/' + build_info.version)
|
||||||
proxy_host = os.environ.get('GCS_PROXY_HOST')
|
# TODO(crbug.com/391663618): Remove the condition once all the hosts
|
||||||
if proxy_host:
|
# are migrated into chrome lab.
|
||||||
# This is a hacky way to get the ip address of the host machine
|
host = '.'.join(get_ip_address(os.environ.get('FUCHSIA_NODENAME'),
|
||||||
# being accessible on the device by the fuchsia managed docker
|
ipv4_only=True).
|
||||||
# image.
|
exploded.split('.')[:-1] +
|
||||||
host = proxy_host + '0'
|
[os.environ.get('CAMERA_SERIAL_NUMBER') and
|
||||||
else:
|
'10' or # In chrome lab, the host is at .10.
|
||||||
# If not running in the managed docker image, replace the last
|
'1']) # In media lab, the host is at .1.
|
||||||
# byte of the fuchsia device ipv4 address to 1, by default it's
|
|
||||||
# the ip address of the host machine being accessible on the
|
|
||||||
# device.
|
|
||||||
# TODO(40935291): This hacky way should be removed once the
|
|
||||||
# tests are migrated to the managed docker image.
|
|
||||||
host = '.'.join(
|
|
||||||
get_ip_address(os.environ.get('FUCHSIA_NODENAME'),
|
|
||||||
True).exploded.split('.')[:-1] + ['1'])
|
|
||||||
|
|
||||||
# Waiting for a change like https://crrev.com/c/6063979 to loose the
|
# Waiting for a change like https://crrev.com/c/6063979 to loose the
|
||||||
# size limitation of the invocation which triggers an upload error
|
# size limitation of the invocation which triggers an upload error
|
||||||
|
Reference in New Issue
Block a user