Skip to content

Commit

Permalink
backend: unknown resalloc tickets helper cleanup
Browse files Browse the repository at this point in the history
If no tickets are taken (which often happens in the staging
environment), this script encountered corner case issues.
  • Loading branch information
praiskup authored and xsuchy committed Sep 24, 2024
1 parent d6a3472 commit 658230d
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions backend/run/copr-backend-unknown-resalloc-tickets.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@

def used_ids():
"""
Return a set of ticket_ids that can be found in the "ps aux" output.
Return a `set()` of ticket IDs currently in use by
`copr-backend-process-build`, based on the output of the `ps aux` command.
"""
cmd = (
"ps aux | "
Expand All @@ -33,7 +34,9 @@ def used_ids():
output = output.strip()
tickets = set()
for ticket_id in output.split("\n"):
assert all(c.isdigit() for c in ticket_id)
if ticket_id: # ignore empty lines
continue
assert ticket_id.isdigit()
tickets.add(int(ticket_id))
return tickets

Expand Down Expand Up @@ -61,11 +64,13 @@ def print_once(message):
print(message)
storage[message] = True


if __name__ == "__main__":
def _main():
script_requires_user("resalloc")

used = used_ids()
if not used:
print("no tickets used")
return

# This is the oldest ticket that Copr Backend currently uses.
min_used = min(used)
Expand All @@ -80,3 +85,7 @@ def print_once(message):
else:
print_once("These tickets are relatively new for closing blindly, double check!")
print(f"resalloc ticket-check {unknown_id}")


if __name__ == "__main__":
_main()

0 comments on commit 658230d

Please sign in to comment.