Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prow/plugins: prioritise repo level triggers over org level ones #30054

Merged

Conversation

MadhavJivrajani
Copy link
Contributor

After #30048 was merged, I wasn't sure why /retest triggers were not working, I think this is why.

So far, TriggerFor prioristised returning org level trigger configs. There might be cases where in a trigger would need to be configured specifically for a repo (ex: allowing /retest to trigger GH workflows). In cases like this, we should return the trigger that is defined at the repo level, rather than its corresponding org level trigger.

We could "work around" the above constraint by simply defining the repo level trigger higher up in the config, but then this trigger config would shadow the org level trigger, which is not desirable.

This change returns a repo level trigger if it finds one, if not, it returns the first org level trigger it sees (keeping in sync with the previous behaviour).

Fwiw - I'm not sure why multiple org level or multiple repo level triggers for the same org or repo would be specified.

/sig contributor-experience
/sig testing
/assign @stevekuznetsov

@k8s-ci-robot k8s-ci-robot added 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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jul 11, 2023
@k8s-ci-robot k8s-ci-robot added area/prow Issues or PRs related to prow area/prow/plugins Issues or PRs related to prow's plugins for the hook component labels Jul 11, 2023
@MadhavJivrajani MadhavJivrajani force-pushed the fix-trigger-for-logic branch 3 times, most recently from 749697f to 98f1866 Compare July 11, 2023 12:00
@MadhavJivrajani
Copy link
Contributor Author

/hold
I'd also like sign-off on this by the GH admins.

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 11, 2023
@Priyankasaggu11929
Copy link
Member

Priyankasaggu11929 commented Jul 17, 2023

Hey @MadhavJivrajani, thanks for the PR.

Just trying to understand this better:

  1. Did the /retest command fail for add generic methods for integer package utils#280 (comment) because it went over the 30-day limit (of GH workflow retrigger)?
    Or because of the "org-level trigger" taking precedence over the "repo-level trigger"?
    Have we tested the later scenario?

  2. If we prioritize the repo-level trigger (like /retest) in cases like add generic methods for integer package utils#280 (comment), will it solve the problem of retriggering GitHub workflows even if it has been more than 30 days since the initial trigger?

    (I think no, based on what you mentioned earlier about the GH actions log retention policy)

    Or does /retest create a new run instead of retriggering the old GH action?

@MadhavJivrajani
Copy link
Contributor Author

MadhavJivrajani commented Jul 17, 2023

@Priyankasaggu11929 excellent points!
I was thinking about this a little more.

Regarding your first point, I thought I had /retested on multiple PRs, but evidently not. So to reconfirm my hypothesis, here's a PR I created for testing purposes to show that /retest is not working: kubernetes/utils#288

Regarding your second point, I agree that this might not help if the time window is outside of 30 days. What I thought we could do is: check if we get an appropriate error from the API, if we do, use prow to comment on the PR saying workflow is older than 30 days and link to GH docs, with a suggestion of what could be done.
Fwiw -- I do see that according to the GH API docs, the 2 error codes possible are 201 and 403, so maybe 403?

Copy link
Contributor

@stevekuznetsov stevekuznetsov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a number of other places where either org or repo-level config is allowed, and I think our convention is to make the repo-level config win out, so the intent here makes sense. This also seems to parallel what we do in ApproveFor and LgtmFor above. I can't say if this change to TriggerFor would be breaking in some way - @cjwagner can you think of anything?

@MadhavJivrajani can you make the implementation in TriggerFor match those in the other functions, for cohesiveness?

prow/plugins/config.go Outdated Show resolved Hide resolved
@MadhavJivrajani
Copy link
Contributor Author

@cjwagner 👋🏼
In case you can take a look here!

@cjwagner
Copy link
Member

cjwagner commented Jan 9, 2024

I can't say if this change to TriggerFor would be breaking in some way - @cjwagner can you think of anything?

It could technically be breaking since it does change behavior, but I can't imagine this being surprising. The only configs that would be affected by this probably intended for this to be the behavior from the beginning so this seems more like a fix.

@cjwagner 👋🏼
In case you can take a look here!

Generally LGTM, but please address Steve's feedback, especially the bit about matching the implementation in the other functions.

So far, `TriggerFor` prioristised returning org level trigger configs.
There might be cases where in a trigger would need to be configured
specifically for a repo (ex: allowing `/retest` to trigger GH workflows).
In cases like this, we should return the trigger that is defined at the
repo level, rather than its corresponding org level trigger.

We could "work around" the above constraint by simply defining the repo
level trigger higher up in the config, but then this trigger config would
shadow the org level trigger, which is not desirable.

This change returns a repo level trigger if it finds one, if not, it returns
the first org level trigger it sees (keeping in sync with the previous behaviour).

Fwiw - I'm not sure why multiple org level or multiple repo level triggers for the
same org or repo would be specified.

Signed-off-by: Madhav Jivrajani <madhav.jiv@gmail.com>
@MadhavJivrajani
Copy link
Contributor Author

Thanks @cjwagner!

@stevekuznetsov I've changed the implementation to how LgtmFor and ApproveFor implement it, could you PTAL? Thank you!

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 9, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: MadhavJivrajani, stevekuznetsov

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 9, 2024
@MadhavJivrajani
Copy link
Contributor Author

/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 9, 2024
@k8s-ci-robot k8s-ci-robot merged commit a3102cd into kubernetes:master Jan 9, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/prow/plugins Issues or PRs related to prow's plugins for the hook component area/prow Issues or PRs related to prow cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. 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. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants