-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Only migrate mirrors containing commits in migration v276
#27132
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
Conversation
v276
v276
v276
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.
blocking while testing
@puni9869 don't put such premature |
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.
This PR does not fix a problem. The real error is, that the migration revealed that the database is/was inconsistent. See this discord discussion: https://discord.com/channels/322538954119184384/322910365237248000/1153443258014388254
@@ -126,6 +129,8 @@ func migratePushMirrors(x *xorm.Engine) error { | |||
var mirrors []PushMirror | |||
if err := sess.Select("push_mirror.id, push_mirror.repo_id, push_mirror.remote_name, push_mirror.remote_address, repository.owner_name as repo_owner, repository.name as repo_name"). | |||
Join("INNER", "repository", "repository.id = push_mirror.repo_id"). | |||
Where("repository.status = ?", repo_model.RepositoryReady). | |||
And("repository.is_empty = ?", false). |
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.
This is wrong. An empty repository can contain push mirrors. This would not update the RemoteAddress
then.
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.
An empty repository should have no any git data. So this will avoid read git data here failure. Maybe we can update the remote_address when the first mirror successfully?
@@ -63,6 +64,8 @@ func migratePullMirrors(x *xorm.Engine) error { | |||
var mirrors []Mirror | |||
if err := sess.Select("mirror.id, mirror.repo_id, mirror.remote_address, repository.owner_name as repo_owner, repository.name as repo_name"). | |||
Join("INNER", "repository", "repository.id = mirror.repo_id"). | |||
Where("repository.status = ?", repo_model.RepositoryReady). | |||
And("repository.is_empty = ?", false). |
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.
This is wrong. If you migrate an empty repository, you still have a pull mirror in the database. This would not update the RemoteAddress
then.
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.
See my above comment, I think they should be updated when the first mirroring.
@@ -63,6 +64,8 @@ func migratePullMirrors(x *xorm.Engine) error { | |||
var mirrors []Mirror | |||
if err := sess.Select("mirror.id, mirror.repo_id, mirror.remote_address, repository.owner_name as repo_owner, repository.name as repo_name"). | |||
Join("INNER", "repository", "repository.id = mirror.repo_id"). | |||
Where("repository.status = ?", repo_model.RepositoryReady). |
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.
Repositories with status = RepositoryPendingTransfer
could have mirrors.
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.
This is for migrations, it may/may not have the mirrors. So we cannot assume it always have when the status = RepositoryPendingTransfer. We can only assume when status = RepositoryPendingReady, the git data have the remote.
@@ -126,6 +129,8 @@ func migratePushMirrors(x *xorm.Engine) error { | |||
var mirrors []PushMirror | |||
if err := sess.Select("push_mirror.id, push_mirror.repo_id, push_mirror.remote_name, push_mirror.remote_address, repository.owner_name as repo_owner, repository.name as repo_name"). | |||
Join("INNER", "repository", "repository.id = push_mirror.repo_id"). | |||
Where("repository.status = ?", repo_model.RepositoryReady). |
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.
Repositories with status = RepositoryPendingTransfer
could have mirrors.
Share my option again here: I do not think adding Why it is not ideal? The definition of RemoteAddress is unclear. In git config, the URL could have username/password, but when storing it into database, it loses the credentials. Then RemoteAddress is not really useful for daily usage. Then, does it really help I would suggest to make the audit system flexible, and revert the "RemoteAddress" related changes until there is a clear design and usage. |
It's not unclear, we already present that informationen in the API.
Without that field you have no performant way to create a "mirror overview" page for the admin dashboard. Could list constant failures and so on. While the source was the audit PR, it's usage is not limited to it. As shown in the changes, the UI uses it.
You don't have add every info needed to the model. If only the audit system needs an information, we can simply create an audit type "inheriting" from the model. |
Unfortunately, the API design was unclear already. "Create" could take the user&password from RemoteAddress, but the RemoteAddress of "List/Get" doesn't have them. I agree that the API shouldn't expose sensitive data, but I think such naming is not a good design. I consider such "RemoteAddress" as an incomplete patch, because it is not a complete replacement for the "git config", maintaining username&password still requires git config.
I agree, while it is just an incidental benefit brought by this change. With or without "RemoteAddress", there is no much difference at the moment, while I think the key point is how to make it complete (the prev topic) and the audit field design (the next topic).
Maybe I do not have the complete understanding for the design. If you are sure it is good enough, I have no more question. |
I will keep in mind next time, No worries. |
Add more conditions to avoid possible migration broken.