Repository: jenkins-x/lighthouse
Pull request #1131 (2020-10-27 05:16:18)

fix: log failure raison since not possible to sent to gitlab
Signed-off-by: Youssef El Houti <youssef.elhouti@gmail.com>

jenkins-x-bot: Hi @yelhouti. Thanks for your PR.

I'm waiting for a [jenkins-x](https://github.com/orgs/jenkins-x/people) member to verify that this patch is reasonable to test. If it is, they should reply with `/ok-to-test` on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should [join the org](https://github.com/orgs/jenkins-x/people) to skip this step.

Once the patch is verified, the new status will be reflected by the `ok-to-test` label.

I understand the commands that are listed [here](https://go.k8s.io/bot-commands?repo=jenkins-x%2Flighthouse).

<details>

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md).  If you have questions or suggestions related to my behavior, please file an issue against the [jenkins-x/lighthouse](https://github.com/jenkins-x/lighthouse/issues/new?title=Command%20issue:) repository.
</details>

jenkins-x-bot: [APPROVALNOTIFIER] This PR is **NOT APPROVED**

This pull-request has been approved by:
To complete the [pull request process](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process), please assign **dgozalo**
You can assign the PR to them by writing `/assign @dgozalo` in a comment when ready.

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=jenkins-x%2Flighthouse).

<details open>
Needs approval from an approver in each of these files:

- **[OWNERS](https://github.com/jenkins-x/lighthouse/blob/master/OWNERS)**

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":["dgozalo"]} -->
yelhouti: /assign @dgozalo
jstrachan: /ok-to-test
jstrachan: I'm cool with this workaround for now (to avoid barfing with keeper state changes on gitlab).

You mentioned `GitLab doesn't like updating status description without a state change` - I just wondered if we could make a state change for gitlab so that we can update the status. I guess that would mean some kind of commit or is there another way of making a state change on gitlab so that we can update the status? (e.g. a comment/label or anything else?)
jenkins-x-bot: @yelhouti: The following test **failed**, say `/retest` to rerun them all:

Test name | Commit | Details | Rerun command
--- | --- | --- | ---
jenkins | 482ce28e0e789425c8d8db6ddbc0a447b5934488 | [link](https://dashboard-jx.jenkins-x.live/teams/jx/projects/jenkins-x/lighthouse/PR-1131/4) | `/test jenkins`

[View all Builds for this Pull Request](https://dashboard-jx.jenkins-x.live/teams/jx/projects/jenkins-x/lighthouse/PR-1131) 

<details>

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md).  If you have questions or suggestions related to my behavior, please file an issue against the [jenkins-x/lighthouse](https://github.com/jenkins-x/lighthouse/issues/new?title=Command%20issue:) repository. I understand the commands that are listed [here](https://go.k8s.io/bot-commands).
</details>
<!-- test report -->
yelhouti: /do-not-merge
yelhouti: I guess we can switch tu running then back to pending, I will try that later
jstrachan: /retest
abayer: /lgtm
jenkins-x-bot: [APPROVALNOTIFIER] This PR is **APPROVED**

This pull-request has been approved by: *[abayer](https://github.com/jenkins-x/lighthouse/pull/1131#issuecomment-717225313 "LGTM")*

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=jenkins-x%2Flighthouse).

The pull request process is described [here](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process)

<details >
Needs approval from an approver in each of these files:

- ~~[OWNERS](https://github.com#issuecomment-717225313/jenkins-x/lighthouse/blob/master/OWNERS)~~ [abayer]

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":[]} -->

Patch:
diff --git a/pkg/keeper/status.go b/pkg/keeper/status.go
index fb2ab99a..770aaa86 100644
--- a/pkg/keeper/status.go
+++ b/pkg/keeper/status.go
@@ -234,7 +234,7 @@ func requirementDiff(pr *PullRequest, q *keeper.Query, cc contextChecker) (strin
 // in order to generate a diff for the status description. We choose the query
 // for the repo that the PR is closest to meeting (as determined by the number
 // of unmet/violated requirements).
-func expectedStatus(queryMap *keeper.QueryMap, pr *PullRequest, pool map[string]prWithStatus, cc contextChecker, blocks blockers.Blockers, providerType string) (string, string) {
+func expectedStatus(queryMap *keeper.QueryMap, pr *PullRequest, pool map[string]prWithStatus, cc contextChecker, blocks blockers.Blockers, providerType string, log *logrus.Entry) (string, string) {
 	if _, ok := pool[pr.prKey()]; !ok {
 		// if the branch is blocked forget checking for a diff
 		blockingIssues := blocks.GetApplicable(string(pr.Repository.Owner.Login), string(pr.Repository.Name), string(pr.BaseRef.Name))
@@ -261,6 +261,7 @@ func expectedStatus(queryMap *keeper.QueryMap, pr *PullRequest, pool map[string]
 		}
 		// GitLab doesn't like updating status description without a state change.
 		if providerType == "gitlab" {
+			log.Infof("gitlab: expectedStatus failed for repository %s pr#%d with reason: %s", pr.Repository.NameWithOwner, pr.Number, minDiff)
 			minDiff = ""
 		}
 		return scmprovider.StatusPending, fmt.Sprintf(statusNotInPool, minDiff)
@@ -334,7 +335,7 @@ func (sc *statusController) setStatuses(all []PullRequest, pool map[string]prWit
 			return
 		}
 
-		wantState, wantDesc := expectedStatus(queryMap, pr, pool, cr, blocks, sc.spc.ProviderType())
+		wantState, wantDesc := expectedStatus(queryMap, pr, pool, cr, blocks, sc.spc.ProviderType(), log)
 		var actualState githubql.StatusState
 		var actualDesc string
 		for _, ctx := range contexts {


Test patch:
diff --git a/pkg/keeper/status_test.go b/pkg/keeper/status_test.go
index 14dfe6b9..355a81c5 100644
--- a/pkg/keeper/status_test.go
+++ b/pkg/keeper/status_test.go
@@ -305,7 +305,7 @@ func TestExpectedStatus(t *testing.T) {
 			}
 			blocks.Repo[blockers.OrgRepo{Org: "", Repo: ""}] = items
 
-			state, desc := expectedStatus(queriesByRepo, &pr, pool, &keeper.ContextPolicy{}, blocks, "fake")
+			state, desc := expectedStatus(queriesByRepo, &pr, pool, &keeper.ContextPolicy{}, blocks, "fake", nil)
 			if state != tc.state {
 				t.Errorf("Expected status state %q, but got %q.", string(tc.state), string(state))
 			}