-
-
Notifications
You must be signed in to change notification settings - Fork 374
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
Fix repository sync aborts after a signle repo failed #651
Fix repository sync aborts after a signle repo failed #651
Conversation
NOTE: We have to look at the api go client too ... so we do not break some CLI client features |
Thanks for the info! I'll have a look myself. Unfortunately, the tests didn't report anything (i.e. succeeded). |
@jdoubleu linting failed |
6af1d96
to
8f3d8b9
Compare
log.Debug().Msgf("could not fetch permission of repo '%s': %v", repo.FullName, err) | ||
hasErrors = true | ||
continue |
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.
As this code solves a somehow "different" problem, I would suggest to just log the error as debug and ignore it otherwise. So we just keep these 3 lines of code for now.
log.Debug().Msgf("could not fetch permission of repo '%s': %v", repo.FullName, err) | |
hasErrors = true | |
continue | |
// TODO: report errors again after #648 got solved | |
log.Debug().Msgf("could not fetch permission of repo '%s': %v", repo.FullName, err) | |
continue |
I would go even future - sory that I think your current way to approach well need refactor once we do it properly ... :/ so I would propose:
for later (of course you can start with now - but it's feature freeze and so It wont make it in upcomming release): |
tldr: for a hotfix this is a lot of code that will be useless once done properly |
okay, I can do this in a separate PR and just close this one.
yes, this definitely needs some thinking. I don't think I'm currently able to fix that, because I'm not familiar with the internal models/structure, yet. @anbraten the reason I chose to always report an error is because I'd like to give the user feedback. At least display a generic error if something failed, otherwise nothing would happen, which is very confusing.
I don't think so, since it is a mechanism to catch any error (e.g. timeouts or other permission errors) and report it back to the user. Sure, when #648 is fixed, there are no more errors for me, hopefully. What if the sync fails for someone else for whatever reason? I'm not 100% confident with my changes, specifically introducing the |
I've pushed the fix in the API client to this branch. It would be nice to be able to share types between the server and client and not have them in different files: |
@jdoubleu I had a short look on the error with sub-group-repos and will create a PR to fix it.
We should find a solution for that. ATM we either throw an error or return some data. In this specific case I would throw an error if any of the repos can not be loaded, normally there shouldn't be an error with only some repos otherwise it is probably an error we need to fix like #648. |
If we do it the "rest api way" we should not change data struct but return different http status code with an error struct. so either 2XX & data OR 4/5XX and error data |
I would propose to invent a generic error type: type ErrorResponse struct {
Error string // error name like "timeout" ...
Message string // optional, describe things if posible
} ☝️ with can be extended by optional fields for specific needs if needed status 500 has only a generic error anymore and only a message if in debug mode or auth user is admin -> it should only be reported back if the system got an error that is caused by issues only instance admins can fix (database is down, ...) |
We either share types with client and api OR api and database. |
tldf: your change to the api is nice for javascript ... just a add an attribute ... but not for api architecture
|
Thank you for the feedback!
My concern is that the sync process can be fragile, especially when you try to sync lots of repos (500+ in my case). While I didn't experience any errors besides the reported, I can totally imagine one (GitLab) API request to timeout or fail for whatever reason. If that happens too often, maybe due to network congestion, it prevents a user from syncing their repos at all.
I can understand that's a problem. Is it possible to employ some build steps for the client, which can output/copy the types to the client lib? On the other hand, that would make it more complex to build/use.
So when there's an error, the API should return a |
the example "timeout" should be handled by woodpecker and not reported back ... in this case "with sleep & retry's" |
not a bad idea, we should do it similar to code format:
☝️ wana create an issue ;) - else I'll do |
Regarding the shared-types discussion I would link to #292 as that would allow us to automatically create a go and js / ts api client with proper types.
Totally agree on that. It helps to keep code simple as well. |
please, go ahead @6543 I was thinking on something similar to TypeScript which can produce a |
@jdoubleu not done jet but it's done via git tagging |
tag example: https://gitea.com/gitea/go-sdk/tags |
Implements #651 (comment), partly fixes #648
This PR fixes the issue, where the whole repository sync process would be canceled if only one repository fails to sync.
It thereby partly fixes, or circumvents, #648 as described (see item 1).
In order to display an additional status/error message after syncing, I had to change the API response types/schemas to include an optional message string (see
RepoList
types both in the frontend and the server). I'm not 100% happy with how I named that type though.