Fix setting cutoff time for TF tasks triggered by finished Copr build#3096
Conversation
Signed-off-by: Nikola Forró <nforro@redhat.com> Assisted-by: Claude Opus 4.6 via Claude Code
There was a problem hiding this comment.
Code Review
This pull request modifies the handle_testing_farm method in packit_service/worker/handlers/copr.py to calculate the cancel_cutoff_time based on the earliest pipeline datetime in the current build batch, rather than just the first run. It also introduces a one-second buffer to ensure sibling tests from the same batch are not canceled. A review comment pointed out a potential issue where calling .timestamp() on naive datetime objects might use the local system timezone instead of UTC, suggesting an explicit conversion to UTC to ensure consistency across different server environments.
| default=None, | ||
| ) | ||
| if earliest: | ||
| event_dict["cancel_cutoff_time"] = (earliest - timedelta(seconds=1)).timestamp() |
There was a problem hiding this comment.
The PipelineModel.datetime column stores naive datetime objects representing UTC. When calling .timestamp() on a naive datetime object, Python assumes it is in the local system timezone. If the server environment is not configured to UTC, this will result in an incorrect timestamp offset. It is safer to explicitly set the timezone to UTC before calculating the timestamp.
| event_dict["cancel_cutoff_time"] = (earliest - timedelta(seconds=1)).timestamp() | |
| event_dict["cancel_cutoff_time"] = ( | |
| earliest.replace(tzinfo=timezone.utc) - timedelta(seconds=1) | |
| ).timestamp() |
There was a problem hiding this comment.
I don't think this matters here.
|
Build succeeded. ✔️ pre-commit SUCCESS in 1m 56s |
|
Build succeeded (gate pipeline). ✔️ pre-commit SUCCESS in 1m 56s |
Related to #3076.