зеркало из https://github.com/golang/build.git
cmd/gomote: use ListDirectoryStreaming
Use the streaming directory listing RPC to avoid overflowing the maximum RPC response size. For golang/go#69732 Change-Id: I2529d3788843844e3ccdde79c12c5c453b09bb25 Reviewed-on: https://go-review.googlesource.com/c/build/+/617161 Reviewed-by: Carlos Amedee <carlos@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
Родитель
25d5d8fff1
Коммит
0b78e172e8
|
@ -8,6 +8,7 @@ import (
|
|||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
"strings"
|
||||
|
@ -71,7 +72,7 @@ func ls(args []string) error {
|
|||
}
|
||||
for _, inst := range lsSet {
|
||||
client := gomoteServerClient(ctx)
|
||||
resp, err := client.ListDirectory(ctx, &protos.ListDirectoryRequest{
|
||||
stream, err := client.ListDirectoryStreaming(ctx, &protos.ListDirectoryRequest{
|
||||
GomoteId: inst,
|
||||
Directory: dir,
|
||||
Recursive: recursive,
|
||||
|
@ -84,8 +85,17 @@ func ls(args []string) error {
|
|||
if len(lsSet) > 1 {
|
||||
fmt.Fprintf(os.Stdout, "# %s\n", inst)
|
||||
}
|
||||
for _, entry := range resp.GetEntries() {
|
||||
fmt.Fprintf(os.Stdout, "%s\n", entry)
|
||||
for {
|
||||
resp, err := stream.Recv()
|
||||
if err == io.EOF {
|
||||
break
|
||||
}
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to ls: %w", err)
|
||||
}
|
||||
for _, entry := range resp.GetEntries() {
|
||||
fmt.Fprintf(os.Stdout, "%s\n", entry)
|
||||
}
|
||||
}
|
||||
if len(lsSet) > 1 {
|
||||
fmt.Fprintln(os.Stdout)
|
||||
|
|
|
@ -76,7 +76,7 @@ func doPush(ctx context.Context, name, goroot string, dryRun, detailedProgress b
|
|||
remote := map[string]buildlet.DirEntry{} // keys like "src/make.bash"
|
||||
|
||||
client := gomoteServerClient(ctx)
|
||||
resp, err := client.ListDirectory(ctx, &protos.ListDirectoryRequest{
|
||||
stream, err := client.ListDirectoryStreaming(ctx, &protos.ListDirectoryRequest{
|
||||
GomoteId: name,
|
||||
Directory: ".",
|
||||
Recursive: true,
|
||||
|
@ -99,11 +99,20 @@ func doPush(ctx context.Context, name, goroot string, dryRun, detailedProgress b
|
|||
if err != nil {
|
||||
return fmt.Errorf("error listing buildlet's existing files: %w", err)
|
||||
}
|
||||
for _, entry := range resp.GetEntries() {
|
||||
de := buildlet.DirEntry{Line: entry}
|
||||
en := de.Name()
|
||||
if strings.HasPrefix(en, "go/") && en != "go/" {
|
||||
remote[en[len("go/"):]] = de
|
||||
for {
|
||||
resp, err := stream.Recv()
|
||||
if err == io.EOF {
|
||||
break
|
||||
}
|
||||
if err != nil {
|
||||
return fmt.Errorf("error listing buildlet's existing files: %w", err)
|
||||
}
|
||||
for _, entry := range resp.GetEntries() {
|
||||
de := buildlet.DirEntry{Line: entry}
|
||||
en := de.Name()
|
||||
if strings.HasPrefix(en, "go/") && en != "go/" {
|
||||
remote[en[len("go/"):]] = de
|
||||
}
|
||||
}
|
||||
}
|
||||
// TODO(66635) remove once gomotes can no longer be created via the coordinator.
|
||||
|
|
Загрузка…
Ссылка в новой задаче