-
Notifications
You must be signed in to change notification settings - Fork 290
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This replaces teuthology-nuke --stale Signed-off-by: Zack Cerza <[email protected]>
- Loading branch information
Showing
2 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import argparse | ||
import logging | ||
import sys | ||
|
||
import teuthology | ||
from teuthology.lock import query, ops | ||
|
||
def main(): | ||
args = parse_args(sys.argv[1:]) | ||
if args.verbose: | ||
teuthology.log.setLevel(logging.DEBUG) | ||
log = logging.getLogger(__name__) | ||
stale = query.find_stale_locks(args.owner) | ||
if not stale: | ||
return | ||
if args.dry_run: | ||
log.info("Would attempt to unlock:") | ||
for node in stale: | ||
log.info(f"{node['name']}\t{node['description']}") | ||
else: | ||
names = [node["name"] for node in stale] | ||
ops.unlock_safe(names, args.owner) | ||
|
||
def parse_args(argv): | ||
parser = argparse.ArgumentParser( | ||
description="Find and unlock nodes that are still locked by jobs that are no " | ||
"longer active", | ||
) | ||
parser.add_argument( | ||
'-v', '--verbose', | ||
action='store_true', | ||
default=False, | ||
help='Be more verbose', | ||
) | ||
parser.add_argument( | ||
'--dry-run', | ||
action='store_true', | ||
default=False, | ||
help="List nodes that would be unlocked if the flag were omitted", | ||
) | ||
parser.add_argument( | ||
'--owner', | ||
help='Optionally, find nodes locked by a specific user', | ||
) | ||
return parser.parse_args(argv) | ||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters