-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[server] Improve logging / error messages of GitLab app and context parser #4747
Conversation
break; | ||
} | ||
if (GitLab.ApiError.is(possibleTags)) { | ||
throw new Error(`GitLab ApiError on searching for possible tags for ${owner}/${repoName}/tree/${segments.join('/')}: ${possibleTags}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
@@ -214,29 +214,31 @@ export class GitlabContextParser extends AbstractContextParser implements IConte | |||
const possibleBranches = await this.gitlabApi.run<GitLab.Branch[]>(user, async g => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why so complicated?
there is https://docs.gitlab.com/ee/api/branches.html#get-single-repository-branch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is, that we don't know what of the segments is part of the branch and what is part of the file tree.
For example this context URL:
corneliusludmann/important-issue-1
is the branch andtest-dir-1
is the file path.
But we cannot know this having just the context URL. It could also be that:
corneliusludmann
is the branch andimportant-issue-1/test-dir-1
is the file path.
We don't know this until we check for all possible branches that start with the first segement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this is the root cause of the issue here. A lucky shot revealed that some/lot of projects are structuring their branches in feature/9999_something
patterns.
In L.212 we're searching for ^feature
branches, which in many cases will be a large set of branches. Unfortunately, there is pagination in the GL REST API unconsidered here at: https://docs.gitlab.com/ee/api/#pagination
So, we always see only some of the feature*
branches (maybe just 20.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is an interesting thought! Indeed, pagination could be the problem here. 💡
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@corneliusludmann thanks for the explanation. I forgot about this dilemma.
Still, in that case we need a retry strategy with get-single-repository-branch
calls and path prefix' in in ascending order, i.e. call it for seg1
, seg1/seg2
, seg1/seg2/seg3
, etc. This is still less expensive than filtering n
search calls.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you post such a case, please? It doesn't sound right. We can file an issue for GitLab.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you post such a case, please? It doesn't sound right.
https://gitlab.com/gp-test-group/gp-test-subgroup/gp-test-project-in-subgroup/-/tree/corneliusludmann
is one
We can file an issue for GitLab.
Exactly. I have it already on my to-do list.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GitLab issue: https://gitlab.com/gitlab-org/gitlab/-/issues/335867
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🥇 Awesome! Thanks for taking care of this and providing details to GitLab!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
quick note on the response 500.
I've seen spikes of request times in server's logs. instead of regular ~300ms it took ~5s, which after checking turned out to be the response 500.
the it was a show branch request for foo
, where foo
does not exist but foo/bar
does. this appears to be a real bug in GitLab.
5adc4ee
to
7785a6c
Compare
1c635db
to
f769375
Compare
/werft run 👍 started the job as gitpod-build-clu-improve-logging-gitlab.16 |
@corneliusludmann this change breaks context parser tests, unfortunately. |
@corneliusludmann, you can run the tests with
|
Ah, it skips it when the env var is not set. That explains why it didn't fail for me. 🙄 Thanks for the hint. |
Try the conjunction of all segments as branch/tag name first before searching for parts of the branch/tag. That hopefully decreases the number of needed API calls.
f769375
to
36ff6c2
Compare
Stupid me. Sorry for not recognizing this and thanks for carefully reviewing the PR, @AlexTugarev. 👍 I've fixed this and updated the PR. There is still a failing test but this test fails on |
/werft run 👍 started the job as gitpod-build-clu-improve-logging-gitlab.18 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'Tested with positive and negative examples and it worked nicely!
Thanks for fixing this, @corneliusludmann!
🎉 🎉 🎉
Improves the logging resp. error messages in the GitLab app resp. context parser. This hopefully gives us more insights into issue #4333.