diff options
author | Stephen Hines <srhines@google.com> | 2022-01-05 21:47:21 -0800 |
---|---|---|
committer | Stephen Hines <srhines@google.com> | 2022-01-05 21:47:21 -0800 |
commit | 7bc245bad95c6f4c15bc3f819f61312705b59a5a (patch) | |
tree | cf4cdad04e1c146844e2a790910cf9cd1b97082a /lock_machine.py | |
parent | f103b9f78baa21b4edf25d5dd5a1226b6c0ff159 (diff) | |
parent | dbc8cb672a14f4a8bb136074817c71a22f743eaf (diff) | |
download | toolchain-utils-f36ee531b7ecef5a4adbaa8f36a3f5203252852f.tar.gz |
Merging 32 commit(s) from Chromium's toolchain-utilsandroid-t-preview-2android-t-preview-1android-t-beta-3android-s-v2-beta-3android-s-qpr3-beta-1android-t-preview-1android-s-v2-beta-3android-s-qpr3-beta-1
Merged commit digest:
dbc8cb67 compiler_wrapper: Use ld.bfd to detect binutils path
0274702f patch_sync: Add show subcommand
7fd98520 patch_sync: Add patch_parsing module
72bb9a35 patch_sync: Base code, version control managing
457d96b5 pgo_tools: make monitor_pgo_profiles fail rather than emailing
ed486b7b afdo_metadata: Publish the new kernel profiles
a170d3e2 crosperf: remove dead bob DUT
d60f468c afdo_metadata: Publish the new kernel profiles
26b91865 llvm_tools: Update get_upstream_patch schema
811429e3 llvm_tools: Catch dup SHAs in get_upstream_patch
ed2aa295 compiler_wrapper: Drop "-fno-experimental-pass-manager"
e8d03f7e rust_watch: report bugs for new minor or major versions of rustc
443e0b36 cros_utils: Add a bug reporting module
86fe58c1 compiler_wrapper: adds ${sysroot}/usr/lib to linker path
d02a62da compiler_wrapper: add missing unused-but-set-var
50d42705 afdo_metadata: Publish the new kernel profiles
7afc3522 llvm_tools: Make skip_dependencies optional
9de6ecbf crosperf: Increase timeout for a crosfleet call
58a779e7 llvm_tools: adds a way to skip dependencies when pulling from Phab
28d6cbe1 crosperf: Replace non-inclusive language
c965dab6 afdo_metadata: Publish the new kernel profiles
58bc0488 crosperf: Update default_remotes to new DUTs
70c83ac3 Replace non-inclusive language
d080198a llvm_tools: fix yapf warnings
5200728b llvm_tools: Add lldb_server to updated_packages
afd2d4b0 compiler_wrapper: ignore unused_but_set_variable
217c68a1 Add crosperf_autolock.py wrapper
dcb168bf afdo_metadata: Publish the new kernel profiles
a7a19342 Auto-format the crosperf files
c5e12fba Add 'no_lock' crosperf setting
ec4d2aec afdo_metadata: Publish the new kernel profiles
2c5d6278 compiler_wrapper: move llvmnext flag to post flags
Change-Id: Id8af179e775f6fe23c22ce05b8be9b5b02ccbaf4
Diffstat (limited to 'lock_machine.py')
-rwxr-xr-x | lock_machine.py | 123 |
1 files changed, 56 insertions, 67 deletions
diff --git a/lock_machine.py b/lock_machine.py index e7020591..03c8c991 100755 --- a/lock_machine.py +++ b/lock_machine.py @@ -125,8 +125,8 @@ class LockManager(object): Returns: A list of names of the toolchain machines in the ChromeOS HW lab. """ - machines_file = os.path.join( - os.path.dirname(__file__), 'crosperf', 'default_remotes') + machines_file = os.path.join(os.path.dirname(__file__), 'crosperf', + 'default_remotes') machine_list = [] with open(machines_file, 'r') as input_file: lines = input_file.readlines() @@ -166,8 +166,8 @@ class LockManager(object): """ if state['locked']: print('%s (%s)\t\t%slocked by %s since %s' % - (m, state['board'], '\t\t' if machine_type == MachineType.LOCAL else - '', state['locked_by'], state['lock_time'])) + (m, state['board'], '\t\t' if machine_type == MachineType.LOCAL + else '', state['locked_by'], state['lock_time'])) else: print('%s (%s)\t\t%sunlocked' % (m, state['board'], @@ -241,8 +241,8 @@ class LockManager(object): """ try: if should_lock_machine: - ret = file_lock_machine.Machine(machine, - self.locks_dir).Lock(True, sys.argv[0]) + ret = file_lock_machine.Machine(machine, self.locks_dir).Lock( + True, sys.argv[0]) else: ret = file_lock_machine.Machine(machine, self.locks_dir).Unlock(True) except Exception: @@ -325,14 +325,14 @@ class LockManager(object): # TODO(zhizhouy): Crosfleet doesn't support host info such as locked_by. # Need to update this when crosfleet supports it. - if (state['locked'] and state['locked_by'] and - state['locked_by'] != self.user): + if (state['locked'] and state['locked_by'] + and state['locked_by'] != self.user): raise DontOwnLock('Attempt to unlock machine (%s) locked by someone ' 'else (%s).' % (k, state['locked_by'])) elif cmd == 'lock': if state['locked']: - self.logger.LogWarning('Attempt to lock already locked machine (%s)' % - k) + self.logger.LogWarning( + 'Attempt to lock already locked machine (%s)' % k) self._InternalRemoveMachine(k) def GetMachineStates(self, cmd=''): @@ -381,12 +381,10 @@ class LockManager(object): swarming = os.path.join(self.chromeos_root, self.SWARMING) # TODO(zhizhouy): Swarming script doesn't support python3 so explicitly # launch it with python2 until migrated. - cmd = (('python2 %s ' \ - 'query --swarming https://chromeos-swarming.appspot.com ' \ - "%s 'bots/list?is_dead=FALSE&dimensions=dut_name:%s'") % \ - (swarming, - credential, - machine.rstrip('.cros'))) + cmd = (('python2 %s ' + 'query --swarming https://chromeos-swarming.appspot.com ' + "%s 'bots/list?is_dead=FALSE&dimensions=dut_name:%s'") % + (swarming, credential, machine.rstrip('.cros'))) exit_code, stdout, stderr = self.ce.RunCommandWOutput(cmd) if exit_code: raise ValueError('Querying bots failed (2); stdout: %r; stderr: %r' % @@ -411,15 +409,12 @@ class LockManager(object): credential = '' if os.path.exists(self.CROSFLEET_CREDENTIAL): credential = '-service-account-json %s' % self.CROSFLEET_CREDENTIAL - cmd = (('%s dut lease -minutes %s %s %s %s') % \ - (self.CROSFLEET_PATH, - self.LEASE_MINS, - credential, - '-host' if '.cros' in machine else '-board', - machine.rstrip('.cros'))) - # Wait 120 seconds for server to start the lease task, if not started, + cmd = (('%s dut lease -minutes %s %s %s %s') % + (self.CROSFLEET_PATH, self.LEASE_MINS, credential, '-host' + if '.cros' in machine else '-board', machine.rstrip('.cros'))) + # Wait 8 minutes for server to start the lease task, if not started, # we will treat it as unavailable. - check_interval_time = 120 + check_interval_time = 480 retval = self.ce.RunCommand(cmd, command_timeout=check_interval_time) return retval == self.SUCCESS @@ -432,10 +427,8 @@ class LockManager(object): credential = '' if os.path.exists(self.CROSFLEET_CREDENTIAL): credential = '-service-account-json %s' % self.CROSFLEET_CREDENTIAL - cmd = (('%s dut abandon %s %s') % \ - (self.CROSFLEET_PATH, - credential, - machine.rstrip('.cros'))) + cmd = (('%s dut abandon %s %s') % + (self.CROSFLEET_PATH, credential, machine.rstrip('.cros'))) retval = self.ce.RunCommand(cmd) return retval == self.SUCCESS @@ -451,44 +444,39 @@ def Main(argv): """ parser = argparse.ArgumentParser() - parser.add_argument( - '--list', - dest='cmd', - action='store_const', - const='status', - help='List current status of all known machines.') - parser.add_argument( - '--lock', - dest='cmd', - action='store_const', - const='lock', - help='Lock given machine(s).') - parser.add_argument( - '--unlock', - dest='cmd', - action='store_const', - const='unlock', - help='Unlock given machine(s).') - parser.add_argument( - '--status', - dest='cmd', - action='store_const', - const='status', - help='List current status of given machine(s).') - parser.add_argument( - '--remote', dest='remote', help='machines on which to operate') - parser.add_argument( - '--chromeos_root', - dest='chromeos_root', - required=True, - help='ChromeOS root to use for autotest scripts.') - parser.add_argument( - '--force', - dest='force', - action='store_true', - default=False, - help='Force lock/unlock of machines, even if not' - ' current lock owner.') + parser.add_argument('--list', + dest='cmd', + action='store_const', + const='status', + help='List current status of all known machines.') + parser.add_argument('--lock', + dest='cmd', + action='store_const', + const='lock', + help='Lock given machine(s).') + parser.add_argument('--unlock', + dest='cmd', + action='store_const', + const='unlock', + help='Unlock given machine(s).') + parser.add_argument('--status', + dest='cmd', + action='store_const', + const='status', + help='List current status of given machine(s).') + parser.add_argument('--remote', + dest='remote', + help='machines on which to operate') + parser.add_argument('--chromeos_root', + dest='chromeos_root', + required=True, + help='ChromeOS root to use for autotest scripts.') + parser.add_argument('--force', + dest='force', + action='store_true', + default=False, + help='Force lock/unlock of machines, even if not' + ' current lock owner.') options = parser.parse_args(argv) @@ -506,7 +494,8 @@ def Main(argv): if options.remote: machine_list = options.remote.split() - lock_manager = LockManager(machine_list, options.force, options.chromeos_root) + lock_manager = LockManager(machine_list, options.force, + options.chromeos_root) machine_states = lock_manager.GetMachineStates(cmd=options.cmd) cmd = options.cmd |