From 6f1346fdb9f5d9efb6ea3858da5ea1a09eb74421 Mon Sep 17 00:00:00 2001 From: Matt Date: Sun, 8 Sep 2024 21:27:48 -0700 Subject: [PATCH 1/2] Fix: Change goreleaser flag from --rm-dist to --clean (#1984) Fixing a release with maintainer permissions --- .github/workflows/goreleaser.yml | 2 +- go.mod | 6 +----- go.sum | 1 - 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/.github/workflows/goreleaser.yml b/.github/workflows/goreleaser.yml index fa01eabb6..6ff252a8d 100644 --- a/.github/workflows/goreleaser.yml +++ b/.github/workflows/goreleaser.yml @@ -22,7 +22,7 @@ jobs: uses: goreleaser/goreleaser-action@v6 with: version: latest - args: release --rm-dist + args: release --clean env: DATE: ${{ steps.date.outputs.date }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/go.mod b/go.mod index 194890562..c819e0651 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,6 @@ require ( github.com/Azure/azure-sdk-for-go/sdk/azcore v1.11.1 github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 github.com/Azure/azure-storage-blob-go v0.10.0 - github.com/Azure/go-autorest/autorest/adal v0.9.23 github.com/BurntSushi/toml v1.0.0 github.com/DataDog/opencensus-go-exporter-datadog v0.0.0-20180917103902-e6c7f767dc57 github.com/aws/aws-sdk-go-v2 v1.26.1 @@ -60,10 +59,7 @@ require ( cloud.google.com/go/monitoring v1.18.0 // indirect cloud.google.com/go/trace v1.10.5 // indirect github.com/Azure/azure-sdk-for-go/sdk/internal v1.8.0 // indirect - github.com/Azure/go-autorest v14.2.0+incompatible // indirect - github.com/Azure/go-autorest/autorest/date v0.3.0 // indirect - github.com/Azure/go-autorest/logger v0.2.1 // indirect - github.com/Azure/go-autorest/tracing v0.6.0 // indirect + github.com/Azure/go-autorest/autorest/adal v0.9.23 // indirect github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 // indirect github.com/DataDog/datadog-go v0.0.0-20180822151419-281ae9f2d895 // indirect github.com/agext/levenshtein v1.2.1 // indirect diff --git a/go.sum b/go.sum index d734438f7..a53844743 100644 --- a/go.sum +++ b/go.sum @@ -81,7 +81,6 @@ github.com/Azure/go-autorest/autorest/date v0.3.0/go.mod h1:BI0uouVdmngYNUzGWeSY github.com/Azure/go-autorest/autorest/mocks v0.1.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0= github.com/Azure/go-autorest/autorest/mocks v0.2.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0= github.com/Azure/go-autorest/autorest/mocks v0.3.0/go.mod h1:a8FDP3DYzQ4RYfVAxAN3SVSiiO77gL2j2ronKKP0syM= -github.com/Azure/go-autorest/autorest/mocks v0.4.1 h1:K0laFcLE6VLTOwNgSxaGbUcLPuGXlNkbVvq4cW4nIHk= github.com/Azure/go-autorest/autorest/mocks v0.4.1/go.mod h1:LTp+uSrOhSkaKrUy935gNZuuIPPVsHlr9DSOxSayd+k= github.com/Azure/go-autorest/logger v0.1.0/go.mod h1:oExouG+K6PryycPJfVSxi/koC6LSNgds39diKLz7Vrc= github.com/Azure/go-autorest/logger v0.2.1 h1:IG7i4p/mDa2Ce4TRyAO8IHnVhAVF3RFU+ZtXWSmf4Tg= From 3856c6feee6e9ec0772e885f73ad9446d84abd21 Mon Sep 17 00:00:00 2001 From: Taylor Chen <95328002+taylorychen@users.noreply.github.com> Date: Thu, 19 Sep 2024 23:19:47 -0700 Subject: [PATCH 2/2] add timeout to vcsLister.List() (#1986) --- cmd/proxy/actions/app_proxy.go | 2 +- pkg/download/list.go | 2 +- pkg/download/protocol_test.go | 2 +- pkg/errors/errors.go | 1 + pkg/module/go_vcs_lister.go | 14 ++++++++++++-- 5 files changed, 16 insertions(+), 5 deletions(-) diff --git a/cmd/proxy/actions/app_proxy.go b/cmd/proxy/actions/app_proxy.go index 0117bc9db..86c2a2478 100644 --- a/cmd/proxy/actions/app_proxy.go +++ b/cmd/proxy/actions/app_proxy.go @@ -99,7 +99,7 @@ func addProxyRoutes( return err } - lister := module.NewVCSLister(c.GoBinary, c.GoBinaryEnvVars, fs) + lister := module.NewVCSLister(c.GoBinary, c.GoBinaryEnvVars, fs, c.TimeoutDuration()) checker := storage.WithChecker(s) withSingleFlight, err := getSingleFlight(l, c, s, checker) if err != nil { diff --git a/pkg/download/list.go b/pkg/download/list.go index 04971cdb5..16188db8c 100644 --- a/pkg/download/list.go +++ b/pkg/download/list.go @@ -28,7 +28,7 @@ func ListHandler(dp Protocol, lggr log.Entry, df *mode.DownloadFile) http.Handle versions, err := dp.List(r.Context(), mod) if err != nil { - severityLevel := errors.Expect(err, errors.KindNotFound) + severityLevel := errors.Expect(err, errors.KindNotFound, errors.KindGatewayTimeout) err = errors.E(op, err, severityLevel) lggr.SystemErr(err) w.WriteHeader(errors.Kind(err)) diff --git a/pkg/download/protocol_test.go b/pkg/download/protocol_test.go index 1a8559842..d7070e013 100644 --- a/pkg/download/protocol_test.go +++ b/pkg/download/protocol_test.go @@ -50,7 +50,7 @@ func getDP(t *testing.T) Protocol { return New(&Opts{ Storage: s, Stasher: st, - Lister: module.NewVCSLister(goBin, conf.GoBinaryEnvVars, fs), + Lister: module.NewVCSLister(goBin, conf.GoBinaryEnvVars, fs, conf.TimeoutDuration()), NetworkMode: Strict, }) } diff --git a/pkg/errors/errors.go b/pkg/errors/errors.go index 6b502dc1b..b2378b19d 100644 --- a/pkg/errors/errors.go +++ b/pkg/errors/errors.go @@ -18,6 +18,7 @@ const ( KindRateLimit = http.StatusTooManyRequests KindNotImplemented = http.StatusNotImplemented KindRedirect = http.StatusMovedPermanently + KindGatewayTimeout = http.StatusGatewayTimeout ) // Error is an Athens system error. diff --git a/pkg/module/go_vcs_lister.go b/pkg/module/go_vcs_lister.go index 86abcc38c..b9e3f041b 100644 --- a/pkg/module/go_vcs_lister.go +++ b/pkg/module/go_vcs_lister.go @@ -28,15 +28,17 @@ type vcsLister struct { env []string fs afero.Fs sfg *singleflight.Group + timeout time.Duration } // NewVCSLister creates an UpstreamLister which uses VCS to fetch a list of available versions. -func NewVCSLister(goBinPath string, env []string, fs afero.Fs) UpstreamLister { +func NewVCSLister(goBinPath string, env []string, fs afero.Fs, timeout time.Duration) UpstreamLister { return &vcsLister{ goBinPath: goBinPath, env: env, fs: fs, sfg: &singleflight.Group{}, + timeout: timeout, } } @@ -56,7 +58,11 @@ func (l *vcsLister) List(ctx context.Context, module string) (*storage.RevInfo, } defer func() { _ = l.fs.RemoveAll(tmpDir) }() - cmd := exec.Command( + timeoutCtx, cancel := context.WithTimeout(ctx, l.timeout) + defer cancel() + + cmd := exec.CommandContext( + timeoutCtx, l.goBinPath, "list", "-m", "-versions", "-json", config.FmtModVer(module, "latest"), @@ -77,6 +83,10 @@ func (l *vcsLister) List(ctx context.Context, module string) (*storage.RevInfo, err = cmd.Run() if err != nil { err = fmt.Errorf("%w: %s", err, stderr) + if errors.IsErr(timeoutCtx.Err(), context.DeadlineExceeded) { + return nil, errors.E(op, err, errors.KindGatewayTimeout) + } + // as of now, we can't recognize between a true NotFound // and an unexpected error, so we choose the more // hopeful path of NotFound. This way the Go command