-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
Add repo-sync-releases admin command #3254
Conversation
cmd/admin.go
Outdated
Usage: "Synchronize repository releases with tags", | ||
Action: runRepoSyncReleasesWithTags, | ||
Flags: []cli.Flag{ | ||
cli.StringFlag{ |
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.
These flags seems wrong
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.
flags fixed, please lift blocker ?
a584ae4
to
d182fd3
Compare
Shorter name for command would probably be better, ex. |
Please see 57cab54a
I've changed the name to "repo-sync" and fixed tags.
Only when I run the command locally I don't see a return from
models.SyncReleasesWithTags for the second of two repositories I have
locally:
2017/12/23 09:57:23 [I] XORM Log Mode: File(Info)
2017/12/23 09:57:23 [T] Found 2 repos
2017/12/23 09:57:23 [T] Synchronizing repo error/test with path /home/strk/gitea-repositories/error/test.git
2017/12/23 09:57:23 [T] currentgNumReleases is 0, running SyncReleasesWithTags
2017/12/23 09:57:23 [W] SyncReleasesWithTags: GetTags: exit status 128 - fatal: Not a git repository (or any of the parent directories): .git
2017/12/23 09:57:23 [T] Repo error/test releases synchronized to tags: from 0 to 0
2017/12/23 09:57:23 [T] Synchronizing repo strk/test with path /home/strk/gitea-repositories/strk/test.git
2017/12/23 09:57:23 [T] currentgNumReleases is 0, running SyncReleasesWithTags
At the end of each loop there should be a "Repo xxx/xxx releases syncrhonized to tags..." message,
but you see only one (for the repository with an error, btw)
Also, I'm afraid the default paging would limit the scan to just the
first page (of a non-infinite default length)
|
00e2e78
to
f422ada
Compare
cmd/admin.go
Outdated
} | ||
|
||
oldnum := repo.NumReleases | ||
log.Trace(" currentgNumReleases is %d, running SyncReleasesWithTags", oldnum) |
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.
typo
cmd/admin.go
Outdated
return fmt.Errorf("models.SetEngine: %v", err) | ||
} | ||
|
||
repos, count, err := models.SearchRepositoryByName(&models.SearchRepoOptions{}) |
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.
2 things:
- Should we use paging instead of dragging all repositories into memory at once?
- We need set
Private
totrue
See models/repo_indexer.go for an example.
cmd/admin.go
Outdated
repos, count, err := models.SearchRepositoryByName(&models.SearchRepoOptions{}) | ||
if err != nil { | ||
log.Fatal(4, "SearchRepositoryByName: %v", err) | ||
return nil |
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 we return Never mind, the nil
, is the return status 0? I think that if we aren't able to even the load the repositories, then the exit status should be non-zero (e.g. if someone is running this command as part of a shell script).return nil
is unreachable due to the log.Fatal
.
@ethantkoenig thanks for the review, I addressed all issues with fe1ab765 Maybe the return code should be the number of failed synchronization, but before going there, I'd really like someone else to try the command on their own installation, because I find it behaving in unexpected ways. For example I cloned a managed repository locally, created and pushed a tag, then run the command but the command did not report creating one additional tag... |
Codecov Report
@@ Coverage Diff @@
## master #3254 +/- ##
==========================================
- Coverage 34.86% 34.81% -0.06%
==========================================
Files 277 277
Lines 40210 40263 +53
==========================================
- Hits 14020 14018 -2
- Misses 24130 24184 +54
- Partials 2060 2061 +1
Continue to review full report at Codecov.
|
Well it turns out SyncReleasesWithTags does not do what I though (and what whoever wrote the migration though) ? That is, it does not read git repository TAGS and turn them into RELEASES into the database. This (#3247) is a very nasty migration bug, please give it higher priority |
cmd/admin.go
Outdated
for page := 1; ; page++ { | ||
repos, count, err := models.SearchRepositoryByName(&models.SearchRepoOptions{ | ||
Page: page, | ||
PageSize: 10, |
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.
Bigger page size would be better I think (50 for ex.)
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 was also wondering why 10, only took that value from the example code I was reading: PopulateRepoIndexer here:
Line 82 in f5155b9
repos, _, err := SearchRepositoryByName(&SearchRepoOptions{ |
But on the other hand, why 50 ? The question is: how much RAM does a single repository information take ? What are we loading, beside the single record, from the DB ? Why not 255 ?
Should we be using a constant for this, to avoid having the same discussion in multiple places ?
For example 20 is used in migration 39:
gitea/models/migrations/v39.go
Line 34 in f5155b9
pageSize := 20 |
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.
With 59672bf6 I've introduced a new RepositoryListDefaultPageSize constant, set to 64 and used from within the new admin command (to be used by other places too, later)
So the command finally works, it was just the debug output being wrong, and now it's fixed. Can we merge now ? |
Will help recovering corrupted database, see go-gitea#3247
…scan private repos, fix typo
Use it from the new admin command
054245c
to
bb04944
Compare
CI still fails for docs comment |
bb04944
to
e8772e3
Compare
Will help recovering corrupted database, see #3247