-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Make Migrations Cancelable #12917
Conversation
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
a7f8c55
to
2fd3802
Compare
marked as ready, as per https://github.com/go-gitea/gitea/pull/12917/files#r527381336 & 00e532e |
the cursur 😆 |
Shouldn't a button show |
@silverwind if you like to have a "fresh" screenshot (00e532e460e790d5449931ceec0f718435de9261): |
@@ -0,0 +1,17 @@ | |||
// Copyright 2020 The Gitea Authors. All rights reserved. |
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.
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 |
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.
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?
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.
If it compiles, I can understand why, but I wouldn't have dreamed up such a syntax ever…
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.
it do compile :)
@@ -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) { |
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.
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.
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()) |
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.
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())) |
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.
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) |
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.
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.
Co-authored-by: delvh <dev.lh@web.de>
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? |
I'll resolve the conflicts ... |
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) |
Replaced by Make repo migration cancelable and fix various bugs #24605 |
Replace #12917 Close #24601 Close #12845 ![image](https://github.com/go-gitea/gitea/assets/2114189/39378118-064d-40fb-8396-4579ebf33917) ![image](https://github.com/go-gitea/gitea/assets/2114189/faf37418-191c-46a6-90a8-353141e00e2d) ![image](https://github.com/go-gitea/gitea/assets/2114189/fdc8ee4d-125f-4737-9990-89bcdf9eb388) ![image](https://github.com/go-gitea/gitea/assets/2114189/9a3bd2c2-fe20-4011-81f0-990ed869d139) --------- Co-authored-by: Yarden Shoham <git@yardenshoham.com> Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: Giteabot <teabot@gitea.io>
close #12845