Skip to content

Commit 5cd78ab

Browse files
committed
devtools/cmd/seeddb: apply -keep_going to versions check
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]>
1 parent 09793e5 commit 5cd78ab

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

devtools/cmd/seeddb/main.go

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,24 @@ func run(ctx context.Context, db *database.DB, proxyURL string) error {
8989
return err
9090
}
9191

92+
var (
93+
mu sync.Mutex
94+
errors database.MultiErr
95+
)
96+
9297
// Expand versions and group by module path.
98+
log.Printf("expanding versions")
9399
versionsByPath := map[string][]string{}
94100
for _, m := range seedModules {
95101
vers, err := versions(ctx, proxyClient, m)
96102
if err != nil {
97-
return err
103+
if *keepGoing {
104+
mu.Lock()
105+
errors = append(errors, err)
106+
mu.Unlock()
107+
} else {
108+
return err
109+
}
98110
}
99111
versionsByPath[m.Path] = append(versionsByPath[m.Path], vers...)
100112
}
@@ -111,10 +123,7 @@ func run(ctx context.Context, db *database.DB, proxyURL string) error {
111123
f.DB = postgres.New(db)
112124
}
113125

114-
var (
115-
mu sync.Mutex
116-
errors database.MultiErr
117-
)
126+
log.Printf("fetching")
118127
for path, vers := range versionsByPath {
119128
path := path
120129
vers := vers
@@ -135,9 +144,11 @@ func run(ctx context.Context, db *database.DB, proxyURL string) error {
135144
})
136145
}
137146
if err := g.Wait(); err != nil {
147+
log.Printf("Wait failed: %v", err)
138148
return err
139149
}
140150
if len(errors) > 0 {
151+
log.Printf("there were errors")
141152
return errors
142153
}
143154
log.Printf("successfully fetched all modules in %s", time.Since(start).Round(time.Millisecond))

0 commit comments

Comments
 (0)