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

Add repo-sync-releases admin command #3254

Merged
merged 6 commits into from
Dec 31, 2017

Conversation

strk
Copy link
Member

@strk strk commented Dec 23, 2017

Will help recovering corrupted database, see #3247

cmd/admin.go Outdated
Usage: "Synchronize repository releases with tags",
Action: runRepoSyncReleasesWithTags,
Flags: []cli.Flag{
cli.StringFlag{
Copy link
Member

Choose a reason for hiding this comment

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

These flags seems wrong

Copy link
Member Author

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 ?

@lafriks
Copy link
Member

lafriks commented Dec 23, 2017

Shorter name for command would probably be better, ex. sync-tags

@tboerger tboerger added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Dec 23, 2017
@strk
Copy link
Member Author

strk commented Dec 23, 2017 via email

@strk strk changed the title Add repo-sync-releases-with-tags admin command Add repo-sync admin command Dec 25, 2017
@strk strk force-pushed the admin-repo-sync-release branch 2 times, most recently from 00e2e78 to f422ada Compare December 25, 2017 09:46
cmd/admin.go Outdated
}

oldnum := repo.NumReleases
log.Trace(" currentgNumReleases is %d, running SyncReleasesWithTags", oldnum)
Copy link
Member

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{})
Copy link
Member

Choose a reason for hiding this comment

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

2 things:

  1. Should we use paging instead of dragging all repositories into memory at once?
  2. We need set Private to true

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
Copy link
Member

@ethantkoenig ethantkoenig Dec 25, 2017

Choose a reason for hiding this comment

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

If we return 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). Never mind, the return nil is unreachable due to the log.Fatal.

@strk
Copy link
Member Author

strk commented Dec 30, 2017

@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-io
Copy link

codecov-io commented Dec 30, 2017

Codecov Report

Merging #3254 into master will decrease coverage by 0.05%.
The diff coverage is 3.57%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
models/repo_list.go 67.18% <ø> (ø) ⬆️
cmd/admin.go 0% <0%> (ø) ⬆️
models/migrations/v39.go 0% <0%> (ø) ⬆️
models/issue_indexer.go 67.81% <100%> (ø) ⬆️
models/repo_indexer.go 50.97% <100%> (-0.98%) ⬇️
models/repo.go 43.2% <0%> (-0.19%) ⬇️
modules/process/manager.go 81.15% <0%> (+4.34%) ⬆️

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 ae9cc8f...e8772e3. Read the comment docs.

@strk
Copy link
Member Author

strk commented Dec 30, 2017

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,
Copy link
Member

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.)

Copy link
Member Author

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:

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:

pageSize := 20

Copy link
Member Author

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)

@strk strk changed the title Add repo-sync admin command Add repo-sync-releases admin command Dec 31, 2017
@strk
Copy link
Member Author

strk commented Dec 31, 2017

So the command finally works, it was just the debug output being wrong, and now it's fixed. Can we merge now ?

@tboerger tboerger 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 Dec 31, 2017
@lafriks lafriks added the type/feature Completely new functionality. Can only be merged if feature freeze is not active. label Dec 31, 2017
@lafriks lafriks added this to the 1.4.0 milestone Dec 31, 2017
@lafriks
Copy link
Member

lafriks commented Dec 31, 2017

CI still fails for docs comment

@tboerger tboerger 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 Dec 31, 2017
@lafriks lafriks merged commit 8cd987a into go-gitea:master Dec 31, 2017
@strk strk deleted the admin-repo-sync-release branch December 31, 2017 14:47
@go-gitea go-gitea locked and limited conversation to collaborators Nov 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/feature Completely new functionality. Can only be merged if feature freeze is not active.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants