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

Make Migrations Cancelable #12917

Closed
wants to merge 18 commits into from
Closed

Conversation

6543
Copy link
Member

@6543 6543 commented Sep 21, 2020

close #12845

@6543 6543 mentioned this pull request Sep 21, 2020
@6543 6543 added type/enhancement An improvement of existing functionality topic/ui Change the appearance of the Gitea UI pr/wip This PR is not ready for review labels Sep 21, 2020
@6543 6543 added this to the 1.14.0 milestone Sep 21, 2020
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Sep 21, 2020
@codecov-commenter
Copy link

codecov-commenter commented Sep 21, 2020

Codecov Report

Merging #12917 into master will increase coverage by 0.11%.
The diff coverage is 7.14%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #12917      +/-   ##
==========================================
+ Coverage   42.49%   42.60%   +0.11%     
==========================================
  Files         672      672              
  Lines       73785    73799      +14     
==========================================
+ Hits        31353    31443      +90     
+ Misses      37361    37263      -98     
- Partials     5071     5093      +22     
Impacted Files Coverage Δ
routers/repo/migrate.go 37.58% <0.00%> (-3.82%) ⬇️
routers/routes/routes.go 89.08% <100.00%> (+0.01%) ⬆️
modules/queue/workerpool.go 58.77% <0.00%> (-2.05%) ⬇️
services/pull/pull.go 41.27% <0.00%> (+0.49%) ⬆️
modules/log/event.go 59.43% <0.00%> (+0.94%) ⬆️
services/mailer/mail.go 55.91% <0.00%> (+1.07%) ⬆️
modules/notification/notification.go 81.25% <0.00%> (+2.67%) ⬆️
modules/notification/base/null.go 71.42% <0.00%> (+2.85%) ⬆️
modules/git/commit.go 54.72% <0.00%> (+4.05%) ⬆️
modules/notification/mail/mail.go 34.48% <0.00%> (+5.74%) ⬆️
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a23c128...6b4e015. Read the comment docs.

@codecov-io
Copy link

codecov-io commented Oct 7, 2020

Codecov Report

Merging #12917 (cfed3be) into master (d8c2c6c) will increase coverage by 0.03%.
The diff coverage is 10.20%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #12917      +/-   ##
==========================================
+ Coverage   42.22%   42.26%   +0.03%     
==========================================
  Files         708      709       +1     
  Lines       77173    77221      +48     
==========================================
+ Hits        32589    32634      +45     
+ Misses      39225    39223       -2     
- Partials     5359     5364       +5     
Impacted Files Coverage Δ
models/migrations/migrations.go 2.44% <ø> (ø)
models/migrations/v161.go 0.00% <0.00%> (ø)
models/task.go 33.03% <0.00%> (-1.87%) ⬇️
routers/repo/migrate.go 33.74% <0.00%> (-8.57%) ⬇️
modules/task/migrate.go 32.39% <50.00%> (+0.96%) ⬆️
modules/process/manager.go 75.90% <100.00%> (+3.40%) ⬆️
routers/routes/macaron.go 92.54% <100.00%> (+<0.01%) ⬆️
modules/queue/workerpool.go 58.77% <0.00%> (-2.05%) ⬇️
modules/queue/unique_queue_disk_channel.go 53.84% <0.00%> (-1.54%) ⬇️
modules/git/repo.go 45.72% <0.00%> (-1.01%) ⬇️
... and 11 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d8c2c6c...cfed3be. Read the comment docs.

@zeripath zeripath changed the title Add Cancle button for Migration Add Cancel button for Migration Oct 8, 2020
routers/repo/migrate.go Outdated Show resolved Hide resolved
templates/repo/migrate/migrating.tmpl Outdated Show resolved Hide resolved
routers/routes/routes.go Outdated Show resolved Hide resolved
@6543 6543 removed the pr/wip This PR is not ready for review label Nov 28, 2020
@6543
Copy link
Member Author

6543 commented Nov 28, 2020

@silverwind
Copy link
Member

What is this | in your screenshot?

image

@6543
Copy link
Member Author

6543 commented Nov 28, 2020

What is this | in your screenshot?

the cursur 😆

@silverwind
Copy link
Member

silverwind commented Nov 28, 2020

Shouldn't a button show cursor: pointer? Where is cursor: text coming from? (Yeah, I'm too lazy to test myself right now)

@6543
Copy link
Member Author

6543 commented Nov 28, 2020

@silverwind if you like to have a "fresh" screenshot (00e532e460e790d5449931ceec0f718435de9261):
Bildschirmfoto zu 2020-11-29 00-58-13

routers/repo/migrate.go Outdated Show resolved Hide resolved
@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 Nov 29, 2020
@6543 6543 added topic/repo-migration Migrate repos from other platforms to Gitea, or from Gitea to them and removed topic/ui Change the appearance of the Gitea UI labels Dec 1, 2020
templates/repo/migrate/migrating.tmpl Show resolved Hide resolved
@@ -0,0 +1,17 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
Copy link
Member

Choose a reason for hiding this comment

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

Well, this file certainly needs to be renamed until this PR will be merged.

if _, err := fmt.Sscanf(task.Process, "%d/%d", &guid, &pid); err != nil {
return 0, 0
}
return
Copy link
Member

Choose a reason for hiding this comment

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

Does that compile?
To me, this seems like a syntax error.
This whole function seems not finished.
Could it be that you intended to finish it another time?

Copy link
Member

Choose a reason for hiding this comment

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

If it compiles, I can understand why, but I wouldn't have dreamed up such a syntax ever…

Copy link
Member Author

Choose a reason for hiding this comment

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

@@ -114,6 +115,17 @@ func (task *Task) MigrateConfig() (*migration.MigrateOptions, error) {
return nil, fmt.Errorf("Task type is %s, not Migrate Repo", task.Type.Name())
}

// GUIDandPID return GUID and PID of a running task
func (task *Task) GUIDandPID() (guid int64, pid int64) {
Copy link
Member

Choose a reason for hiding this comment

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

I think simply returning 0, 0 is not always the best idea.
What if you extended the return to produce an additional error ((guid, pid int64, err error))?
Alternatively, you could set the error return value to -1, -1.
This is because it is guaranteed that no process will ever have a negative PID, while it could happen that a process has PID 0, although that is close to impossible for a process that is not the OS.

routers/repo/migrate.go Outdated Show resolved Hide resolved
log.Trace("Migration [%s] cancel PID [%d] ", ctx.Repo.Repository.FullName(), tPID)
process.GetManager().Cancel(tPID)
ctx.Flash.Success(ctx.Tr("repo.migrate.cancelled"))
ctx.Redirect(ctx.Repo.Owner.DashboardLink())
Copy link
Member

Choose a reason for hiding this comment

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

Is it even sensible to flash a message if the next action is to redirect back to the homepage?

return
}

ctx.Flash.Error(ctx.Tr("repo.migrate.task_not_found", ctx.Repo.Repository.FullName()))
Copy link
Member

Choose a reason for hiding this comment

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

Is it even sensible to flash a message if the next action is to redirect back to the homepage?

tGUID, tPID := task.GUIDandPID()
if guid == tGUID {
log.Trace("Migration [%s] cancel PID [%d] ", ctx.Repo.Repository.FullName(), tPID)
process.GetManager().Cancel(tPID)
Copy link
Member

Choose a reason for hiding this comment

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

I think it would be best to delete the repository here explicitly.
Otherwise, the repo might or might not exist in the database,
resulting in the user being unable to recreate a repo under this name until
either an admin runs a health check, or a doctor command is scheduled.

@lunny lunny modified the milestones: 1.16.0, 1.17.0 Nov 9, 2021
Co-authored-by: delvh <dev.lh@web.de>
@singuliere
Copy link
Contributor

This is an interesting feature, how could the conflicts be resolved? Would you like to rebase or should it be done in a different way?

@6543
Copy link
Member Author

6543 commented Feb 4, 2022

I'll resolve the conflicts ...

@6543 6543 self-assigned this Feb 8, 2022
@6543
Copy link
Member Author

6543 commented Feb 8, 2022

to explain the problem why it did not got merged jet: if you have a setup with more instances, and you like to cancle a migration from instance A running on instance B, it wont work (A will find the job in the database but cant find it in it's process.Manager)

@lunny lunny modified the milestones: 1.17.0, 1.18.0 May 25, 2022
@lunny lunny modified the milestones: 1.18.0, 1.19.0 Oct 17, 2022
@lunny lunny modified the milestones: 1.19.0, 1.20.0 Jan 31, 2023
@wxiaoguang
Copy link
Contributor

Replaced by Make repo migration cancelable and fix various bugs #24605

@wxiaoguang wxiaoguang closed this May 9, 2023
@GiteaBot GiteaBot removed this from the 1.20.0 milestone May 9, 2023
@6543 6543 deleted the ui-migration-cancel branch July 18, 2023 13:24
@6543 6543 removed their assignment Jul 18, 2023
@go-gitea go-gitea locked as resolved and limited conversation to collaborators Aug 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/need 1 This PR needs approval from one additional maintainer to be merged. status/blocked This PR cannot be merged yet, i.e. because it depends on another unmerged PR topic/repo-migration Migrate repos from other platforms to Gitea, or from Gitea to them type/enhancement An improvement of existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migration: add Cancel button