Skip to content

Rework create/fork/adopt/generate repository to make sure resources will be cleanup once failed #31035

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

Merged
merged 25 commits into from
Apr 8, 2025

Conversation

lunny
Copy link
Member

@lunny lunny commented May 21, 2024

Fix #28144

To make the resources will be cleanup once failed. All repository operations now follow a consistent pattern:

    1. Create a database record for the repository with the status being_migrated.
    1. Register a deferred cleanup function to delete the repository and its related data if the operation fails.
    1. Perform the actual Git and database operations step by step.
    1. Upon successful completion, update the repository’s status to ready.

The adopt operation is a special case — if it fails, the repository on disk should not be deleted.

@lunny lunny added type/bug backport/v1.22 This PR should be backported to Gitea 1.22 labels May 21, 2024
@lunny lunny added this to the 1.23.0 milestone May 21, 2024
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label May 21, 2024
@github-actions github-actions bot added the modifies/go Pull requests that update Go code label May 21, 2024
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels May 27, 2024
Copy link
Contributor

@yp05327 yp05327 left a comment

Choose a reason for hiding this comment

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

CreateRepositoryNotice has two same messages, maybe it is better to adjust them

@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels May 27, 2024
@lunny
Copy link
Member Author

lunny commented May 27, 2024

I will try to have some tests.

@yp05327 yp05327 self-requested a review May 27, 2024 23:32
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. labels May 27, 2024
@lunny lunny marked this pull request as draft August 22, 2024 04:46
@lunny lunny modified the milestones: 1.23.0, 1.24.0 Sep 7, 2024
@lunny lunny modified the milestones: 1.24.0, 1.23.0 Sep 23, 2024
@lunny lunny marked this pull request as ready for review September 23, 2024 17:23
@lunny lunny marked this pull request as draft September 23, 2024 18:14
@lunny lunny modified the milestones: 1.23.0, 1.24.0 Sep 24, 2024
@lunny lunny marked this pull request as draft April 6, 2025 21:36
@lunny lunny marked this pull request as ready for review April 8, 2025 01:36
@lunny
Copy link
Member Author

lunny commented Apr 8, 2025

0142df4

The tests changed in 0142df4

@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Apr 8, 2025
@lunny lunny merged commit a100ac3 into go-gitea:main Apr 8, 2025
26 checks passed
@lunny lunny deleted the lunny/cleanup_failure_creation_of_repo branch April 8, 2025 05:12
@lunny lunny removed the backport/v1.23 This PR should be backported to Gitea 1.23 label Apr 8, 2025
lunny added a commit that referenced this pull request Apr 14, 2025
This PR fixed a bug which is a regression from #31035
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. modifies/go Pull requests that update Go code type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Template repo files should be cleaned up after an error
5 participants