Home | History | Annotate | Download | only in cros

Lines Matching full:devserver

35 # Number of seconds for caller to poll devserver's is_staged call to check if
38 # Artifacts that should be staged when client calls devserver RPC to stage an
41 # Artifacts that should be staged when client calls devserver RPC to stage an
46 # Artifacts that should be staged when client calls devserver RPC to stage an
50 # Artifacts that should be staged when client calls devserver RPC to stage an
55 # Number of seconds for the call to get devserver load to time out.
58 # Android artifact path in devserver
62 # Return value from a devserver RPC indicating the call succeeded.
131 """A decorator to use with remote devserver calls.
135 The method retries on urllib2.URLError to avoid devserver flakiness.
164 class DevServer(object):
165 """Base class for all DevServer-like server stubs.
168 A caller should instantiate a sub-class of DevServer with:
174 # Threshold for the CPU load percentage for a devserver to be selected.
185 def __init__(self, devserver):
186 self._devserver = devserver
190 """Returns the url for this devserver."""
207 def get_devserver_load_wrapper(devserver, timeout_sec, output):
210 @param devserver: url of the devserver.
211 @param timeout_sec: Number of seconds before time out the devserver
215 load = DevServer.get_devserver_load(devserver,
218 load['devserver'] = devserver
223 def get_devserver_load(devserver, timeout_min=0.1):
224 """Returns True if the |devserver| is healthy to stage build.
226 @param devserver: url of the devserver.
228 the devserver is not up (float).
230 @return: A dictionary of the devserver's load.
233 server_name = DevServer.get_server_name(devserver)
236 call = DevServer._build_call(devserver, 'check_health')
255 logging.error('Devserver call failed: "%s", timeout: %s seconds,'
261 """Check if a devserver has enough free disk.
263 @param load: A dict of the load of the devserver.
265 @return: True if the devserver has enough free disk or disk check is
270 logging.debug('devserver health check is skipped.')
271 elif load[DevServer.FREE_DISK] < DevServer._MIN_FREE_DISK_SPACE_GB:
278 def devserver_healthy(devserver, timeout_min=0.1):
279 """Returns True if the |devserver| is healthy to stage build.
281 @param devserver: url of the devserver.
283 the devserver is not up (float).
285 @return: True if devserver is healthy. Return False otherwise.
288 server_name = DevServer.get_server_name(devserver)
291 load = DevServer.get_devserver_load(devserver, timeout_min=timeout_min)
293 # Failed to get the load of devserver.
298 disk_ok = DevServer.is_free_disk_ok(load)
300 logging.error('Devserver check_health failed. Free disk space is '
302 load[DevServer.FREE_DISK])
304 # This counter indicates the load of a devserver. By comparing the
329 """Builds a devserver RPC string that can be invoked using urllib.open.
331 @param method: remote devserver method to call.
366 @param ip: The IP address of a dut to look for devserver.
373 # we need a dict to return the full devserver path once the IPs are
407 """"Get a healthy devserver instance from the list of devservers.
411 @return: A DevServer object of a healthy devserver. Return None if no
412 healthy devserver is found.
417 devserver = devservers.pop(hash_index)
418 if cls.devserver_healthy(devserver):
419 return cls(devserver)
424 """"Resolves a build to a devserver instance.
427 @param hostname: The hostname of dut that requests a devserver. It's
428 used to make sure a devserver in the same subnet is
431 @raise DevServerException: If no devserver is available.
438 'devserver without subnet constraint.', hostname)
450 'Try to locate a devserver inside subnet '
456 # If devserver election is not restricted and
458 # select a devserver from unrestricted servers. Otherwise, drone will
459 # not be able to access devserver in restricted subnet.
468 devserver = cls.get_healthy_devserver(build, devservers)
470 if not devserver and can_retry:
471 devserver = cls.get_healthy_devserver(
473 if devserver:
474 return devserver
486 class CrashServer(DevServer):
487 """Class of DevServer that symbolicates crash dumps."""
495 """Ask the devserver to symbolicate the dump at minidump_path.
498 devserver to symbolicate the dump at |minidump_path|.
532 class ImageServerBase(DevServer):
543 devserver.
549 """Returns the url of the directory for this image on the devserver.
569 @param server_name: name of the devserver, e.g 172.22.33.44.
591 @param server_name: name of the devserver, e.g 172.22.33.44.
599 metadata = {'devserver': server_name,
601 '_type': 'devserver'}
610 """Polling devserver.is_staged until all artifacts are staged.
612 @param kwargs: keyword arguments to make is_staged devserver call.
614 @return: True if all artifacts are staged in devserver.
619 """Call devserver.is_staged rpc to check if all files are staged.
621 @return: True if all artifacts are staged in devserver. False
624 exceptions that were raised when devserver tried to download
625 the artifacts. devserver raises an HTTPError when an
628 to devserver failed for connection issue, a URLError
661 @param call_name: name of devserver rpc call.
668 @param kwargs: keyword arguments to make is_staged devserver call.
679 raise DevServerException('Received Bad Status line, Devserver %s '
686 # `os_type` is needed in build a devserver call, but not needed for
696 """Tell the devserver to download and stage |artifacts| from |image|
704 This is maintained along with the actual devserver code.
712 make stage devserver call.
728 logging.info('Staging artifacts on devserver %s: %s',
774 """Tell the devserver to download and stage image specified in
777 Tells the devserver to fetch |image| from the image storage server
833 """Tell the devserver to finish staging image specified in
838 devserver and blocks until all staging is completed and should be
873 """Class for DevServer that handles RPCs related to CrOS images.
875 The calls to devserver to stage artifacts, including stage and download, are
877 devserver to stage certain artifacts, devserver handles the call and starts
880 devserver's is_staged call until all artifacts are staged.
881 Such mechanism is designed to prevent cherrypy threads in devserver being
883 with a fixed number of threads that handle devserver rpc.
903 """Polling devserver.is_staged until all artifacts are staged.
908 @return: True if all artifacts are staged in devserver.
921 @param call_name: name of devserver rpc call.
946 """Tell the devserver to download and stage |artifacts| from |image|.
953 This is maintained along with the actual devserver code.
972 """List the contents of the image stage directory, on the devserver.
979 logging.info('Requesting contents from devserver %s for image %s',
989 """Tell the devserver to download and stage |image|.
991 Tells the devserver to fetch |image| from the image storage server
1015 """Tell the devserver to setup telemetry for this build.
1017 The devserver will stage autotest and then extract the required files
1022 @returns path on the devserver that telemetry is installed to.
1031 raise DevServerException('Received Bad Status line, Devserver %s '
1038 """Tell the devserver to finish staging |image|.
1042 devserver and blocks until all staging is completed and should be
1065 """Returns the url of a staged file for this image on the devserver."""
1095 """Ask the devserver to list all control files for |build|.
1114 """Ask the devserver for the contents of a control file.
1209 """Class for DevServer that handles RPCs related to Android builds.
1211 The calls to devserver to stage artifacts, including stage and download, are
1213 devserver to stage certain artifacts, devserver handles the call and starts
1216 devserver's is_staged call until all artifacts are staged.
1217 Such mechanism is designed to prevent cherrypy threads in devserver being
1219 with a fixed number of threads that handle devserver rpc.
1224 """Polling devserver.is_staged until all artifacts are staged.
1234 @return: True if all artifacts are staged in devserver.
1253 @param call_name: name of devserver rpc call.
1287 """Tell the devserver to download and stage |artifacts| from |image|.
1294 This is maintained along with the actual devserver code.
1324 """Tell the devserver to download and stage an Android build.
1326 Tells the devserver to fetch an Android build from the image storage
1357 """Tell the devserver to finish staging an Android build.
1361 devserver and blocks until all staging is completed and should be
1382 """Returns the url of a staged file for this image on the devserver.
1390 @return: The url of a staged file for this image on the devserver.
1426 """Check if devserver's load meets the minimum threshold.
1428 @param load: The devserver's load stats to check.
1435 if load[DevServer.CPU_LOAD] > DevServer.MAX_CPU_LOAD:
1436 logging.debug('CPU load of devserver %s is at %s%%, which is higher '
1437 'than the threshold of %s%%', load['devserver'],
1438 load[DevServer.CPU_LOAD], DevServer.MAX_CPU_LOAD)
1440 if load[DevServer.NETWORK_IO] > DevServer.MAX_NETWORK_IO:
1441 logging.debug('Network IO of devserver %s is at %i Bps, which is '
1443 load['devserver'], load[DevServer.NETWORK_IO],
1444 DevServer.MAX_NETWORK_IO)
1452 @param devserver1: A dictionary of devserver load stats to be compared.
1453 @param devserver2: A dictionary of devserver load stats to be compared.
1459 return int(devserver1[DevServer.DISK_IO] - devserver2[DevServer.DISK_IO])
1463 """Get the devserver with the least load.
1467 TODO(crbug.com/486278): Devserver with required build already staged should
1471 selects a devserver based on the hash of the image name/url.
1473 @param devserver_type: Type of devserver to select from. Default is set to
1476 @return: Name of the devserver with the least load.
1483 for devserver in devserver_type.servers():
1485 target=DevServer.get_devserver_load_wrapper,
1486 args=(devserver, TIMEOUT_GET_DEVSERVER_LOAD, output)))
1494 loads = [load for load in loads if load and DevServer.CPU_LOAD in load and
1495 DevServer.is_free_disk_ok(load)]
1497 logging.debug('Failed to retrieve load stats from any devserver. No '
1502 logging.error('No devserver has the capacity to be selected.')
1505 return loads[0]['devserver']