prow: handle the case of re-triggering an expired GitHub workflow #192
Labels
lifecycle/rotten
Denotes an issue or PR that has aged beyond stale and will be auto-closed.
sig/contributor-experience
Categorizes an issue or PR as relevant to SIG Contributor Experience.
sig/testing
Categorizes an issue or PR as relevant to SIG Testing.
Original issue here: kubernetes/test-infra#31645
kubernetes/test-infra#31132 added the functionality of re-triggering only failed jobs in a GitHub workflow. However, the trigger plugin does not handle the cases when the failed workflow is expired (came up in discussion here kubernetes/test-infra#30054 (comment), cc @Priyankasaggu11929)
Workflows or jobs in workflows can only be re-run within
min(30 days, log retention period)
(or atleast that is my understanding based on https://docs.github.com/en/actions/managing-workflow-runs/re-running-workflows-and-jobs). Considering our repos have a 90 day log retention period, seems like we can only ever re-run jobs in a 30 day time-frame.Regardless, if a repo uses prow to trigger GitHub workflows,
/retest
on expired workflows runs will yield no result from prow. We should probably make the bot post a comment indicating that one or more workflow run has expired.Step 1: Modify the trigger logic here to include a comment if at least one of the runs is expired:
prow/pkg/plugins/trigger/generic-comment.go
Line 160 in 924d31f
The status code returned by an API call to re-run a failed, expired workflow run is
403
(unfortunately, GitHub does not document this), with an error message. There are 2 issues with trying to rely on this returned403
:403
can indicate the need to retry the request. The Prow GitHub client will attempt a retry if status code of403
is returned, but it will retry only if the error returned by the sending the request isnil
prow/pkg/github/client.go
Lines 946 to 958 in 924d31f
Note: you may not be able to run the exact same command above since you may not have write access on kubernetes/utils.
The output:
The same error is propagated into the Prow GitHub client as well.
As a result, the way the request is handled in the Prow client is that if an error is returned after all retries are done, it returns a status code of
0
, indicating that the client could not communicate with the server using HTTP (which is clearly not true). I've demonstrated this here with a unit test: MadhavJivrajani/test-infra@38c5f90The only way (for now) to know if we are trying to rerun an expired workflow run is to parse the error message itself. We can probably do:
If the above condition is true, post a comment saying there are expired workflow runs.
It might also be worth including what can be done to mitigate this, one popular workaround I see online is to rebase or force push an empty commit.
Step 2: Add tests
There aren't any tests for triggering GitHub workflows in general. If we do this, we need to ensure we have test coverage.
Follow ups
Its worth looking into the returning of status code
0
considering this is a valid use case, but this is a follow up.Also - note that we will end up retrying and backing off every time we try to rerun an expired workflow run. Maybe there's a way to short-circuit that.
/sig contributor-experience testing
The text was updated successfully, but these errors were encountered: