Skip to content

Cryptic error message when git is not available #1239

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

Closed
gecube opened this issue Sep 19, 2023 · 10 comments · Fixed by fluxcd/pkg#678 or #1271
Closed

Cryptic error message when git is not available #1239

gecube opened this issue Sep 19, 2023 · 10 comments · Fixed by fluxcd/pkg#678 or #1271

Comments

@gecube
Copy link

gecube commented Sep 19, 2023

Hi!

I got the next error message:

{"level":"error","ts":"2023-09-19T22:10:07.384Z","msg":"failed to checkout and determine revision: unable to list remote for 'ssh://git@****/zodia/infra/kubernetes': unknown error: remote: ","controller":"gitrepository","controllerGroup":"source.toolkit.fluxcd.io","controllerKind":"GitRepository","GitRepository":{"name":"flux-system","namespace":"flux-system"},"namespace":"flux-system","name":"flux-system","reconcileID":"ae69a081-4408-49c3-abe5-f37135fc1573","error":"failed to checkout and determine revision: unable to list remote for 'ssh://git@****/zodia/infra/kubernetes': unknown error: remote: "}

I am sure that in that very moment GitLab was not available, so it means network error. Unfortunately, it is completely opaque what happened from the error message.

My expectations: the error message will clearly state that git repo source is not available (due to network error).

@gecube
Copy link
Author

gecube commented Sep 19, 2023

The same error message in slack:

Screenshot 2023-09-20 at 0 24 14

@makkes
Copy link
Member

makkes commented Sep 20, 2023

The underlying error is generated by go-git here.

@gecube
Copy link
Author

gecube commented Sep 20, 2023

@makkes agree, thanks for prompt answer. Are there any chances for easy fix?

@makkes
Copy link
Member

makkes commented Sep 20, 2023

This is an example message from GitLab:

remote: 
remote: ========================================================================
remote: 
remote: ERROR: The project you were looking for could not be found or you don't have permission to view it.

remote: 
remote: ========================================================================
remote: 
fatal: Could not read from remote repository.

The issue is that go-git only returns the first line of the message returned from the remote and in this case this line isn't very useful

@darkowlzz
Copy link
Contributor

Hi, I started looking into it earlier and then got into something else. Getting back to it, looks like we have all the necessary clues about the problem above. In our go-git wrapper, we have a function that's specifically made to handle such errors goGitError().
Wrapping the code that returns the above error with goGitError() would provide a little better error.
But reading the current implementation of goGitError() I think it was initially written to be used for push operations only, maybe for image-automation-controller. Now that we have this in a get remote head call, it'll be better to change the error to something more appropriate.

@makkes
Copy link
Member

makkes commented Sep 20, 2023

In this case (GitLab apparently unavailable) the message "check git secret has write access" would be plain misleading. The remote: message can potentially be caused by all kinds of issues.

I would much rather improve (and rename) the checkNotFoundError message to catch more of the most common errors.

@pjbgf
Copy link
Member

pjbgf commented Sep 20, 2023

@makkes the handling of error descriptions from the server for http is slightly better than for ssh, as it try to provide that information back to the user. I would be more than happy to review a PR to improve that for ssh upstream.

@gecube
Copy link
Author

gecube commented Oct 4, 2023

Colleagues, any progress? Is there anything that I could test?

@makkes
Copy link
Member

makkes commented Oct 6, 2023

I created a draft PR to mitigate this situation in go-git. /cc @pjbgf

@makkes
Copy link
Member

makkes commented Oct 12, 2023

go-git PR has been merged so next up is bumping the go-git version as soon as a new version has been released.

makkes pushed a commit to fluxcd/pkg that referenced this issue Oct 26, 2023
This will fix fluxcd/source-controller#1239

Signed-off-by: Max Jonas Werner <mail@makk.es>
makkes pushed a commit to fluxcd/pkg that referenced this issue Oct 26, 2023
This will fix fluxcd/source-controller#1239

Signed-off-by: Max Jonas Werner <mail@makk.es>
makkes pushed a commit to fluxcd/pkg that referenced this issue Oct 26, 2023
This will fix fluxcd/source-controller#1239

Signed-off-by: Max Jonas Werner <mail@makk.es>
@makkes makkes reopened this Oct 26, 2023
makkes pushed a commit that referenced this issue Oct 26, 2023
fixes #1239

Signed-off-by: Max Jonas Werner <mail@makk.es>
makkes pushed a commit that referenced this issue Oct 26, 2023
fixes #1239

Signed-off-by: Max Jonas Werner <mail@makk.es>
makkes pushed a commit that referenced this issue Oct 26, 2023
fixes #1239

Signed-off-by: Max Jonas Werner <mail@makk.es>
makkes pushed a commit that referenced this issue Nov 8, 2023
fixes #1239

Signed-off-by: Max Jonas Werner <mail@makk.es>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants