#3235 hub: fix Task.lock for correctly closed tasks
Merged 2 years ago by tkopecek. Opened 2 years ago by tkopecek.
tkopecek/koji issue3220  into  master

file modified
+5 -3
@@ -214,9 +214,11 @@ 

                      log_error(f"Error: task {task_id} is already open and handled by "

                                f"{host_id} (double open/assign)")

                  return False

-             elif otherhost is None:  # CLOSED, FAILED

-                 log_error(f"Error: task {task_id} is non-free but not handled by any host "

-                           f"(state {koji.TASK_STATES[state]})")

+             else:

+                 # state is CLOSED or FAILED

+                 if otherhost is None:

+                     log_error(f"Error: task {task_id} is non-free but not handled by any host "

+                               f"(state {koji.TASK_STATES[state]})")

                  return False

          # if we reach here, task is either

          #  - free and unlocked

Metadata Update from @tkopecek:
- Pull-request tagged with: testing-ready

2 years ago

Ah yes, this behavior looks correct.

I just have a couple of readability notes.

  • the added comment says "host assigned", but this could be misread. Might be better to say something slightly different, perhaps "host associated" or "taken by host"
  • every if case but the last here is based on a state check. The last is not, and that arguably led to this oversight. It might be better to refactor the checks just a little. E.g.
    else:
        # state is CLOSED or FAILED
        if otherhost is None:
            log_error(f"Error: task {task_id} is non-free but not handled by any host "
                      f"(state {koji.TASK_STATES[state]})")
        return False

Which should be entirely equivalent, but provides a bit of separate between the implicit state branching and the follow up check for host association.

rebased onto edad8d4

2 years ago

breadcrumb: code last changed in #3007

Commit 78d7f3f fixes this pull-request

Pull-Request has been merged by tkopecek

2 years ago

Metadata Update from @jobrauer:
- Pull-request tagged with: testing-done

2 years ago
Metadata