Home | History | Annotate | Download | only in cros

Lines Matching refs:devserver

43 # Number of seconds for caller to poll devserver's is_staged call to check if
46 # Artifacts that should be staged when client calls devserver RPC to stage an
49 # Artifacts that should be staged when client calls devserver RPC to stage an
54 # Artifacts that should be staged when client calls devserver RPC to stage an
59 # Number of seconds for the call to get devserver load to time out.
62 # Android artifact path in devserver
66 # Return value from a devserver RPC indicating the call succeeded.
69 # The timeout minutes for a given devserver ssh call.
72 # Error message for invalid devserver response.
76 # Error message for devserver call timedout.
79 # The timeout minutes for waiting a devserver staging.
85 # The total times of devserver triggering CrOS auto-update.
88 # Number of seconds for caller to poll devserver's get_au_status call to
103 # Raised when devserver portfile does not exist on host.
104 (r".*Devserver portfile does not exist!.*$",
105 '(1) Devserver portfile does not exist on host'),
106 # Raised when devserver cannot copy packages to host.
109 # Raised when devserver fails to run specific commands on host.
127 # Raised when devserver returns non-json response to shard/drone.
129 '(8) Devserver returned non-json object'),
130 # Raised when devserver loses host's ssh connection
132 "(9) Devserver lost host's ssh connection"),
173 """Raised when fail to locate any devserver."""
294 """Infer the devserver call arguments to use with the given archive_url.
296 @param archive_url: The archive url to include the in devserver RPC. This
298 @return: A dict of arguments to include in the devserver call.
305 # For a local path, we direct the devserver to move the files while
308 # the devserver once staged.
351 """A decorator to use with remote devserver calls.
355 retries on urllib2.URLError or error.CmdError to avoid devserver flakiness.
380 if args and isinstance(args[0], DevServer):
382 elif 'devserver' in kwargs:
383 dev_server = get_hostname(kwargs['devserver'])
385 logging.debug('RPC call %s has timed out on devserver %s.',
388 'chromeos/autotest/devserver/call_timeout')
410 class DevServer(object):
411 """Base class for all DevServer-like server stubs.
414 A caller should instantiate a sub-class of DevServer with:
421 # Threshold for the CPU load percentage for a devserver to be selected.
434 def __init__(self, devserver):
435 self._devserver = devserver
439 """Returns the url for this devserver."""
445 """Return devserver hostname parsed from the devserver URL.
447 Note that this is likely parsed from the devserver URL from
449 devserver URL is actually an IP address.
458 """Return devserver hostname, resolved from its IP address.
461 the proper hostname from the devserver IP address. If lookup
472 """Get the devserver url from a repo url, which includes build info.
476 @return A devserver url, e.g., http://127.0.0.10:8080
484 def get_devserver_load_wrapper(cls, devserver, timeout_sec, output):
487 @param devserver: url of the devserver.
488 @param timeout_sec: Number of seconds before time out the devserver
492 load = cls.get_devserver_load(devserver, timeout_min=timeout_sec/60.0)
494 load['devserver'] = devserver
499 def get_devserver_load(cls, devserver,
501 """Returns True if the |devserver| is healthy to stage build.
503 @param devserver: url of the devserver.
505 the devserver is not up (float).
507 @return: A dictionary of the devserver's load.
510 call = cls._build_call(devserver, 'check_health')
512 def get_load(devserver=devserver):
517 return json.load(cStringIO.StringIO(get_load(devserver=devserver)))
519 logging.error('Devserver call failed: "%s", timeout: %s seconds,'
525 """Check if a devserver has enough free disk.
527 @param load: A dict of the load of the devserver.
529 @return: True if the devserver has enough free disk or disk check is
534 logging.debug('devserver health check is skipped.')
543 """Check if a devserver has enough Apache connections available.
546 a devserver has too many live connections, it likely indicates the
551 @param load: A dict of the load of the devserver.
553 @return: True if the devserver has enough Apache connections available,
558 logging.debug('devserver health check is skipped.')
560 logging.debug('Apache client count is not collected from devserver.')
569 def devserver_healthy(cls, devserver,
571 """Returns True if the |devserver| is healthy to stage build.
573 @param devserver: url of the devserver.
575 the devserver is not up (float).
577 @return: True if devserver is healthy. Return False otherwise.
580 c = metrics.Counter('chromeos/autotest/devserver/devserver_healthy')
583 load = cls.get_devserver_load(devserver, timeout_min=timeout_min)
586 # Failed to get the load of devserver.
593 logging.error('Devserver check_health failed. Live Apache client '
601 logging.error('Devserver check_health failed. Free disk space is '
607 c.increment(fields={'dev_server': cls(devserver).resolved_hostname,
610 # Monitor how many AU processes the devserver is currently running.
611 if load is not None and load.get(DevServer.AU_PROCESS):
613 'chromeos/autotest/devserver/devserver_au_count')
615 load.get(DevServer.AU_PROCESS),
616 fields={'dev_server': cls(devserver).resolved_hostname})
631 # If the archive_url is a local path, the args expected by the devserver
643 """Builds a devserver RPC string that is used by 'run_call()'.
645 @param method: remote devserver method to call.
673 """Invoke a given devserver call using urllib.open.
678 @param call: a url string that calls a method to a devserver.
705 @param ip: The IP address of a dut to look for devserver.
707 @param unrestricted_only: Set to True to select from devserver in
714 # we need a dict to return the full devserver path once the IPs are
727 'Fail to locate a devserver for dut %s in %s devservers'
759 """"Get a healthy devserver instance from the list of devservers.
762 @param devservers: The devserver list to be chosen out a healthy one.
766 @return: A DevServer object of a healthy devserver. Return None if no
767 healthy devserver is found.
770 logging.debug('Pick one healthy devserver from %r', devservers)
773 devserver = devservers.pop(hash_index)
774 logging.debug('Check health for %s', devserver)
775 if ban_list and devserver in ban_list:
778 if cls.devserver_healthy(devserver):
779 logging.debug('Pick %s', devserver)
780 return cls(devserver)
789 @param hostname: Hostname of a DUT to choose devserver for.
794 devserver if no devserver in the returned devservers can be
804 'devserver without subnet constraint.', hostname)
817 'Try to locate a devserver inside subnet '
825 # restricted subnet, pick a devserver in the same subnet if possible.
826 # Set can_retry to True so it can pick a different devserver if all
837 """"Resolves a build to a devserver instance.
840 @param hostname: The hostname of dut that requests a devserver. It's
841 used to make sure a devserver in the same subnet is
845 @raise DevServerException: If no devserver is available.
852 devserver = cls.get_healthy_devserver(build, devservers,
855 if not devserver and can_retry:
858 devserver = cls.get_healthy_devserver(build, devservers,
862 if devserver:
863 return devserver
877 'chromeos/autotest/devserver/subnet_without_devservers')
884 """Return a random devserver that's available.
886 Devserver election in `resolve` method is based on a hash of the
888 callers requesting for the same build can get the same devserver,
892 This function returns a random devserver, by passing a random
898 class CrashServer(DevServer):
899 """Class of DevServer that symbolicates crash dumps."""
908 """Ask the devserver to symbolicate the dump at minidump_path.
911 devserver to symbolicate the dump at |minidump_path|.
949 @param hostname: Hostname of a DUT to choose devserver for.
958 class ImageServerBase(DevServer):
969 devserver.
975 """Returns the url of the directory for this image on the devserver.
991 @param server_name: name of the devserver, e.g 172.22.33.44.
999 metadata = {'devserver': server_name,
1001 '_type': 'devserver'}
1013 @param call: a url string that calls a method to a devserver.
1028 c = metrics.Counter('chromeos/autotest/devserver/ssh_failure')
1048 """Invoke a given devserver call using urllib.open or ssh.
1054 @param call: a url string that calls a method to a devserver.
1065 """Invoke a given devserver call using urllib.open or ssh.
1067 @param call: a url string that calls a method to a devserver.
1068 @param is_in_restricted_subnet: whether the devserver is in subnet.
1079 # Retry if devserver service is temporarily down, e.g. in a
1080 # devserver push.
1101 """Download file from devserver.
1106 @param remote_file: The URL of the file on devserver that need to be
1117 """Polling devserver.is_staged until all artifacts are staged.
1119 @param kwargs: keyword arguments to make is_staged devserver call.
1121 @return: True if all artifacts are staged in devserver.
1126 """Call devserver.is_staged rpc to check if all files are staged.
1128 @return: True if all artifacts are staged in devserver. False
1131 exceptions that were raised when devserver tried to download
1132 the artifacts. devserver raises an HTTPError or a CmdError
1135 If the call to devserver failed for connection issue, a
1153 # Retry if SSH failed to connect to the devserver.
1170 @param call_name: name of devserver rpc call.
1177 @param kwargs: keyword arguments to make is_staged devserver call.
1194 raise DevServerException('Received Bad Status line, Devserver %s '
1201 # `os_type` is needed in build a devserver call, but not needed for
1211 """Tell the devserver to download and stage |artifacts| from |image|
1219 This is maintained along with the actual devserver code.
1227 make stage devserver call.
1243 logging.info('Staging artifacts on devserver %s: %s',
1258 'chromeos/autotest/devserver/stage_artifact_duration',
1272 metrics.Counter('chromeos/autotest/devserver/stage_artifact'
1287 """Tell the devserver to download and stage image specified in
1290 Tells the devserver to fetch |image| from the image storage server
1337 """Tell the devserver to finish staging image specified in
1342 devserver and blocks until all staging is completed and should be
1372 """Locate a file with the given file_name on devserver.
1374 This method calls devserver RPC `locate_file` to look up a file with
1387 @return: A devserver url to the file.
1399 # Devserver treats Android and Brillo build in the same way as they
1401 # artifacts. Therefore, os_type for devserver calls is `android` for
1413 raise DevServerException('Received Bad Status line, Devserver %s '
1420 """Ask the devserver to list all control files for |build|.
1438 """Ask the devserver for the contents of a control file.
1455 """Ask the devserver to list contents of all control files for |build|.
1473 """Class for DevServer that handles RPCs related to CrOS images.
1475 The calls to devserver to stage artifacts, including stage and download, are
1477 devserver to stage certain artifacts, devserver handles the call and starts
1480 devserver's is_staged call until all artifacts are staged.
1481 Such mechanism is designed to prevent cherrypy threads in devserver being
1483 with a fixed number of threads that handle devserver rpc.
1503 """Polling devserver.is_staged until all artifacts are staged.
1508 @return: True if all artifacts are staged in devserver.
1521 @param call_name: name of devserver rpc call.
1546 """Tell the devserver to download and stage |artifacts| from |image|.
1553 This is maintained along with the actual devserver code.
1572 """List the contents of the image stage directory, on the devserver.
1579 logging.info('Requesting contents from devserver %s for image %s',
1589 """Tell the devserver to download and stage |image|.
1591 Tells the devserver to fetch |image| from the image storage server
1615 """Tell the devserver to setup telemetry for this build.
1617 The devserver will stage autotest and then extract the required files
1622 @returns path on the devserver that telemetry is installed to.
1631 raise DevServerException('Received Bad Status line, Devserver %s '
1638 """Tell the devserver to finish staging |image|.
1642 devserver and blocks until all staging is completed and should be
1665 """Returns the url of a staged file for this image on the devserver."""
1776 @param kwargs: Arguments to make kill_au_proc devserver call.
1783 'on devserver %s, the response is %s' % (
1793 If pid is specified, the devserver will further check the given pid to
1838 'devserver for host %s and process id %s: %s',
1851 """Reads the json response from the devserver.
1854 @param response: the response for a devserver.
1865 """Collect logs from devserver after cros-update process is finished.
1874 @param pid: the auto-update process id on devserver.
1876 retrieved from devserver.
1907 """Collect logs from devserver after cros-update process is finished.
1910 @param pid: the auto-update process id on devserver.
1912 retrieved from devserver.
1925 'devserver for host %s and process id %s: %s',
1934 """Trigger auto-update by calling devserver.cros_au.
1936 @param kwargs: Arguments to make cros_au devserver call.
1939 the auto-update process id running on devserver.
1946 'Received response from devserver for cros_au call: %r',
1950 raise DevServerException('Received Bad Status line, Devserver %s '
1958 """Polling devserver.get_au_status to get current auto-update status.
1963 @param pid: The background process id for auto-update in devserver.
1964 @param kwargs: keyword arguments to make get_au_status devserver call.
1974 """Call devserver.get_au_status rpc to check if auto-update
1980 exceptions that were raised when devserver tried to
1981 download the artifacts. devserver raises an HTTPError or
1984 waiting. If the call to devserver failed for connection
1994 # devserver CL is deployed.
2022 'devserver to check auto-update status.', e)
2025 # Retry if SSH failed to connect to the devserver.
2030 # Could be some temporary devserver connection issues.
2032 'devserver to check auto-update status.', e)
2056 @param kwargs: keyword arguments to make get_au_status devserver call.
2061 pid: the auto-update process id on devserver.
2076 'devserver', pid)
2080 logging.debug('Failed to trigger auto-update process on devserver')
2110 auto_update with another devserver based on the given error_msg.
2113 # When we get more date about what's the json response when devserver
2302 devserver.
2490 """Class for DevServer that handles RPCs related to Android builds.
2492 The calls to devserver to stage artifacts, including stage and download, are
2494 devserver to stage certain artifacts, devserver handles the call and starts
2497 devserver's is_staged call until all artifacts are staged.
2498 Such mechanism is designed to prevent cherrypy threads in devserver being
2500 with a fixed number of threads that handle devserver rpc.
2505 """Polling devserver.is_staged until all artifacts are staged.
2515 @return: True if all artifacts are staged in devserver.
2534 @param call_name: name of devserver rpc call.
2568 """Tell the devserver to download and stage |artifacts| from |image|.
2575 This is maintained along with the actual devserver code.
2611 """Get the url to pull files from the devserver.
2625 """Tell the devserver to download and stage an Android build.
2627 Tells the devserver to fetch an Android build from the image storage
2664 """Tell the devserver to finish staging an Android build.
2668 devserver and blocks until all staging is completed and should be
2691 """Returns the url of a staged file for this image on the devserver.
2699 @return: The url of a staged file for this image on the devserver.
2736 """Check if devserver's load meets the minimum threshold.
2738 @param load: The devserver's load stats to check.
2745 if load[DevServer.CPU_LOAD] > DevServer.MAX_CPU_LOAD:
2746 logging.debug('CPU load of devserver %s is at %s%%, which is higher '
2747 'than the threshold of %s%%', load['devserver'],
2748 load[DevServer.CPU_LOAD], DevServer.MAX_CPU_LOAD)
2750 if load[DevServer.NETWORK_IO] > DevServer.MAX_NETWORK_IO:
2751 logging.debug('Network IO of devserver %s is at %i Bps, which is '
2753 load['devserver'], load[DevServer.NETWORK_IO],
2754 DevServer.MAX_NETWORK_IO)
2762 @param devserver1: A dictionary of devserver load stats to be compared.
2763 @param devserver2: A dictionary of devserver load stats to be compared.
2769 return int(devserver1[DevServer.DISK_IO] - devserver2[DevServer.DISK_IO])
2790 """Get the devserver with the least load.
2794 TODO(crbug.com/486278): Devserver with required build already staged should
2798 selects a devserver based on the hash of the image name/url.
2800 @param devserver_type: Type of devserver to select from. Default is set to
2802 @param hostname: Hostname of the dut that the devserver is used for. The
2803 picked devserver needs to respect the location of the host if
2807 @return: Name of the devserver with the least load.
2826 for devserver in devservers:
2829 args=(devserver, TIMEOUT_GET_DEVSERVER_LOAD, output)))
2837 loads = [load for load in loads if load and DevServer.CPU_LOAD in load and
2838 DevServer.is_free_disk_ok(load) and
2839 DevServer.is_apache_client_count_ok(load)]
2841 logging.debug('Failed to retrieve load stats from any devserver. No '
2846 logging.error('No devserver has the capacity to be selected.')
2849 return loads[0]['devserver']
2853 """Resolve a devserver can be used for given build and hostname.
2855 @param build: Name of a build to stage on devserver, e.g.,
2858 @param hostname: Hostname of a devserver for, default is None, which means
2859 devserver is not restricted by the network location of the host.
2862 @return: A DevServer instance that can be used to stage given build for the