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

Fallback to approvers as reviewers #7742

Merged
merged 2 commits into from
Jun 5, 2018

Conversation

grantr
Copy link
Contributor

@grantr grantr commented Apr 17, 2018

If the newly added blunderbuss option ApproverFallback is true ExcludeApprovers is false, the reviewer selection method will attempt to add approvers to the list if there aren't enough qualifying reviewers to satisfy the requested reviewer count.

While the implementation works and is tested with mixed approver and reviewer lists, this feature is most useful for projects that don't have a reviewer role and thus have OWNERS files containing only approver lists. Those projects should now enable the ApproverFallback option can rely on the default to have Blunderbuss select reviewers from approver lists.

/kind feature
/area prow

/assign @cjwagner
/cc @rsdcastro @fejta

Fixes #7691

@k8s-ci-robot k8s-ci-robot added kind/feature Categorizes issue or PR as related to a new feature. area/prow Issues or PRs related to prow labels Apr 17, 2018
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Apr 17, 2018
@fejta
Copy link
Contributor

fejta commented Apr 18, 2018

Can we just make the review list the union of approvers and reviewers?

@0xmichalis
Copy link
Contributor

I would argue for falling back to approvers by default (no config option).

@@ -61,6 +61,9 @@ func helpProvider(config *plugins.Configuration, enabledRepos []string) (*plugin
}

type ownersClient interface {
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like you should provide a different implementation of the ownersClient that returns approvers instead of duplicating methods

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍 I'll experiment with that approach.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@stevekuznetsov
Copy link
Contributor

/ok-to-test

@k8s-ci-robot k8s-ci-robot removed the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Apr 18, 2018
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 28, 2018
@fejta
Copy link
Contributor

fejta commented May 12, 2018

Please get this to pass tests?

@grantr
Copy link
Contributor Author

grantr commented May 13, 2018 via email

@grantr grantr force-pushed the blunderbuss-only-approvers branch from e6166ac to 6a7566f Compare May 16, 2018 23:08
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 16, 2018
@grantr
Copy link
Contributor Author

grantr commented May 16, 2018

Can we just make the review list the union of approvers and reviewers?

I would argue for falling back to approvers by default (no config option).

Where should the fallback live? Should the behavior of repoowners.RepoOwners change to always fallback by default? Should blunderbuss wrap RepoOwners with its specific union implementation?

@fejta
Copy link
Contributor

fejta commented May 17, 2018

If we make the reviewer set the combination of everyone in reviewers and approvers then we do not need a fallback option, right?

@cjwagner
Copy link
Member

If we make the reviewer set the combination of everyone in reviewers and approvers then we do not need a fallback option, right?

I don't think we should do that. We want to prioritize using the reviewers over the approvers and only use the approvers as a last resort if no reviewers are found. If we union the approvers and reviewers we can't distinguish them.

I think the fallback belongs in blunderbuss. Not all potential consumers of OWNERS file data from repoowners would want to have approvers returned in place of reviewers if reviewers are absent.

@grantr
Copy link
Contributor Author

grantr commented May 19, 2018

I removed the GetApprovers method and replaced it with an implementation that delegates to Approver methods. The existing ownersClient was renamed to reviewersClient:

type reviewersClient interface {
	FindReviewersOwnersForFile(path string) string
	Reviewers(path string) sets.String
	LeafReviewers(path string) sets.String
}

ownersClient was extended to include those methods plus the Approver methods:

type ownersClient interface {
	reviewersClient
	FindApproverOwnersForFile(path string) string
	Approvers(path string) sets.String
	LeafApprovers(path string) sets.String
}

That allows this implementation of reviewersClient to be passed to GetReviewers:

type fallbackReviewersClient struct {
	ownersClient
}

func (foc fallbackReviewersClient) FindReviewersOwnersForFile(path string) string {
	return foc.ownersClient.FindApproverOwnersForFile(path)
}

func (foc fallbackReviewersClient) Reviewers(path string) sets.String {
	return foc.ownersClient.Approvers(path)
}

func (foc fallbackReviewersClient) LeafReviewers(path string) sets.String {
	return foc.ownersClient.LeafApprovers(path)
}

@grantr
Copy link
Contributor Author

grantr commented May 19, 2018

What's the consensus on whether this should be enabled by default? Seems like @fejta, @Kargakis, and @cblecker think it should be the default. @cjwagner WDYT?

@cblecker
Copy link
Member

Yes to this as the default, provided that "no" we don't just union reviewers and approvers. Agree 100% with @cjwagner's comment. I haven't reviewed the PR/implementation, but just an opinion from the experience POV.

@fejta
Copy link
Contributor

fejta commented May 19, 2018

I disagree that approvers should not share the burden of reviewing code. People who do not review the code should not be approving the code.

The intent of the reviewer system is to support overloaded code owners, not create a caste system where as soon as we add a reviewer the approvers are forever freed from the burden of doing initial reviews.

@cblecker
Copy link
Member

Prow as a software product doesn’t need to dictate that, though. That situation would be solved by having that user in both the reviewer and the approver section (what we do in most places anyways).

This allows us to have the flexibility to allow a particular overloaded approver to drop from the frontline pool without revoking their approval rights.

@grantr grantr changed the title Optionally fallback to approvers as reviewers Fallback to approvers as reviewers May 24, 2018
@grantr
Copy link
Contributor Author

grantr commented May 24, 2018

I changed the name of the config option to ExcludeApprovers so the default behavior is now to fall back to approvers when necessary. I also cleaned up the duplicate fixtures in the tests so there's only one copy of each test case. Minor unrelated change: a warning is now logged when maxReviewers limits the number of reviewers requested, because I found that useful when debugging tests. RFAL.

@fejta I agree with you that making this explicit in OWNERS is probably a better solution, but a much more extensive one.

@cblecker
Copy link
Member

On this PR: it looks good to me. Falling back seems like a sane default. Should probably squash out commits before merge.

On the social friction bikeshed: I agree from a healthy ecosystem point of view, but I'm not convinced that embedding that prow is needed. Maintaining healthy reviewer/approver pools (ensuring reviewers and approvers are active and responsive) is more critical to me.

If there aren't enough qualified reviewers available (as determined by the
reviewer_count option), then fall back to using approvers as reviewers. This
is most useful for projects that don't have a reviewer role. Those projects
may now use OWNERS files containing only approvers lists.

This is now the default behavior, so approvers which are not in any reviewer
lists may now get review requests when they didn't before. To return to the
previous behavior of only considering reviewers, set the exclude_approvers
option to true.
@grantr grantr force-pushed the blunderbuss-only-approvers branch from ff84f72 to 48d7aae Compare May 25, 2018 20:01
@grantr
Copy link
Contributor Author

grantr commented May 25, 2018

Rebased.

Copy link
Contributor

@fejta fejta left a comment

Choose a reason for hiding this comment

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

/lgtm
/hold

I remain convinced that combining approvers and reviewers into the reviewer set is the right default, but we don't need to resolve this conflict in this PR. And falling back to approvers is certainly better than the current situation.

Thanks!

@@ -107,12 +131,28 @@ func handle(ghc githubClient, oc ownersClient, log *logrus.Entry, reviewerCount,
return err
}
if missing := *reviewerCount - len(reviewers); missing > 0 {
log.Warnf("Not enough reviewers found in OWNERS files for files touched by this PR. %d/%d reviewers found.", len(reviewers), reviewerCount)
log.Warnf("Not enough reviewers found in OWNERS files for files touched by this PR. %d/%d reviewers found.", len(reviewers), *reviewerCount)
Copy link
Contributor

Choose a reason for hiding this comment

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

should this only warn if excludeApprovers?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I moved this to warn after fallback to approvers (if enabled). WDYT?

}
}

if len(reviewers) > 0 {
if maxReviewers > 0 && len(reviewers) > maxReviewers {
log.Warnf("Limiting request of %d reviewers to %d maxReviewers.", len(reviewers), maxReviewers)
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems more like info to me

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed, fixed.

@k8s-ci-robot k8s-ci-robot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. 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 May 29, 2018
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 5, 2018
Copy link
Contributor Author

@grantr grantr left a comment

Choose a reason for hiding this comment

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

Thanks for the review @fejta! RFAL.

@@ -107,12 +131,28 @@ func handle(ghc githubClient, oc ownersClient, log *logrus.Entry, reviewerCount,
return err
}
if missing := *reviewerCount - len(reviewers); missing > 0 {
log.Warnf("Not enough reviewers found in OWNERS files for files touched by this PR. %d/%d reviewers found.", len(reviewers), reviewerCount)
log.Warnf("Not enough reviewers found in OWNERS files for files touched by this PR. %d/%d reviewers found.", len(reviewers), *reviewerCount)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I moved this to warn after fallback to approvers (if enabled). WDYT?

}
}

if len(reviewers) > 0 {
if maxReviewers > 0 && len(reviewers) > maxReviewers {
log.Warnf("Limiting request of %d reviewers to %d maxReviewers.", len(reviewers), maxReviewers)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed, fixed.

@grantr
Copy link
Contributor Author

grantr commented Jun 5, 2018

/retest

@grantr grantr closed this Jun 5, 2018
@grantr grantr reopened this Jun 5, 2018
@grantr
Copy link
Contributor Author

grantr commented Jun 5, 2018

/retest

@fejta
Copy link
Contributor

fejta commented Jun 5, 2018

/lgtm

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: fejta, grantr

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

@fejta
Copy link
Contributor

fejta commented Jun 5, 2018

/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 Jun 5, 2018
@k8s-ci-robot k8s-ci-robot merged commit aa73004 into kubernetes:master Jun 5, 2018
@grantr
Copy link
Contributor Author

grantr commented Jun 5, 2018

Should this be announced on any mailing lists, since it changes default behavior?

@grantr grantr deleted the blunderbuss-only-approvers branch June 5, 2018 22:21
@fejta
Copy link
Contributor

fejta commented Jun 5, 2018

We need to build and deploy a new prow before this takes effect.

Could you add a blurb to https://github.com/kubernetes/test-infra/blob/master/prow/ANNOUNCEMENTS.md?

grantr added a commit to grantr/test-infra that referenced this pull request Jun 5, 2018
@fejta
Copy link
Contributor

fejta commented Jun 5, 2018

Sent a note to https://groups.google.com/d/msg/kubernetes-sig-contribex/HnOdQ2ChBR4/8QSFCyGKAgAJ

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 Issues or PRs related to prow cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants