Skip to content

Commit

Permalink
devtools/cmd/seeddb: apply -keep_going to versions check
Browse files Browse the repository at this point in the history
Some module proxies may return invalid responses for versions for some modules.
This change helps skip through those, when the majority of other modules would
succeed.

Concrete example: given a GitHub repo with no tagged releases, when querying
the official Go module proxy for versions at /v@/list, it returns 200 OK and no
content (since there are no versions). The jFrog Artifactory go module proxy's
behaviour, in contrast, is to return 404 NOT FOUND if there are no versions.

That means that if you're using seeddb and any of your seed.txt modules does
not have tagged versions, we fail-fast when we try to list that module's
versions, despite using -keep_going. This change applies -keep_going to that
section of code, so that we skip over the 404 errors.

Original author: Jean Barkhuysen <[email protected]>

Fixes #71140

Change-Id: I2ccbcc356c322deed81860ee92274fba04a079b2
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/641675
LUCI-TryBot-Result: Go LUCI <[email protected]>
Reviewed-by: Michael Knyszek <[email protected]>
Reviewed-by: Jonathan Amsterdam <[email protected]>
kokoro-CI: kokoro <[email protected]>
Reviewed-by: Jean Barkhuysen <[email protected]>
  • Loading branch information
jba committed Jan 15, 2025
1 parent 09793e5 commit 5cd78ab
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions devtools/cmd/seeddb/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,24 @@ func run(ctx context.Context, db *database.DB, proxyURL string) error {
return err
}

var (
mu sync.Mutex
errors database.MultiErr
)

// Expand versions and group by module path.
log.Printf("expanding versions")
versionsByPath := map[string][]string{}
for _, m := range seedModules {
vers, err := versions(ctx, proxyClient, m)
if err != nil {
return err
if *keepGoing {
mu.Lock()
errors = append(errors, err)
mu.Unlock()
} else {
return err
}
}
versionsByPath[m.Path] = append(versionsByPath[m.Path], vers...)
}
Expand All @@ -111,10 +123,7 @@ func run(ctx context.Context, db *database.DB, proxyURL string) error {
f.DB = postgres.New(db)
}

var (
mu sync.Mutex
errors database.MultiErr
)
log.Printf("fetching")
for path, vers := range versionsByPath {
path := path
vers := vers
Expand All @@ -135,9 +144,11 @@ func run(ctx context.Context, db *database.DB, proxyURL string) error {
})
}
if err := g.Wait(); err != nil {
log.Printf("Wait failed: %v", err)
return err
}
if len(errors) > 0 {
log.Printf("there were errors")
return errors
}
log.Printf("successfully fetched all modules in %s", time.Since(start).Round(time.Millisecond))
Expand Down

0 comments on commit 5cd78ab

Please sign in to comment.