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

Expose malformed status contexts on PR HEAD commit #7454

Merged

Conversation

stevekuznetsov
Copy link
Contributor

When all labels are appropriately present or absent on a PR, tide will
still not merge the PR unless all status contexts are passing. We need
to expose non-passing status contexts on the HEAD commit of the PR so
this is clear to users.

Signed-off-by: Steve Kuznetsov skuznets@redhat.com

Fixes #7449
/area prow
/kind bug
/cc @Kargakis @fejta
/assign @cjwagner @BenTheElder

@k8s-ci-robot k8s-ci-robot added area/prow Issues or PRs related to prow kind/bug Categorizes issue or PR as related to a bug. labels Mar 28, 2018
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Mar 28, 2018
@stevekuznetsov
Copy link
Contributor Author

I didn't use headContexts() since this seems like a best-effort sort of thing and a waste of tokens if we end up with PRs that we need to call out for. But that can be refactored, I don't feel strongly.

sort.Strings(malformedContexts)
trunced := truncate(malformedContexts)
if len(trunced) == 1 {
desc = fmt.Sprintf(" Job %s has not succeeded.", trunced[0])
Copy link
Contributor

Choose a reason for hiding this comment

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

Hrm, what about the cla check context?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Don't we block on it today?

Copy link
Contributor

Choose a reason for hiding this comment

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

Nevermind, I guess it's a job.

var malformedContexts []string
for _, commit := range pr.Commits.Nodes {
if commit.Commit.OID == pr.HeadRefOID {
for _, status := range commit.Commit.Status.Contexts {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you also pick up the tide context?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, yes

Copy link
Contributor

Choose a reason for hiding this comment

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

add this case to the unit tests?

if commit.Commit.OID == pr.HeadRefOID {
for _, status := range commit.Commit.Status.Contexts {
if status.State != githubql.StatusStateSuccess {
malformedContexts = append(malformedContexts, string(status.Context))
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are unsuccessful contexts malformed? This makes me think they are corrupted

var malformedContexts []string
for _, commit := range pr.Commits.Nodes {
if commit.Commit.OID == pr.HeadRefOID {
for _, status := range commit.Commit.Status.Contexts {
Copy link
Contributor

Choose a reason for hiding this comment

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

add this case to the unit tests?

@stevekuznetsov stevekuznetsov force-pushed the skuznets/report-contexts branch from fce8950 to 33e7dc4 Compare March 29, 2018 16:32
@stevekuznetsov
Copy link
Contributor Author

@fejta @Kargakis updated

@cjwagner how do you feel about this being "best-effort" or would you rather see me use headContexts() here?

@cjwagner
Copy link
Member

@stevekuznetsov The current usage of headContexts could already be prohibitively expensive for k/k...

I'd prefer to find a way to make headContexts less wasteful:

  • We could do this trivially with a proxy cache layer.
  • We could cache the statuses for a commit, but only if we make tide receive status webhooks and invalidate the cache entry for a commit when a status is updated. This isn't a good option because if we miss a status webhook, tide could operate on stale data.

@stevekuznetsov
Copy link
Contributor Author

@cjwagner OK, that is understood. I think those approaches are probably useful, but orthogonal to the changes here. Given your response I continue to be confident that not using the headContexts() call is appropriate in the status controller.

The test flaked on:

W0329 16:33:27.573] ERROR: (gcloud.auth.activate-service-account) There was a problem refreshing your current auth tokens: Unable to find the server at accounts.google.com

/retest

@cjwagner @fejta any other comments?

@@ -246,11 +247,34 @@ func requirementDiff(pr *PullRequest, q *config.TideQuery) (string, int) {
desc = fmt.Sprintf(" Should not have %s labels.", strings.Join(trunced, ", "))
}
}
diff = len(missingLabels) + len(presentLabels)

if desc == "" {
Copy link
Member

Choose a reason for hiding this comment

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

We still need to check for unsuccessful contexts in order to return a correct diff even if we already have a message to use for the status description.

}
}
}
if len(contexts) > 0 {
Copy link
Member

Choose a reason for hiding this comment

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

if desc == "" && len(contexts) > 0 {

} else {
desc = fmt.Sprintf(" Jobs %s have not succeeded.", strings.Join(trunced, ", "))
}
diff = len(contexts)
Copy link
Member

Choose a reason for hiding this comment

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

s/=/+=/

When all labels are appropriately present or absent on a PR, `tide` will
still not merge the PR unless all status contexts are passing. We need
to expose non-passing status contexts on the `HEAD` commit of the PR so
this is clear to users.

Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>
@stevekuznetsov stevekuznetsov force-pushed the skuznets/report-contexts branch from 33e7dc4 to 1ac67f2 Compare March 29, 2018 22:21
@stevekuznetsov
Copy link
Contributor Author

@cjwagner your approach to the diff count makes a lot of sense. Updated.

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 29, 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.

/lgtm

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cjwagner, 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 merged commit 91135c5 into kubernetes:master Mar 29, 2018
sebastienvas added a commit to sebastienvas/k8s-test-infra that referenced this pull request Mar 30, 2018
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/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. 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.

6 participants