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

Migrate label-unapproved-picks from mungegithub to prow #9128

Merged

Conversation

nikhita
Copy link
Member

@nikhita nikhita commented Aug 22, 2018

This PR migrates the label-unapproved-picks munger from mungegithub to prow. Ref: #3331.

The original munger did not contain any tests. This PR also adds tests for it.

This PR also makes the plugin configurable:

  • The branch name against which PRs should be treated as cherrypicks can now be specified as a regexp.
  • The comment that the plugin comments with while adding the do-not-merge/cherry-pick-not-approved label can be specified.

This PR also updates the label name from cherrypick-unapproved to cherry-pick-unapproved.

The content below this line was originally what the PR was based on. This PR contains the following change as well i.e. it updates the comment body to list the patch release managers.


Ref: kubernetes/community#994 (comment). Note: this does not assign the patch release manager, just suggests them so that it's not too noisy for the release manager. Sometimes it's also useful to assign the release manager only after the cherrypick PR has received lgtm + approval.

Part of #1795

If a cherrypick PR does not have the cherrypick-approved label, the comment (by the bot) just lists that this label does not exist on the PR and adds a do-not-merge/cherry-pick-not-approved label. It does not tell us what needs to be done for cherrypick approval. See kubernetes/kubernetes#67616 (comment) for an example.

This PR updates the comment to point to the list of patch release managers so the author of the PR can know whom to assign to get the cherrypick approved.

/sig release
/sig contributor-experience

@k8s-ci-robot k8s-ci-robot added sig/release Categorizes an issue or PR as relevant to SIG Release. sig/contributor-experience Categorizes an issue or PR as relevant to SIG Contributor Experience. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. area/mungegithub area/prow Issues or PRs related to prow labels Aug 22, 2018
@nikhita
Copy link
Member Author

nikhita commented Aug 22, 2018

/cc @cblecker @guineveresaenger
contribex 🦇 signal

/cc @tpepper @spiffxp

@nikhita nikhita force-pushed the cherrypick-approve-suggest-patchmanager branch from ec47bb2 to 74bae8c Compare August 22, 2018 19:16
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Aug 22, 2018
@spiffxp
Copy link
Member

spiffxp commented Aug 22, 2018

I get the utility, but I also really don't want any more mungegithub maintenance. Can we instead port this to a prow plugin?

@nikhita
Copy link
Member Author

nikhita commented Aug 22, 2018

Can we instead port this to a prow plugin?

@spiffxp would this mean porting all the cherrypick-related components here: https://github.com/kubernetes/test-infra/tree/master/mungegithub/mungers?

@spiffxp
Copy link
Member

spiffxp commented Aug 22, 2018

overhauling cherrypicking is a much larger task, not trying to blow your scope (and I want to discuss this with patch managers)

I think I'm just asking to port this munger

EDIT: yes, I am, label-unapproved-picks is the only cherrypick related munger that's actively deployed by misc-mungers. The larger discussion we need to have is whether http://cherrypick.k8s.io/ is used by any of the patch managers

@nikhita
Copy link
Member Author

nikhita commented Aug 22, 2018

@spiffxp 👍

I'll take a dab at porting it to prow tomorrow (it's 1am here 🙃)

@spiffxp
Copy link
Member

spiffxp commented Aug 22, 2018

Really appreciate it. If it turns out to be too much of a pain, and this is really necessary to move us forward, we can look at merging. But I think this is the (or very nearly the) last piece of mungegithub to be ported over. And the bonfire will be glorious.

@nikhita nikhita force-pushed the cherrypick-approve-suggest-patchmanager branch from 74bae8c to 4476950 Compare August 23, 2018 15:18
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Aug 23, 2018
@nikhita nikhita changed the title mungegithub: point to list of patch release managers Migrate label-unapproved-picks from mungegithub to prow Aug 23, 2018
@nikhita
Copy link
Member Author

nikhita commented Aug 23, 2018

@spiffxp Done!

This original munger did not contain any tests. This PR adds tests too.

PS: I got confused by your edit 🙈 and ported only the label-unapproved-picks munger. Let me know if you were looking to port all of them!

@nikhita nikhita force-pushed the cherrypick-approve-suggest-patchmanager branch from 4476950 to 7ba56e0 Compare August 23, 2018 15:29
obj.WriteComment(labelUnapprovedBody)
}

func (LabelUnapprovedPicks) isStaleIssueComment(obj *github.MungeObject, comment *githubapi.IssueComment) bool {
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure what this does? I didn't add anything related to this to the plugin for now.

Copy link
Contributor

Choose a reason for hiding this comment

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

This was the old comment cleanup mechanism

// Package cherrypick adds the `do-not-merge/cherry-pick-not-approved`
// label to PRs against a release branch which do not have the
// `cherrypick-approved` label.
package cherrypick
Copy link
Member Author

@nikhita nikhita Aug 23, 2018

Choose a reason for hiding this comment

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

Should the name be cherrypick-unapproved or something like that? (ditto for pluginName)

Copy link
Member

Choose a reason for hiding this comment

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

We an external cherrypicker plugin that implements a /cherrypick command so yeah, this package/plugin should be named something else to avoid confusion.

Not sure what off the top of my head though. Will review and come back

Copy link
Member

Choose a reason for hiding this comment

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

cherrypick-unapproved sounds reasonable as a plugin name. Package names can't have hyphens though so the package would be cherrypickunapproved.


func handlePR(gc githubClient, log *logrus.Entry, pr *github.PullRequestEvent) error {
// Only consider the events that indicate opening of the PR
if pr.Action != github.PullRequestActionOpened && pr.Action != github.PullRequestActionReopened {
Copy link
Member Author

Choose a reason for hiding this comment

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

PTAL if this right.

Copy link
Member

Choose a reason for hiding this comment

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

This also needs to handle events where pr.Action is the label or unlabel action and pr.Label is the cherrypick-approved label.

@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 Aug 24, 2018
Copy link
Member

@cjwagner cjwagner left a comment

Choose a reason for hiding this comment

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

Just a couple nits.
/lgtm
/hold

}

// shouldPrune finds comments left by this plugin.
func shouldPrune(log *logrus.Entry, commentBody string) func(github.IssueComment) bool {
Copy link
Member

Choose a reason for hiding this comment

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

log is not used.
You could just get rid of this entire function now and pass this value to PruneComments instead:

func(comment github.IssueComment) bool {
	return strings.Contains(comment.Body, comment)
}

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

labels, err := gc.GetIssueLabels(org, repo, pr.Number)
if err != nil {
log.WithError(err).Errorf("failed to list labels")
return err
Copy link
Member

Choose a reason for hiding this comment

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

The returned error will be logged so the log message here is redundant.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

@k8s-ci-robot k8s-ci-robot added lgtm "Looks good to me", indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Aug 24, 2018
@nikhita nikhita force-pushed the cherrypick-approve-suggest-patchmanager branch from 79afa70 to 030e08a Compare August 24, 2018 20:37
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 24, 2018
Copy link
Member

@cjwagner cjwagner left a comment

Choose a reason for hiding this comment

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

Thanks again for migrating this!
/lgtm

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cjwagner, nikhita

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

@cjwagner
Copy link
Member

/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 Aug 24, 2018
@k8s-ci-robot
Copy link
Contributor

@nikhita: Updated the label-config configmap using the following files:

  • key labels.yaml using file label_sync/labels.yaml

In response to this:

This PR migrates the label-unapproved-picks munger from mungegithub to prow. Ref: #3331.

The original munger did not contain any tests. This PR also adds tests for it.

This PR also makes the plugin configurable:

  • The branch name against which PRs should be treated as cherrypicks can now be specified as a regexp.
  • The comment that the plugin comments with while adding the do-not-merge/cherry-pick-not-approved label can be specified.

This PR also updates the label name from cherrypick-unapproved to cherry-pick-unapproved.

The content below this line was originally what the PR was based on. This PR contains the following change as well i.e. it updates the comment body to list the patch release managers.


Ref: kubernetes/community#994 (comment). Note: this does not assign the patch release manager, just suggests them so that it's not too noisy for the release manager. Sometimes it's also useful to assign the release manager only after the cherrypick PR has received lgtm + approval.

Part of #1795

If a cherrypick PR does not have the cherrypick-approved label, the comment (by the bot) just lists that this label does not exist on the PR and adds a do-not-merge/cherry-pick-not-approved label. It does not tell us what needs to be done for cherrypick approval. See kubernetes/kubernetes#67616 (comment) for an example.

This PR updates the comment to point to the list of patch release managers so the author of the PR can know whom to assign to get the cherrypick approved.

/sig release
/sig contributor-experience

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@nikhita
Copy link
Member Author

nikhita commented Aug 26, 2018

Cherry-picks are not getting merged right now because the cherry-pick labels were updated from cherrypick-approved to cherry-pick-approved. The label changes were made across the repos immediately (#9128 (comment)).

However, prow was not bumped. The current prow code looks for a cherrypick-approved label and if it doesn't find it, it applies the do-not-merge/cherry-pick-not-approved label. Once prow is bumped, the code will look for the cherry-pick-approved label and remove the do-not-merge label.

Also, even after prow is bumped, all such PRs (https://github.com/kubernetes/kubernetes/labels/cherry-pick-approved) will need a trigger in terms of changing the cherrypick labels or closing/reopening the PR. I'll take care of closing+reopening all the affected ones. 👍

Can some someone bump prow to get this fixed?

@stevekuznetsov
Copy link
Contributor

Firstly, thanks @nikhita for the migration!! The work is very appreciated. For the label migration, we can use the label_sync tool to migrate one label to another. Hopefully the doc is sufficient to explain how the config should be changed, but otherwise @fejta is a good contact.

@stevekuznetsov
Copy link
Contributor

(But of course a bump to Prow is also necessary, contact the on-call for that.)

@nikhita
Copy link
Member Author

nikhita commented Aug 26, 2018

For the label migration, we can use the label_sync tool to migrate one label to another.

@stevekuznetsov The change to labels.yaml was done in this PR and the labels have already been migrated. :) Ref: #9128 (comment).

(But of course a bump to Prow is also necessary, contact the on-call for that.)

Have reached out on Slack about this. 👍

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/label_sync Issues or PRs related to code in /label_sync 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/release Categorizes an issue or PR as relevant to SIG Release. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants