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

Skip failed LFS objects and continue when migrating LFS #31697

Closed
wants to merge 5 commits into from

Conversation

6543
Copy link
Member

@6543 6543 commented Jul 24, 2024

Partially fix #31137.

Continue #31623 ...

When migrating LFS objects, if there's any object that failed (like some objects are losted, which is not really critical), Gitea will stop migrating LFS immediately but treat the migration as successful.

This PR makes it ignore failed objects and continue migrating. It may not be the best way to handle it, but a better way.

And to ensure data integrity of LFS objects, we may need to add an option to fail the migration if there's any error in the feature.

@pull-request-size pull-request-size bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jul 24, 2024
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jul 24, 2024
@github-actions github-actions bot added the modifies/go Pull requests that update Go code label Jul 24, 2024
@6543 6543 requested a review from wolfogre July 24, 2024 12:06
@6543
Copy link
Member Author

6543 commented Jul 24, 2024

PS: the whole code is quite complex and not good to maintain ... it should be refactored into smaler chunks and probably into it's own submodule(s)

if m.Existing {
log.Trace("Repo[%-v]: LFS meta object %-v was already present", repo, m)
}
continue
Copy link
Member Author

Choose a reason for hiding this comment

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

this continue is not needed but make the code more redable ... at least a bit

@wolfogre
Copy link
Member

wolfogre commented Jul 25, 2024

Hmm, I would say it is a different idea from what I had in mind.

ErrLFSDownload is not clear enough to indicate the error.

I think I have to write my idea down to discuss ...


See #31702

wolfogre added a commit that referenced this pull request Jul 31, 2024
…ion (#31702)

Fix #31137.

Replace #31623 #31697.

When migrating LFS objects, if there's any object that failed (like some
objects are losted, which is not really critical), Gitea will stop
migrating LFS immediately but treat the migration as successful.

This PR checks the error according to the [LFS api
doc](https://github.com/git-lfs/git-lfs/blob/main/docs/api/batch.md#successful-responses).

> LFS object error codes should match HTTP status codes where possible:
> 
> - 404 - The object does not exist on the server.
> - 409 - The specified hash algorithm disagrees with the server's
acceptable options.
> - 410 - The object was removed by the owner.
> - 422 - Validation error.

If the error is `404`, it's safe to ignore it and continue migration.
Otherwise, stop the migration and mark it as failed to ensure data
integrity of LFS objects.

And maybe we should also ignore others errors (maybe `410`? I'm not sure
what's the difference between "does not exist" and "removed by the
owner".), we can add it later when some users report that they have
failed to migrate LFS because of an error which should be ignored.
GiteaBot pushed a commit to GiteaBot/gitea that referenced this pull request Jul 31, 2024
…ion (go-gitea#31702)

Fix go-gitea#31137.

Replace go-gitea#31623 go-gitea#31697.

When migrating LFS objects, if there's any object that failed (like some
objects are losted, which is not really critical), Gitea will stop
migrating LFS immediately but treat the migration as successful.

This PR checks the error according to the [LFS api
doc](https://github.com/git-lfs/git-lfs/blob/main/docs/api/batch.md#successful-responses).

> LFS object error codes should match HTTP status codes where possible:
> 
> - 404 - The object does not exist on the server.
> - 409 - The specified hash algorithm disagrees with the server's
acceptable options.
> - 410 - The object was removed by the owner.
> - 422 - Validation error.

If the error is `404`, it's safe to ignore it and continue migration.
Otherwise, stop the migration and mark it as failed to ensure data
integrity of LFS objects.

And maybe we should also ignore others errors (maybe `410`? I'm not sure
what's the difference between "does not exist" and "removed by the
owner".), we can add it later when some users report that they have
failed to migrate LFS because of an error which should be ignored.
lunny pushed a commit that referenced this pull request Jul 31, 2024
…ion (#31702) (#31745)

Backport #31702 by @wolfogre

Fix #31137.

Replace #31623 #31697.

When migrating LFS objects, if there's any object that failed (like some
objects are losted, which is not really critical), Gitea will stop
migrating LFS immediately but treat the migration as successful.

This PR checks the error according to the [LFS api
doc](https://github.com/git-lfs/git-lfs/blob/main/docs/api/batch.md#successful-responses).

> LFS object error codes should match HTTP status codes where possible:
> 
> - 404 - The object does not exist on the server.
> - 409 - The specified hash algorithm disagrees with the server's
acceptable options.
> - 410 - The object was removed by the owner.
> - 422 - Validation error.

If the error is `404`, it's safe to ignore it and continue migration.
Otherwise, stop the migration and mark it as failed to ensure data
integrity of LFS objects.

And maybe we should also ignore others errors (maybe `410`? I'm not sure
what's the difference between "does not exist" and "removed by the
owner".), we can add it later when some users report that they have
failed to migrate LFS because of an error which should be ignored.

Co-authored-by: Jason Song <[email protected]>
@lunny
Copy link
Member

lunny commented Aug 1, 2024

replaced by #31702

@lunny lunny closed this Aug 1, 2024
@6543 6543 deleted the bugfix/migrate_lfs branch August 1, 2024 11:52
@go-gitea go-gitea locked as resolved and limited conversation to collaborators Oct 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. modifies/go Pull requests that update Go code size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrating repo with LFS causes 500 error
4 participants