Skip to content

Commit

Permalink
fix(pkg/stash): close etcd sessions
Browse files Browse the repository at this point in the history
Athens creates a new session for each 'Stash' request and then never closes it.
The sessions (etcd leases) are consequently held forever and eventually leads
to resource exhaustion on the etcd cluster.

This has been fixed by closing the acquired session at the end of the request.

Fixes: #1886
  • Loading branch information
uhthomas committed Sep 14, 2023
1 parent e248d22 commit d7b0edf
Show file tree
Hide file tree
Showing 6 changed files with 341 additions and 108 deletions.
18 changes: 11 additions & 7 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ linters-settings:
cyclop:
max-complexity: 12
skip-tests: true
errcheck:
exclude-functions:
- (*go.etcd.io/etcd/client/v3/concurrency.Mutex).Unlock
- (*go.etcd.io/etcd/client/v3/concurrency.Session).Close
gofumpt:
extra-rules: true

Expand Down Expand Up @@ -50,15 +54,15 @@ linters:
issues:
exclude-use-default: false
exclude:
- 'package-comments: should have a package comment'
- 'ST1000: at least one file in a package should have a package comment'
- 'G204: Subprocess launched with a potential tainted input or cmd arguments'
- 'G204: Subprocess launched with variable'
- 'G402: TLS MinVersion too low.'
- 'const `op` is unused'
- "package-comments: should have a package comment"
- "ST1000: at least one file in a package should have a package comment"
- "G204: Subprocess launched with a potential tainted input or cmd arguments"
- "G204: Subprocess launched with variable"
- "G402: TLS MinVersion too low."
- "const `op` is unused"
exclude-rules:
- path: cmd/proxy/main.go
text: 'G108: Profiling endpoint is automatically exposed on /debug/pprof'
text: "G108: Profiling endpoint is automatically exposed on /debug/pprof"
- path: pkg/stash/stasher.go
linters:
- contextcheck
Expand Down
44 changes: 36 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@ require (
github.com/lib/pq v1.10.7
github.com/minio/minio-go/v6 v6.0.57
github.com/mitchellh/go-homedir v1.1.0
github.com/sirupsen/logrus v1.6.0
github.com/sirupsen/logrus v1.7.0
github.com/spf13/afero v1.8.2
github.com/stretchr/testify v1.7.0
github.com/stretchr/testify v1.8.1
github.com/technosophos/moniker v0.0.0-20180509230615-a5dbd03a2245
github.com/unrolled/secure v0.0.0-20181221173256-0d6b5bb13069
go.etcd.io/etcd/client/v3 v3.5.2
go.etcd.io/etcd/client/v3 v3.5.9
go.etcd.io/etcd/server/v3 v3.5.9
go.mongodb.org/mongo-driver v1.7.1
go.opencensus.io v0.23.0
golang.org/x/mod v0.8.0
Expand All @@ -53,28 +54,36 @@ require (
github.com/ajg/form v0.0.0-20160822230020-523a5da1a92f // indirect
github.com/apparentlymart/go-textseg v1.0.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cenkalti/backoff/v4 v4.1.1 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/codegangsta/negroni v1.0.0 // indirect
github.com/coreos/go-semver v0.3.0 // indirect
github.com/coreos/go-systemd/v22 v22.3.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/dustin/go-humanize v1.0.0 // indirect
github.com/go-playground/locales v0.12.1 // indirect
github.com/go-playground/universal-translator v0.16.0 // indirect
github.com/go-stack/stack v1.8.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect
github.com/golang-jwt/jwt/v4 v4.4.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/snappy v0.0.3 // indirect
github.com/google/btree v1.0.1 // indirect
github.com/googleapis/gax-go/v2 v2.1.1 // indirect
github.com/gorilla/context v1.1.1 // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect
github.com/hashicorp/errwrap v1.0.0 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/joho/godotenv v1.3.0 // indirect
github.com/jonboulle/clockwork v0.2.2 // indirect
github.com/json-iterator/go v1.1.11 // indirect
github.com/klauspost/compress v1.9.5 // indirect
github.com/klauspost/cpuid v1.2.3 // indirect
github.com/konsorten/go-windows-terminal-sequences v1.0.3 // indirect
github.com/kylelemons/godebug v1.1.0 // indirect
github.com/markbates/hmax v1.0.0 // indirect
github.com/mattn/go-colorable v0.1.9 // indirect
Expand All @@ -94,22 +103,38 @@ require (
github.com/prometheus/common v0.26.0 // indirect
github.com/prometheus/procfs v0.6.0 // indirect
github.com/rogpeppe/go-internal v1.3.0 // indirect
github.com/soheilhy/cmux v0.1.5 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/tinylib/msgp v1.0.2 // indirect
github.com/tmc/grpc-websocket-proxy v0.0.0-20201229170055-e5319fda7802 // indirect
github.com/uber/jaeger-client-go v2.25.0+incompatible // indirect
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
github.com/xdg-go/scram v1.0.2 // indirect
github.com/xdg-go/stringprep v1.0.2 // indirect
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 // indirect
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect
github.com/zclconf/go-cty v0.0.0-20190426224007-b18a157db9e2 // indirect
go.etcd.io/etcd/api/v3 v3.5.2 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.2 // indirect
go.etcd.io/bbolt v1.3.7 // indirect
go.etcd.io/etcd/api/v3 v3.5.9 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.9 // indirect
go.etcd.io/etcd/client/v2 v2.305.9 // indirect
go.etcd.io/etcd/pkg/v3 v3.5.9 // indirect
go.etcd.io/etcd/raft/v3 v3.5.9 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.25.0 // indirect
go.opentelemetry.io/otel v1.0.1 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.0.1 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.0.1 // indirect
go.opentelemetry.io/otel/sdk v1.0.1 // indirect
go.opentelemetry.io/otel/trace v1.0.1 // indirect
go.opentelemetry.io/proto/otlp v0.9.0 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.7.0 // indirect
go.uber.org/zap v1.21.0 // indirect
golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa // indirect
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 // indirect
golang.org/x/net v0.8.0 // indirect
golang.org/x/sys v0.6.0 // indirect
golang.org/x/text v0.8.0 // indirect
golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20220211171837-173942840c17 // indirect
Expand All @@ -118,5 +143,8 @@ require (
gopkg.in/DataDog/dd-trace-go.v1 v1.10.0 // indirect
gopkg.in/go-playground/assert.v1 v1.2.1 // indirect
gopkg.in/ini.v1 v1.42.0 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
sigs.k8s.io/yaml v1.2.0 // indirect
)
Loading

0 comments on commit d7b0edf

Please sign in to comment.