Skip to content

Commit

Permalink
Add debug to figure out timing issue
Browse files Browse the repository at this point in the history
  • Loading branch information
jlsherrill committed Nov 8, 2023
1 parent 2d37d7b commit 9318ada
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions cmd/external-repos/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"sort"
"time"

"github.com/content-services/content-sources-backend/pkg/api"
"github.com/content-services/content-sources-backend/pkg/config"
"github.com/content-services/content-sources-backend/pkg/dao"
"github.com/content-services/content-sources-backend/pkg/db"
Expand All @@ -30,6 +31,7 @@ func main() {
args := os.Args
config.Load()
config.ConfigureLogging()
log.Error().Msgf("Loaded args: %v", args)
err := db.Connect()
if err != nil {
log.Panic().Err(err).Msg("Failed to connect to database")
Expand Down Expand Up @@ -85,8 +87,10 @@ func main() {
for i := 2; i < len(args); i++ {
urls = append(urls, args[i])
}
log.Error().Msgf("Urls: %v", urls)
if config.Get().Features.Snapshots.Enabled {
waitForPulp()
debugIssue()
err := enqueueSyncRepos(&urls)
if err != nil {
log.Warn().Msgf("Error enqueuing snapshot tasks: %v", err)
Expand Down Expand Up @@ -132,6 +136,7 @@ func saveToDB(db *gorm.DB) error {
}

func waitForPulp() {
log.Warn().Msg("Waiting for pulp")
for {
client := pulp_client.GetPulpClientWithDomain(context.Background(), pulp_client.DefaultDomain)
_, err := client.GetRpmRemoteList()
Expand Down Expand Up @@ -194,6 +199,23 @@ func enqueueIntrospectAllRepos() error {
return nil
}

func debugIssue() {
repoConfigDao := dao.GetRepositoryConfigDao(db.DB)
repoConfigs, err := repoConfigDao.InternalOnly_ListReposToSnapshot(nil)
log.Error().Msgf("Found %v repoconfigs", len(repoConfigs))
if err != nil {
log.Error().Err(err).Msg("error getting repository configurations")
}
for _, repoConfig := range repoConfigs {
log.Warn().Msgf("Repository: %v", repoConfig.Name)
}
_, count, err := dao.GetRepositoryDao(db.DB).ListPublic(api.PaginationData{}, api.FilterData{})
if err != nil {
log.Error().Err(err).Msg("error getting public repos")
}
log.Error().Msgf("Found %v public repos", count)
}

func enqueueSyncRepos(urls *[]string) error {
q, err := queue.NewPgQueue(db.GetUrl())
if err != nil {
Expand Down

0 comments on commit 9318ada

Please sign in to comment.