Upgrade dskit and remove dependency on weaveworks/common (#10220)

**What this PR does / why we need it**:

This PR upgrades `github.com/grafana/dskit` removes Loki's dependency on
`github.com/weaveworks/common`.

The changes in dskit, apart from the migration
(https://github.com/grafana/dskit/pull/356), are:

* https://github.com/grafana/dskit/pull/347 
* https://github.com/grafana/dskit/pull/349, which required small
changes in `pkg/canary/reader/reader.go` and `pkg/canary/writer/push.go`
* https://github.com/grafana/dskit/pull/352
* https://github.com/grafana/dskit/pull/354

**Which issue(s) this PR fixes**:

(none)

**Special notes for your reviewer**:

**Checklist**
- [x] Reviewed the
[`CONTRIBUTING.md`](https://github.com/grafana/loki/blob/main/CONTRIBUTING.md)
guide (**required**)
- [n/a] Documentation added
- [n/a] Tests updated
- [n/a] `CHANGELOG.md` updated
- [n/a] If the change is worth mentioning in the release notes, add
`add-to-release-notes` label
- [n/a] Changes that require user attention or interaction to upgrade
are documented in `docs/sources/setup/upgrade/_index.md`
- [n/a] For Helm chart changes bump the Helm chart version in
`production/helm/loki/Chart.yaml` and update
`production/helm/loki/CHANGELOG.md` and
`production/helm/loki/README.md`. [Example
PR](d10549e3ec)

---------

Co-authored-by: Michel Hollands <42814411+MichelHollands@users.noreply.github.com>
pull/10249/head
Charles Korn 3 years ago committed by GitHub
parent 0de80fc306
commit 8e6a5433ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      docs/sources/configure/_index.md
  2. 11
      go.mod
  3. 46
      go.sum
  4. 7
      pkg/canary/reader/reader.go
  5. 7
      pkg/canary/writer/push.go
  6. 2
      pkg/storage/chunk/client/aws/dynamodb_storage_client.go
  7. 2
      pkg/storage/chunk/client/aws/s3_storage_client.go
  8. 2
      pkg/storage/stores/composite_store_test.go
  9. 2
      pkg/storage/stores/series/series_store_test.go
  10. 81
      vendor/github.com/aws/aws-sdk-go/aws/endpoints/defaults.go
  11. 2
      vendor/github.com/aws/aws-sdk-go/aws/version.go
  12. 131
      vendor/github.com/aws/aws-sdk-go/service/ec2/api.go
  13. 4
      vendor/github.com/grafana/dskit/aws/config.go
  14. 4
      vendor/github.com/grafana/dskit/httpgrpc/server/server.go
  15. 128
      vendor/github.com/grafana/dskit/log/ratelimit.go
  16. 101
      vendor/github.com/grafana/dskit/middleware/grpc_instrumentation.go
  17. 50
      vendor/github.com/grafana/dskit/server/server.go
  18. 4
      vendor/github.com/grafana/dskit/test/diff.go
  19. 26
      vendor/github.com/grafana/dskit/test/poll.go
  20. 192
      vendor/github.com/prometheus/common/config/http_config.go
  21. 7
      vendor/github.com/prometheus/exporter-toolkit/web/landing_page.css
  22. 29
      vendor/github.com/prometheus/exporter-toolkit/web/landing_page.go
  23. 11
      vendor/github.com/prometheus/exporter-toolkit/web/landing_page.html
  24. 121
      vendor/github.com/prometheus/exporter-toolkit/web/tls_config.go
  25. 175
      vendor/github.com/weaveworks/common/COPYING.LGPL-3
  26. 191
      vendor/github.com/weaveworks/common/LICENSE
  27. 3
      vendor/github.com/weaveworks/common/NOTICE
  28. 10
      vendor/golang.org/x/sync/errgroup/errgroup.go
  29. 14
      vendor/golang.org/x/sync/errgroup/go120.go
  30. 15
      vendor/golang.org/x/sync/errgroup/pre_go120.go
  31. 20
      vendor/modules.txt

@ -265,6 +265,12 @@ Configures the `server` of the launched module(s).
[tls_min_version: <string> | default = ""]
http_tls_config:
[cert: <string> | default = ""]
[key: <string> | default = ""]
[client_ca: <string> | default = ""]
# HTTP server cert path.
# CLI flag: -server.http-tls-cert-path
[cert_file: <string> | default = ""]
@ -282,6 +288,12 @@ http_tls_config:
[client_ca_file: <string> | default = ""]
grpc_tls_config:
[cert: <string> | default = ""]
[key: <string> | default = ""]
[client_ca: <string> | default = ""]
# GRPC TLS server cert path.
# CLI flag: -server.grpc-tls-cert-path
[cert_file: <string> | default = ""]

@ -16,7 +16,7 @@ require (
github.com/Workiva/go-datastructures v1.1.0
github.com/alicebob/miniredis/v2 v2.30.4
github.com/aliyun/aliyun-oss-go-sdk v2.2.7+incompatible
github.com/aws/aws-sdk-go v1.44.315
github.com/aws/aws-sdk-go v1.44.321
github.com/baidubce/bce-sdk-go v0.9.141
github.com/bmatcuk/doublestar v1.3.4
github.com/buger/jsonparser v1.1.1
@ -49,7 +49,7 @@ require (
github.com/gorilla/mux v1.8.0
github.com/gorilla/websocket v1.5.0
github.com/grafana/cloudflare-go v0.0.0-20230110200409-c627cf6792f2
github.com/grafana/dskit v0.0.0-20230804003603-740f56bd2934
github.com/grafana/dskit v0.0.0-20230811062909-a2c425ae7975
github.com/grafana/go-gelf/v2 v2.0.1
github.com/grafana/gomemcache v0.0.0-20230316202710-a081dae0aba9
github.com/grafana/regexp v0.0.0-20221122212121-6b5c0a4cb7fd
@ -84,7 +84,7 @@ require (
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.16.0
github.com/prometheus/client_model v0.4.0
github.com/prometheus/common v0.43.0
github.com/prometheus/common v0.44.0
github.com/prometheus/prometheus v0.43.1-0.20230419161410-69155c6ba1e9
github.com/segmentio/fasthash v1.0.3
github.com/shurcooL/httpfs v0.0.0-20190707220628-8d4bc4ba7749
@ -94,14 +94,13 @@ require (
github.com/stretchr/testify v1.8.2
github.com/tonistiigi/fifo v0.0.0-20190226154929-a9fb20d87448
github.com/uber/jaeger-client-go v2.30.0+incompatible
github.com/weaveworks/common v0.0.0-20230511094633-334485600903
github.com/xdg-go/scram v1.1.2
go.etcd.io/bbolt v1.3.6
go.uber.org/atomic v1.11.0
go.uber.org/goleak v1.2.1
golang.org/x/crypto v0.11.0
golang.org/x/net v0.12.0
golang.org/x/sync v0.2.0
golang.org/x/sync v0.3.0
golang.org/x/sys v0.10.0
golang.org/x/time v0.3.0
google.golang.org/api v0.126.0
@ -271,7 +270,7 @@ require (
github.com/oschwald/maxminddb-golang v1.10.0 // indirect
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/exporter-toolkit v0.9.1 // indirect
github.com/prometheus/exporter-toolkit v0.10.1-0.20230714054209-2f4150c63f97 // indirect
github.com/prometheus/procfs v0.10.1 // indirect
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
github.com/rootless-containers/rootlesskit v1.1.0 // indirect

@ -554,7 +554,6 @@ github.com/armon/go-metrics v0.4.1 h1:hR91U9KYmb6bLBYLQjyM+3j+rcd/UhE+G78SFnF8gJ
github.com/armon/go-metrics v0.4.1/go.mod h1:E6amYzXo6aW1tqzoZGT755KkbgrJsSdpwZ+3JqfkOG4=
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
github.com/aryann/difflib v0.0.0-20170710044230-e206f873d14a/go.mod h1:DAHtR1m6lCRdSC2Tm3DSWRPvIPr6xNKyeHdqDQSQT+A=
github.com/asaskevich/govalidator v0.0.0-20180319081651-7d2e70ef918f/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY=
github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw=
@ -565,8 +564,8 @@ github.com/aws/aws-sdk-go v1.15.24/go.mod h1:mFuSZ37Z9YOHbQEwBWztmVzqXrEkub65tZo
github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
github.com/aws/aws-sdk-go v1.34.34/go.mod h1:H7NKnBqNVzoTJpGfLrQkkD+ytBA93eiDYi/+8rV9s48=
github.com/aws/aws-sdk-go v1.38.35/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro=
github.com/aws/aws-sdk-go v1.44.315 h1:kYTC+Y/bJ9M7QQRvkI/LN5OWvhkIOL/YuFFRhS5QAOo=
github.com/aws/aws-sdk-go v1.44.315/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI=
github.com/aws/aws-sdk-go v1.44.321 h1:iXwFLxWjZPjYqjPq0EcCs46xX7oDLEELte1+BzgpKk8=
github.com/aws/aws-sdk-go v1.44.321/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI=
github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g=
github.com/aws/aws-sdk-go-v2 v1.16.0 h1:cBAYjiiexRAg9v2z9vb6IdxAa7ef4KCtjW7w7e3GxGo=
github.com/aws/aws-sdk-go-v2 v1.16.0/go.mod h1:lJYcuZZEHWNIb6ugJjbQY1fykdoobWbOS7kJYb4APoI=
@ -626,7 +625,6 @@ github.com/census-instrumentation/opencensus-proto v0.4.1/go.mod h1:4T9NM4+4Vw91
github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko=
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
@ -664,7 +662,6 @@ github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf h1:iW4rZ826su+pqaw19uhpSCzhj44qo35pNgKFGqzDKkU=
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/coreos/go-systemd/v22 v22.4.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs=
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
@ -803,14 +800,12 @@ github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgO
github.com/go-kit/kit v0.12.0 h1:e4o3o3IsBfAKQh5Qbbiqyfu97Ku7jrO/JbohvztANh4=
github.com/go-kit/kit v0.12.0/go.mod h1:lHd+EkCZPIwYItmGDDRdhinkzX2A1sj+M9biaEaizzs=
github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY=
github.com/go-kit/log v0.2.0/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0=
github.com/go-kit/log v0.2.1 h1:MRVx0/zhvdseW+Gza6N9rVzU/IVzaeE1SFI4raAhmBU=
github.com/go-kit/log v0.2.1/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0=
github.com/go-ldap/ldap v3.0.2+incompatible/go.mod h1:qfd9rJvER9Q0/D/Sqn1DfHRoBp40uXYvFoEVrNEPqRc=
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs=
github.com/go-logfmt/logfmt v0.6.0 h1:wGYYu3uicYdqXVgoYbvnkrPVXkuLM1p1ifugDMEdRi4=
github.com/go-logfmt/logfmt v0.6.0/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs=
github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas=
@ -916,11 +911,9 @@ github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7a
github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
github.com/gogo/protobuf v1.2.2-0.20190723190241-65acae22fc9d/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
github.com/gogo/protobuf v1.3.0/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
github.com/gogo/status v1.0.3/go.mod h1:SavQ51ycCLnc7dGyJxp8YAmudx8xqiVrRf+6IXRsugc=
github.com/gogo/status v1.1.1 h1:DuHXlSFHNKqTQ+/ACf5Vs6r4X/dH2EgIzR9Vr+H65kg=
github.com/gogo/status v1.1.1/go.mod h1:jpG3dM5QPcqu19Hg8lkUhBFBa3TcLs1DG7+2Jqci7oU=
github.com/golang-jwt/jwt/v4 v4.0.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg=
@ -1080,8 +1073,8 @@ github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/ad
github.com/gotestyourself/gotestyourself v2.2.0+incompatible/go.mod h1:zZKM6oeNM8k+FRljX1mnzVYeS8wiGgQyvST1/GafPbY=
github.com/grafana/cloudflare-go v0.0.0-20230110200409-c627cf6792f2 h1:qhugDMdQ4Vp68H0tp/0iN17DM2ehRo1rLEdOFe/gB8I=
github.com/grafana/cloudflare-go v0.0.0-20230110200409-c627cf6792f2/go.mod h1:w/aiO1POVIeXUQyl0VQSZjl5OAGDTL5aX+4v0RA1tcw=
github.com/grafana/dskit v0.0.0-20230804003603-740f56bd2934 h1:W1g+y6rOO7K/Jm2XNPxIXyJisJSJ25uiVVaSa7N1Zwo=
github.com/grafana/dskit v0.0.0-20230804003603-740f56bd2934/go.mod h1:Xg0aN3EpqkYFW1ZxGyIl4BGEpr3QrCQOM1aWalpU3ik=
github.com/grafana/dskit v0.0.0-20230811062909-a2c425ae7975 h1:rCBTyr4vKVNh+synt3A3o3jxgcLSk/y958iOdfaIjW0=
github.com/grafana/dskit v0.0.0-20230811062909-a2c425ae7975/go.mod h1:clB9S8ZI/5NiIMCnRv0rA60xs2y1iyVGmO4E5Z8nueE=
github.com/grafana/go-gelf/v2 v2.0.1 h1:BOChP0h/jLeD+7F9mL7tq10xVkDG15he3T1zHuQaWak=
github.com/grafana/go-gelf/v2 v2.0.1/go.mod h1:lexHie0xzYGwCgiRGcvZ723bSNyNI8ZRD4s0CLobh90=
github.com/grafana/gocql v0.0.0-20200605141915-ba5dc39ece85 h1:xLuzPoOzdfNb/RF/IENCw+oLVdZB4G21VPhkHBgwSHY=
@ -1352,7 +1345,6 @@ github.com/mdlayher/genetlink v1.0.0/go.mod h1:0rJ0h4itni50A86M2kHcgS85ttZazNt7a
github.com/mdlayher/netlink v0.0.0-20190409211403-11939a169225/go.mod h1:eQB3mZE4aiYnlUsyGGCOpPETfdQq4Jhsgf1fk3cwQaA=
github.com/mdlayher/netlink v1.0.0/go.mod h1:KxeJAFOFLG6AjpyDkQ/iIhxygIUKD+vcwqcnu43w/+M=
github.com/mdlayher/netlink v1.1.0/go.mod h1:H4WCitaheIsdF9yOYu8CFmCgQthAPIWZmcKp9uZHgmY=
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso=
github.com/miekg/dns v1.1.41/go.mod h1:p6aan82bvRIyn+zDIv9xYNUpwa73JcSh9BKwknJysuI=
@ -1456,11 +1448,9 @@ github.com/opencontainers/image-spec v1.0.1/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zM
github.com/opencontainers/image-spec v1.0.2 h1:9yCKha/T5XdGtO0q9Q9a6T5NUCsTn/DrBg0D7ufOcFM=
github.com/opencontainers/image-spec v1.0.2/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0=
github.com/opencontainers/runc v0.1.1/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U=
github.com/opentracing-contrib/go-grpc v0.0.0-20180928155321-4b5a12d3ff02/go.mod h1:JNdpVEzCpXBgIiv4ds+TzhN1hrtxq6ClLrTlT9OQRSc=
github.com/opentracing-contrib/go-grpc v0.0.0-20210225150812-73cb765af46e h1:4cPxUYdgaGzZIT5/j0IfqOrrXmq6bG8AwvwisMXpdrg=
github.com/opentracing-contrib/go-grpc v0.0.0-20210225150812-73cb765af46e/go.mod h1:DYR5Eij8rJl8h7gblRrOZ8g0kW1umSpKqYIBTgeDtLo=
github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492/go.mod h1:Ngi6UdF0k5OKD5t5wlmGhe/EDKPoUM3BXZSSfIuJbis=
github.com/opentracing-contrib/go-stdlib v0.0.0-20190519235532-cf7a6c988dc9/go.mod h1:PLldrQSroqzH70Xl+1DQcGnefIbqsKR7UDaiux3zV+w=
github.com/opentracing-contrib/go-stdlib v1.0.0 h1:TBS7YuVotp8myLon4Pv7BtCBzOTo1DeZCld0Z63mW2w=
github.com/opentracing-contrib/go-stdlib v1.0.0/go.mod h1:qtI1ogk+2JhVPIXVc6q+NHziSmy2W5GbdQZFUHADCBU=
github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74=
@ -1526,9 +1516,6 @@ github.com/prometheus/client_golang v1.6.1-0.20200604110148-03575cad4e55/go.mod
github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M=
github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0=
github.com/prometheus/client_golang v1.11.1/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0=
github.com/prometheus/client_golang v1.12.1/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY=
github.com/prometheus/client_golang v1.13.0/go.mod h1:vTeo+zgvILHsnnj/39Ou/1fPN5nJFOEMgftOUOmlvYQ=
github.com/prometheus/client_golang v1.14.0/go.mod h1:8vpkKitgIVNcqrRBWh1C4TIUQgYNtG/XQE4E/Zae36Y=
github.com/prometheus/client_golang v1.16.0 h1:yk/hx9hDbrGHovbci4BY+pRMfSuuat626eFsHb7tmT8=
github.com/prometheus/client_golang v1.16.0/go.mod h1:Zsulrv/L9oM40tJ7T815tM89lFEugiJ9HzIqaAx4LKc=
github.com/prometheus/client_model v0.0.0-20171117100541-99fa1f4be8e5/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
@ -1538,7 +1525,6 @@ github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.1.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.3.0/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w=
github.com/prometheus/client_model v0.4.0 h1:5lQXD3cAg1OXBf4Wq03gTrXHeaV0TQvGfUooCfx1yqY=
github.com/prometheus/client_model v0.4.0/go.mod h1:oMQmHW1/JoDwqLtg57MGgP/Fb1CJEYF2imWWhWtMkYU=
github.com/prometheus/common v0.0.0-20180326160409-38c53a9f4bfc/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro=
@ -1551,15 +1537,12 @@ github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8b
github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo=
github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc=
github.com/prometheus/common v0.29.0/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls=
github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls=
github.com/prometheus/common v0.37.0/go.mod h1:phzohg0JFMnBEFGxTDbfu3QyL5GI8gTQJFhYO5B3mfA=
github.com/prometheus/common v0.43.0 h1:iq+BVjvYLei5f27wiuNiB1DN6DYQkp1c8Bx0Vykh5us=
github.com/prometheus/common v0.43.0/go.mod h1:NCvr5cQIh3Y/gy73/RdVtC9r8xxrxwJnB+2lB3BxrFc=
github.com/prometheus/common v0.44.0 h1:+5BrQJwiBB9xsMygAB3TNvpQKOwlkc25LbISbrdOOfY=
github.com/prometheus/common v0.44.0/go.mod h1:ofAIvZbQ1e/nugmZGz4/qCb9Ap1VoSTIO7x0VV9VvuY=
github.com/prometheus/common/sigv4 v0.1.0 h1:qoVebwtwwEhS85Czm2dSROY5fTo2PAPEVdDeppTwGX4=
github.com/prometheus/common/sigv4 v0.1.0/go.mod h1:2Jkxxk9yYvCkE5G1sQT7GuEXm57JrvHu9k5YwTjsNtI=
github.com/prometheus/exporter-toolkit v0.8.2/go.mod h1:00shzmJL7KxcsabLWcONwpyNEuWhREOnFqZW7vadFS0=
github.com/prometheus/exporter-toolkit v0.9.1 h1:cNkC01riqiOS+kh3zdnNwRsbe/Blh0WwK3ij5rPJ9Sw=
github.com/prometheus/exporter-toolkit v0.9.1/go.mod h1:iFlTmFISCix0vyuyBmm0UqOUCTao9+RsAsKJP3YM9ec=
github.com/prometheus/exporter-toolkit v0.10.1-0.20230714054209-2f4150c63f97 h1:oHcfzdJnM/SFppy2aUlvomk37GI33x9vgJULihE5Dt8=
github.com/prometheus/exporter-toolkit v0.10.1-0.20230714054209-2f4150c63f97/go.mod h1:LoBCZeRh+5hX+fSULNyFnagYlQG/gBsyA/deNzROkq8=
github.com/prometheus/procfs v0.0.0-20180408092902-8b1c2da0d56d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
@ -1570,8 +1553,6 @@ github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+Gx
github.com/prometheus/procfs v0.0.11/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
github.com/prometheus/procfs v0.8.0/go.mod h1:z7EfXMXOkbkqb9IINtpCn86r/to3BnA0uaxHdg830/4=
github.com/prometheus/procfs v0.10.1 h1:kYK1Va/YMlutzCGazswoHKo//tZVlFpKYh+PymziUAg=
github.com/prometheus/procfs v0.10.1/go.mod h1:nwNm2aOCAYw8uTR/9bWRREkZFxAUcWzPHWJq+XBB/FM=
github.com/prometheus/prometheus v0.43.1-0.20230419161410-69155c6ba1e9 h1:GrpznPCSJgx8mGGj5qfKoHiou/dVx7uMce9/9rSdiuY=
@ -1696,10 +1677,8 @@ github.com/tonistiigi/fifo v0.0.0-20190226154929-a9fb20d87448 h1:hbyjqt5UnyKeOT3
github.com/tonistiigi/fifo v0.0.0-20190226154929-a9fb20d87448/go.mod h1:Q5IRRDY+cjIaiOjTAnXN5LKQV5MPqVx5ofQn85Jy5Yw=
github.com/ttacon/chalk v0.0.0-20160626202418-22c06c80ed31/go.mod h1:onvgF043R+lC5RZ8IT9rBXDaEDnpnw/Cl+HFiw+v/7Q=
github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM=
github.com/uber/jaeger-client-go v2.28.0+incompatible/go.mod h1:WVhlPFC8FDjOFMMWRy2pZqQJSXxYSwNYOkTr/Z6d3Kk=
github.com/uber/jaeger-client-go v2.30.0+incompatible h1:D6wyKGCecFaSRUpo8lCVbaOOb6ThwMmTEbhRwtKR97o=
github.com/uber/jaeger-client-go v2.30.0+incompatible/go.mod h1:WVhlPFC8FDjOFMMWRy2pZqQJSXxYSwNYOkTr/Z6d3Kk=
github.com/uber/jaeger-lib v2.2.0+incompatible/go.mod h1:ComeNDZlWwrWnDv8aPp0Ba6+uUTzImX/AauajbLI56U=
github.com/uber/jaeger-lib v2.4.1+incompatible h1:td4jdvLcExb4cBISKIpHuGoVXh+dVKhn2Um6rjCsSsg=
github.com/uber/jaeger-lib v2.4.1+incompatible/go.mod h1:ComeNDZlWwrWnDv8aPp0Ba6+uUTzImX/AauajbLI56U=
github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc=
@ -1715,8 +1694,6 @@ github.com/vmware/govmomi v0.18.0/go.mod h1:URlwyTFZX72RmxtxuaFL2Uj3fD1JTvZdx59b
github.com/vmware/govmomi v0.19.0/go.mod h1:URlwyTFZX72RmxtxuaFL2Uj3fD1JTvZdx59bHWk6aFU=
github.com/vultr/govultr/v2 v2.17.2 h1:gej/rwr91Puc/tgh+j33p/BLR16UrIPnSr+AIwYWZQs=
github.com/wavefronthq/wavefront-sdk-go v0.9.2/go.mod h1:hQI6y8M9OtTCtc0xdwh+dCER4osxXdEAeCpacjpDZEU=
github.com/weaveworks/common v0.0.0-20230511094633-334485600903 h1:ph7R2CS/0o1gBzpzK/CioUKJVsXNVXfDGR8FZ9rMZIw=
github.com/weaveworks/common v0.0.0-20230511094633-334485600903/go.mod h1:rgbeLfJUtEr+G74cwFPR1k/4N0kDeaeSv/qhUNE4hm8=
github.com/weaveworks/promrus v1.2.0 h1:jOLf6pe6/vss4qGHjXmGz4oDJQA+AOCqEL3FvvZGz7M=
github.com/weaveworks/promrus v1.2.0/go.mod h1:SaE82+OJ91yqjrE1rsvBWVzNZKcHYFtMUyS1+Ogs/KA=
github.com/willf/bitset v1.1.11 h1:N7Z7E9UvjW+sGsEl7k/SJrvY2reP1A07MrGuCjIOjRE=
@ -1791,7 +1768,6 @@ go.starlark.net v0.0.0-20200901195727-6e684ef5eeee/go.mod h1:f0znQkUKRrkk36XxWbG
go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
go.uber.org/atomic v1.5.1/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE=
go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
@ -1837,7 +1813,6 @@ golang.org/x/crypto v0.0.0-20220314234659-1baeb1ce4c0b/go.mod h1:IxCIyHEi3zRg3s0
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.0.0-20221012134737-56aed061732a/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4=
golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58=
golang.org/x/crypto v0.11.0 h1:6Ewdq3tDic1mg5xRO4milcWCfMVQhI4NkqWWvqejpuA=
@ -2013,8 +1988,8 @@ golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220929204114-8fcdb60fdcc0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.2.0 h1:PUR+T4wwASmuSTYdKjYHI5TD22Wy5ogLU5qZCOLxBrI=
golang.org/x/sync v0.2.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E=
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
golang.org/x/sys v0.0.0-20170830134202-bb24a47a89ea/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
@ -2106,7 +2081,6 @@ golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211210111614-af8b64212486/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=

@ -99,7 +99,12 @@ func NewReader(writer io.Writer,
httpClient := http.DefaultClient
if tlsConfig != nil && (certFile != "" || keyFile != "" || caFile != "") {
// For the mTLS case, use a http.Client configured with the client side certificates.
rt, err := config.NewTLSRoundTripper(tlsConfig, caFile, certFile, keyFile, func(tls *tls.Config) (http.RoundTripper, error) {
tlsSettings := config.TLSRoundTripperSettings{
CAFile: caFile,
CertFile: certFile,
KeyFile: keyFile,
}
rt, err := config.NewTLSRoundTripper(tlsConfig, tlsSettings, func(tls *tls.Config) (http.RoundTripper, error) {
return &http.Transport{TLSClientConfig: tls}, nil
})
if err != nil {

@ -87,7 +87,12 @@ func NewPush(
// setup tls transport
if tlsCfg != nil {
rt, err := config.NewTLSRoundTripper(tlsCfg, caFile, certFile, keyFile, func(tls *tls.Config) (http.RoundTripper, error) {
tlsSettings := config.TLSRoundTripperSettings{
CAFile: caFile,
CertFile: certFile,
KeyFile: keyFile,
}
rt, err := config.NewTLSRoundTripper(tlsCfg, tlsSettings, func(tls *tls.Config) (http.RoundTripper, error) {
return &http.Transport{TLSClientConfig: tls}, nil
})
if err != nil {

@ -18,6 +18,7 @@ import (
"github.com/aws/aws-sdk-go/service/dynamodb"
"github.com/aws/aws-sdk-go/service/dynamodb/dynamodbiface"
"github.com/go-kit/log/level"
awscommon "github.com/grafana/dskit/aws"
"github.com/grafana/dskit/backoff"
"github.com/grafana/dskit/flagext"
"github.com/grafana/dskit/instrument"
@ -25,7 +26,6 @@ import (
otlog "github.com/opentracing/opentracing-go/log"
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"
awscommon "github.com/weaveworks/common/aws"
"golang.org/x/time/rate"
"github.com/grafana/loki/pkg/storage/chunk"

@ -22,13 +22,13 @@ import (
v4 "github.com/aws/aws-sdk-go/aws/signer/v4"
"github.com/aws/aws-sdk-go/service/s3"
"github.com/aws/aws-sdk-go/service/s3/s3iface"
awscommon "github.com/grafana/dskit/aws"
"github.com/grafana/dskit/backoff"
"github.com/grafana/dskit/flagext"
"github.com/grafana/dskit/instrument"
"github.com/minio/minio-go/v7/pkg/signer"
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"
awscommon "github.com/weaveworks/common/aws"
bucket_s3 "github.com/grafana/loki/pkg/storage/bucket/s3"
"github.com/grafana/loki/pkg/storage/chunk/client"

@ -10,10 +10,10 @@ import (
"github.com/grafana/loki/pkg/logproto"
"github.com/grafana/dskit/test"
"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/model/labels"
"github.com/stretchr/testify/require"
"github.com/weaveworks/common/test"
"github.com/grafana/loki/pkg/storage/chunk"
"github.com/grafana/loki/pkg/storage/chunk/fetcher"

@ -9,13 +9,13 @@ import (
"github.com/go-kit/log"
"github.com/grafana/dskit/flagext"
"github.com/grafana/dskit/test"
"github.com/grafana/dskit/user"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/model/labels"
"github.com/prometheus/prometheus/promql/parser"
"github.com/stretchr/testify/require"
"github.com/weaveworks/common/test"
"github.com/grafana/loki/pkg/ingester/client"
"github.com/grafana/loki/pkg/logqlmodel/stats"

@ -10442,6 +10442,15 @@ var awsPartition = partition{
},
Deprecated: boxedTrue,
},
endpointKey{
Region: "fips-il-central-1",
}: endpoint{
Hostname: "elasticfilesystem-fips.il-central-1.amazonaws.com",
CredentialScope: credentialScope{
Region: "il-central-1",
},
Deprecated: boxedTrue,
},
endpointKey{
Region: "fips-me-central-1",
}: endpoint{
@ -10505,6 +10514,15 @@ var awsPartition = partition{
},
Deprecated: boxedTrue,
},
endpointKey{
Region: "il-central-1",
}: endpoint{},
endpointKey{
Region: "il-central-1",
Variant: fipsVariant,
}: endpoint{
Hostname: "elasticfilesystem-fips.il-central-1.amazonaws.com",
},
endpointKey{
Region: "me-central-1",
}: endpoint{},
@ -13706,6 +13724,9 @@ var awsPartition = partition{
endpointKey{
Region: "af-south-1",
}: endpoint{},
endpointKey{
Region: "ap-east-1",
}: endpoint{},
endpointKey{
Region: "ap-northeast-1",
}: endpoint{},
@ -13748,6 +13769,9 @@ var awsPartition = partition{
endpointKey{
Region: "eu-west-3",
}: endpoint{},
endpointKey{
Region: "me-south-1",
}: endpoint{},
endpointKey{
Region: "sa-east-1",
}: endpoint{},
@ -13757,6 +13781,9 @@ var awsPartition = partition{
endpointKey{
Region: "us-east-2",
}: endpoint{},
endpointKey{
Region: "us-west-1",
}: endpoint{},
endpointKey{
Region: "us-west-2",
}: endpoint{},
@ -15912,6 +15939,9 @@ var awsPartition = partition{
endpointKey{
Region: "eu-west-3",
}: endpoint{},
endpointKey{
Region: "il-central-1",
}: endpoint{},
endpointKey{
Region: "me-central-1",
}: endpoint{},
@ -17196,6 +17226,9 @@ var awsPartition = partition{
},
Deprecated: boxedTrue,
},
endpointKey{
Region: "il-central-1",
}: endpoint{},
endpointKey{
Region: "me-central-1",
}: endpoint{},
@ -23162,6 +23195,9 @@ var awsPartition = partition{
endpointKey{
Region: "eu-west-3",
}: endpoint{},
endpointKey{
Region: "il-central-1",
}: endpoint{},
endpointKey{
Region: "me-central-1",
}: endpoint{},
@ -25003,6 +25039,9 @@ var awsPartition = partition{
},
Deprecated: boxedTrue,
},
endpointKey{
Region: "il-central-1",
}: endpoint{},
endpointKey{
Region: "me-central-1",
}: endpoint{},
@ -25254,6 +25293,9 @@ var awsPartition = partition{
endpointKey{
Region: "eu-west-3",
}: endpoint{},
endpointKey{
Region: "il-central-1",
}: endpoint{},
endpointKey{
Region: "me-central-1",
}: endpoint{},
@ -28656,6 +28698,25 @@ var awsPartition = partition{
},
},
},
"tnb": service{
Endpoints: serviceEndpoints{
endpointKey{
Region: "ap-southeast-2",
}: endpoint{},
endpointKey{
Region: "eu-central-1",
}: endpoint{},
endpointKey{
Region: "eu-west-3",
}: endpoint{},
endpointKey{
Region: "us-east-1",
}: endpoint{},
endpointKey{
Region: "us-west-2",
}: endpoint{},
},
},
"transcribe": service{
Defaults: endpointDefaults{
defaultKey{}: endpoint{
@ -31673,6 +31734,16 @@ var awscnPartition = partition{
}: endpoint{},
},
},
"arc-zonal-shift": service{
Endpoints: serviceEndpoints{
endpointKey{
Region: "cn-north-1",
}: endpoint{},
endpointKey{
Region: "cn-northwest-1",
}: endpoint{},
},
},
"athena": service{
Endpoints: serviceEndpoints{
endpointKey{
@ -36911,6 +36982,16 @@ var awsusgovPartition = partition{
},
},
},
"license-manager-linux-subscriptions": service{
Endpoints: serviceEndpoints{
endpointKey{
Region: "us-gov-east-1",
}: endpoint{},
endpointKey{
Region: "us-gov-west-1",
}: endpoint{},
},
},
"logs": service{
Endpoints: serviceEndpoints{
endpointKey{

@ -5,4 +5,4 @@ package aws
const SDKName = "aws-sdk-go"
// SDKVersion is the version of this SDK
const SDKVersion = "1.44.315"
const SDKVersion = "1.44.321"

@ -72923,6 +72923,21 @@ type CreateNetworkInterfaceInput struct {
// it is UnauthorizedOperation.
DryRun *bool `locationName:"dryRun" type:"boolean"`
// If you’re creating a network interface in a dual-stack or IPv6-only subnet,
// you have the option to assign a primary IPv6 IP address. A primary IPv6 address
// is an IPv6 GUA address associated with an ENI that you have enabled to use
// a primary IPv6 address. Use this option if the instance that this ENI will
// be attached to relies on its IPv6 address not changing. Amazon Web Services
// will automatically assign an IPv6 address associated with the ENI attached
// to your instance to be the primary IPv6 address. Once you enable an IPv6
// GUA address to be a primary IPv6, you cannot disable it. When you enable
// an IPv6 GUA address to be a primary IPv6, the first IPv6 GUA will be made
// the primary IPv6 address until the instance is terminated or the network
// interface is detached. If you have multiple IPv6 addresses associated with
// an ENI attached to your instance and you enable a primary IPv6 address, the
// first IPv6 GUA address associated with the ENI becomes the primary IPv6 address.
EnablePrimaryIpv6 *bool `type:"boolean"`
// The IDs of one or more security groups.
Groups []*string `locationName:"SecurityGroupId" locationNameList:"SecurityGroupId" type:"list"`
@ -73060,6 +73075,12 @@ func (s *CreateNetworkInterfaceInput) SetDryRun(v bool) *CreateNetworkInterfaceI
return s
}
// SetEnablePrimaryIpv6 sets the EnablePrimaryIpv6 field's value.
func (s *CreateNetworkInterfaceInput) SetEnablePrimaryIpv6(v bool) *CreateNetworkInterfaceInput {
s.EnablePrimaryIpv6 = &v
return s
}
// SetGroups sets the Groups field's value.
func (s *CreateNetworkInterfaceInput) SetGroups(v []*string) *CreateNetworkInterfaceInput {
s.Groups = v
@ -112880,8 +112901,7 @@ type EbsBlockDevice struct {
// The ARN of the Outpost on which the snapshot is stored.
//
// This parameter is only supported on BlockDeviceMapping objects called by
// CreateImage (https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_CreateImage.html).
// This parameter is not supported when using CreateImage (https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_CreateImage.html).
OutpostArn *string `locationName:"outpostArn" type:"string"`
// The ID of the snapshot.
@ -130058,6 +130078,13 @@ type InstanceIpv6Address struct {
// The IPv6 address.
Ipv6Address *string `locationName:"ipv6Address" type:"string"`
// Determines if an IPv6 address associated with a network interface is the
// primary IPv6 address. When you enable an IPv6 GUA address to be a primary
// IPv6, the first IPv6 GUA will be made the primary IPv6 address until the
// instance is terminated or the network interface is detached. For more information,
// see RunInstances (https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_RunInstances.html).
IsPrimaryIpv6 *bool `locationName:"isPrimaryIpv6" type:"boolean"`
}
// String returns the string representation.
@ -130084,6 +130111,12 @@ func (s *InstanceIpv6Address) SetIpv6Address(v string) *InstanceIpv6Address {
return s
}
// SetIsPrimaryIpv6 sets the IsPrimaryIpv6 field's value.
func (s *InstanceIpv6Address) SetIsPrimaryIpv6(v bool) *InstanceIpv6Address {
s.IsPrimaryIpv6 = &v
return s
}
// Describes an IPv6 address.
type InstanceIpv6AddressRequest struct {
_ struct{} `type:"structure"`
@ -130922,6 +130955,13 @@ type InstanceNetworkInterfaceSpecification struct {
// specify a network interface ID in a launch specification.
NetworkInterfaceId *string `locationName:"networkInterfaceId" type:"string"`
// The primary IPv6 address of the network interface. When you enable an IPv6
// GUA address to be a primary IPv6, the first IPv6 GUA will be made the primary
// IPv6 address until the instance is terminated or the network interface is
// detached. For more information about primary IPv6 addresses, see RunInstances
// (https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_RunInstances.html).
PrimaryIpv6 *bool `type:"boolean"`
// The private IPv4 address of the network interface. Applies only if creating
// a network interface when launching an instance. You cannot specify this option
// if you're launching more than one instance in a RunInstances (https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_RunInstances.html)
@ -131054,6 +131094,12 @@ func (s *InstanceNetworkInterfaceSpecification) SetNetworkInterfaceId(v string)
return s
}
// SetPrimaryIpv6 sets the PrimaryIpv6 field's value.
func (s *InstanceNetworkInterfaceSpecification) SetPrimaryIpv6(v bool) *InstanceNetworkInterfaceSpecification {
s.PrimaryIpv6 = &v
return s
}
// SetPrivateIpAddress sets the PrivateIpAddress field's value.
func (s *InstanceNetworkInterfaceSpecification) SetPrivateIpAddress(v string) *InstanceNetworkInterfaceSpecification {
s.PrivateIpAddress = &v
@ -137434,6 +137480,13 @@ type LaunchTemplateInstanceNetworkInterfaceSpecification struct {
// The ID of the network interface.
NetworkInterfaceId *string `locationName:"networkInterfaceId" type:"string"`
// The primary IPv6 address of the network interface. When you enable an IPv6
// GUA address to be a primary IPv6, the first IPv6 GUA will be made the primary
// IPv6 address until the instance is terminated or the network interface is
// detached. For more information about primary IPv6 addresses, see RunInstances
// (https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_RunInstances.html).
PrimaryIpv6 *bool `locationName:"primaryIpv6" type:"boolean"`
// The primary private IPv4 address of the network interface.
PrivateIpAddress *string `locationName:"privateIpAddress" type:"string"`
@ -137555,6 +137608,12 @@ func (s *LaunchTemplateInstanceNetworkInterfaceSpecification) SetNetworkInterfac
return s
}
// SetPrimaryIpv6 sets the PrimaryIpv6 field's value.
func (s *LaunchTemplateInstanceNetworkInterfaceSpecification) SetPrimaryIpv6(v bool) *LaunchTemplateInstanceNetworkInterfaceSpecification {
s.PrimaryIpv6 = &v
return s
}
// SetPrivateIpAddress sets the PrivateIpAddress field's value.
func (s *LaunchTemplateInstanceNetworkInterfaceSpecification) SetPrivateIpAddress(v string) *LaunchTemplateInstanceNetworkInterfaceSpecification {
s.PrivateIpAddress = &v
@ -137648,6 +137707,13 @@ type LaunchTemplateInstanceNetworkInterfaceSpecificationRequest struct {
// The ID of the network interface.
NetworkInterfaceId *string `type:"string"`
// The primary IPv6 address of the network interface. When you enable an IPv6
// GUA address to be a primary IPv6, the first IPv6 GUA will be made the primary
// IPv6 address until the instance is terminated or the network interface is
// detached. For more information about primary IPv6 addresses, see RunInstances
// (https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_RunInstances.html).
PrimaryIpv6 *bool `type:"boolean"`
// The primary private IPv4 address of the network interface.
PrivateIpAddress *string `type:"string"`
@ -137769,6 +137835,12 @@ func (s *LaunchTemplateInstanceNetworkInterfaceSpecificationRequest) SetNetworkI
return s
}
// SetPrimaryIpv6 sets the PrimaryIpv6 field's value.
func (s *LaunchTemplateInstanceNetworkInterfaceSpecificationRequest) SetPrimaryIpv6(v bool) *LaunchTemplateInstanceNetworkInterfaceSpecificationRequest {
s.PrimaryIpv6 = &v
return s
}
// SetPrivateIpAddress sets the PrivateIpAddress field's value.
func (s *LaunchTemplateInstanceNetworkInterfaceSpecificationRequest) SetPrivateIpAddress(v string) *LaunchTemplateInstanceNetworkInterfaceSpecificationRequest {
s.PrivateIpAddress = &v
@ -144423,6 +144495,21 @@ type ModifyNetworkInterfaceAttributeInput struct {
// attached to the instance.
EnaSrdSpecification *EnaSrdSpecification `type:"structure"`
// If you’re modifying a network interface in a dual-stack or IPv6-only subnet,
// you have the option to assign a primary IPv6 IP address. A primary IPv6 address
// is an IPv6 GUA address associated with an ENI that you have enabled to use
// a primary IPv6 address. Use this option if the instance that this ENI will
// be attached to relies on its IPv6 address not changing. Amazon Web Services
// will automatically assign an IPv6 address associated with the ENI attached
// to your instance to be the primary IPv6 address. Once you enable an IPv6
// GUA address to be a primary IPv6, you cannot disable it. When you enable
// an IPv6 GUA address to be a primary IPv6, the first IPv6 GUA will be made
// the primary IPv6 address until the instance is terminated or the network
// interface is detached. If you have multiple IPv6 addresses associated with
// an ENI attached to your instance and you enable a primary IPv6 address, the
// first IPv6 GUA address associated with the ENI becomes the primary IPv6 address.
EnablePrimaryIpv6 *bool `type:"boolean"`
// Changes the security groups for the network interface. The new set of groups
// you specify replaces the current set. You must specify at least one group,
// even if it's just the default security group in the VPC. You must specify
@ -144498,6 +144585,12 @@ func (s *ModifyNetworkInterfaceAttributeInput) SetEnaSrdSpecification(v *EnaSrdS
return s
}
// SetEnablePrimaryIpv6 sets the EnablePrimaryIpv6 field's value.
func (s *ModifyNetworkInterfaceAttributeInput) SetEnablePrimaryIpv6(v bool) *ModifyNetworkInterfaceAttributeInput {
s.EnablePrimaryIpv6 = &v
return s
}
// SetGroups sets the Groups field's value.
func (s *ModifyNetworkInterfaceAttributeInput) SetGroups(v []*string) *ModifyNetworkInterfaceAttributeInput {
s.Groups = v
@ -151911,6 +152004,13 @@ type NetworkInterfaceIpv6Address struct {
// The IPv6 address.
Ipv6Address *string `locationName:"ipv6Address" type:"string"`
// Determines if an IPv6 address associated with a network interface is the
// primary IPv6 address. When you enable an IPv6 GUA address to be a primary
// IPv6, the first IPv6 GUA will be made the primary IPv6 address until the
// instance is terminated or the network interface is detached. For more information,
// see ModifyNetworkInterfaceAttribute (https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_ModifyNetworkInterfaceAttribute.html).
IsPrimaryIpv6 *bool `locationName:"isPrimaryIpv6" type:"boolean"`
}
// String returns the string representation.
@ -151937,6 +152037,12 @@ func (s *NetworkInterfaceIpv6Address) SetIpv6Address(v string) *NetworkInterface
return s
}
// SetIsPrimaryIpv6 sets the IsPrimaryIpv6 field's value.
func (s *NetworkInterfaceIpv6Address) SetIsPrimaryIpv6(v bool) *NetworkInterfaceIpv6Address {
s.IsPrimaryIpv6 = &v
return s
}
// Describes a permission for a network interface.
type NetworkInterfacePermission struct {
_ struct{} `type:"structure"`
@ -164029,6 +164135,21 @@ type RunInstancesInput struct {
// are considered current customers and will be able to continue using the service.
ElasticInferenceAccelerators []*ElasticInferenceAccelerator `locationName:"ElasticInferenceAccelerator" locationNameList:"item" type:"list"`
// If you’re launching an instance into a dual-stack or IPv6-only subnet,
// you can enable assigning a primary IPv6 address. A primary IPv6 address is
// an IPv6 GUA address associated with an ENI that you have enabled to use a
// primary IPv6 address. Use this option if an instance relies on its IPv6 address
// not changing. When you launch the instance, Amazon Web Services will automatically
// assign an IPv6 address associated with the ENI attached to your instance
// to be the primary IPv6 address. Once you enable an IPv6 GUA address to be
// a primary IPv6, you cannot disable it. When you enable an IPv6 GUA address
// to be a primary IPv6, the first IPv6 GUA will be made the primary IPv6 address
// until the instance is terminated or the network interface is detached. If
// you have multiple IPv6 addresses associated with an ENI attached to your
// instance and you enable a primary IPv6 address, the first IPv6 GUA address
// associated with the ENI becomes the primary IPv6 address.
EnablePrimaryIpv6 *bool `type:"boolean"`
// Indicates whether the instance is enabled for Amazon Web Services Nitro Enclaves.
// For more information, see What is Amazon Web Services Nitro Enclaves? (https://docs.aws.amazon.com/enclaves/latest/user/nitro-enclave.html)
// in the Amazon Web Services Nitro Enclaves User Guide.
@ -164366,6 +164487,12 @@ func (s *RunInstancesInput) SetElasticInferenceAccelerators(v []*ElasticInferenc
return s
}
// SetEnablePrimaryIpv6 sets the EnablePrimaryIpv6 field's value.
func (s *RunInstancesInput) SetEnablePrimaryIpv6(v bool) *RunInstancesInput {
s.EnablePrimaryIpv6 = &v
return s
}
// SetEnclaveOptions sets the EnclaveOptions field's value.
func (s *RunInstancesInput) SetEnclaveOptions(v *EnclaveOptionsRequest) *RunInstancesInput {
s.EnclaveOptions = v

@ -1,3 +1,7 @@
// Provenance-includes-location: https://github.com/weaveworks/common/blob/main/aws/config.go
// Provenance-includes-license: Apache-2.0
// Provenance-includes-copyright: Weaveworks Ltd.
package aws
import (

@ -8,7 +8,7 @@ import (
"bytes"
"context"
"fmt"
"io/ioutil"
"io"
"net"
"net/http"
"net/http/httptest"
@ -154,7 +154,7 @@ func NewClient(address string) (*Client, error) {
// HTTPRequest wraps an ordinary HTTPRequest with a gRPC one
func HTTPRequest(r *http.Request) (*httpgrpc.HTTPRequest, error) {
body, err := ioutil.ReadAll(r.Body)
body, err := io.ReadAll(r.Body)
if err != nil {
return nil, err
}

@ -0,0 +1,128 @@
package log
import (
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"golang.org/x/time/rate"
)
const (
infoLevel = "info"
debugLevel = "debug"
warnLevel = "warning"
errorLevel = "error"
)
type RateLimitedLogger struct {
next Interface
limiter *rate.Limiter
discardedInfoLogLinesCounter prometheus.Counter
discardedDebugLogLinesCounter prometheus.Counter
discardedWarnLogLinesCounter prometheus.Counter
discardedErrorLogLinesCounter prometheus.Counter
}
// NewRateLimitedLogger returns a logger.Interface that is limited to the given number of logs per second,
// with the given burst size.
func NewRateLimitedLogger(logger Interface, logsPerSecond rate.Limit, burstSize int, reg prometheus.Registerer) Interface {
discardedLogLinesCounter := promauto.With(reg).NewCounterVec(prometheus.CounterOpts{
Name: "logger_rate_limit_discarded_log_lines_total",
Help: "Total number of discarded log lines per level.",
}, []string{"level"})
return &RateLimitedLogger{
next: logger,
limiter: rate.NewLimiter(logsPerSecond, burstSize),
discardedInfoLogLinesCounter: discardedLogLinesCounter.WithLabelValues(infoLevel),
discardedDebugLogLinesCounter: discardedLogLinesCounter.WithLabelValues(debugLevel),
discardedWarnLogLinesCounter: discardedLogLinesCounter.WithLabelValues(warnLevel),
discardedErrorLogLinesCounter: discardedLogLinesCounter.WithLabelValues(errorLevel),
}
}
func (l *RateLimitedLogger) Debugf(format string, args ...interface{}) {
if l.limiter.Allow() {
l.next.Debugf(format, args...)
} else {
l.discardedDebugLogLinesCounter.Inc()
}
}
func (l *RateLimitedLogger) Debugln(args ...interface{}) {
if l.limiter.Allow() {
l.next.Debugln(args...)
} else {
l.discardedDebugLogLinesCounter.Inc()
}
}
func (l *RateLimitedLogger) Infof(format string, args ...interface{}) {
if l.limiter.Allow() {
l.next.Infof(format, args...)
} else {
l.discardedInfoLogLinesCounter.Inc()
}
}
func (l *RateLimitedLogger) Infoln(args ...interface{}) {
if l.limiter.Allow() {
l.next.Infoln(args...)
} else {
l.discardedInfoLogLinesCounter.Inc()
}
}
func (l *RateLimitedLogger) Errorf(format string, args ...interface{}) {
if l.limiter.Allow() {
l.next.Errorf(format, args...)
} else {
l.discardedErrorLogLinesCounter.Inc()
}
}
func (l *RateLimitedLogger) Errorln(args ...interface{}) {
if l.limiter.Allow() {
l.next.Errorln(args...)
} else {
l.discardedErrorLogLinesCounter.Inc()
}
}
func (l *RateLimitedLogger) Warnf(format string, args ...interface{}) {
if l.limiter.Allow() {
l.next.Warnf(format, args...)
} else {
l.discardedWarnLogLinesCounter.Inc()
}
}
func (l *RateLimitedLogger) Warnln(args ...interface{}) {
if l.limiter.Allow() {
l.next.Warnln(args...)
} else {
l.discardedWarnLogLinesCounter.Inc()
}
}
func (l *RateLimitedLogger) WithField(key string, value interface{}) Interface {
return &RateLimitedLogger{
next: l.next.WithField(key, value),
limiter: l.limiter,
discardedInfoLogLinesCounter: l.discardedInfoLogLinesCounter,
discardedDebugLogLinesCounter: l.discardedDebugLogLinesCounter,
discardedWarnLogLinesCounter: l.discardedWarnLogLinesCounter,
discardedErrorLogLinesCounter: l.discardedErrorLogLinesCounter,
}
}
func (l *RateLimitedLogger) WithFields(f Fields) Interface {
return &RateLimitedLogger{
next: l.next.WithFields(f),
limiter: l.limiter,
discardedInfoLogLinesCounter: l.discardedInfoLogLinesCounter,
discardedDebugLogLinesCounter: l.discardedDebugLogLinesCounter,
discardedWarnLogLinesCounter: l.discardedWarnLogLinesCounter,
discardedErrorLogLinesCounter: l.discardedErrorLogLinesCounter,
}
}

@ -11,10 +11,11 @@ import (
"time"
"github.com/prometheus/client_golang/prometheus"
"go.uber.org/atomic"
"google.golang.org/grpc"
"google.golang.org/grpc/metadata"
grpcUtils "github.com/grafana/dskit/grpcutil"
"github.com/grafana/dskit/grpcutil"
"github.com/grafana/dskit/httpgrpc"
"github.com/grafana/dskit/instrument"
)
@ -24,7 +25,7 @@ func observe(ctx context.Context, hist *prometheus.HistogramVec, method string,
if err != nil {
if errResp, ok := httpgrpc.HTTPResponseFromError(err); ok {
respStatus = strconv.Itoa(int(errResp.Code))
} else if grpcUtils.IsCanceled(err) {
} else if grpcutil.IsCanceled(err) {
respStatus = "cancel"
} else {
respStatus = "error"
@ -70,60 +71,108 @@ func StreamClientInstrumentInterceptor(metric *prometheus.HistogramVec) grpc.Str
) (grpc.ClientStream, error) {
start := time.Now()
stream, err := streamer(ctx, desc, cc, method, opts...)
return &instrumentedClientStream{
metric: metric,
start: start,
method: method,
ClientStream: stream,
}, err
s := &instrumentedClientStream{
metric: metric,
start: start,
method: method,
serverStreams: desc.ServerStreams,
finished: atomic.NewBool(false),
finishedChan: make(chan struct{}),
stream: stream,
}
s.awaitCompletion(ctx)
return s, err
}
}
// This implementation is heavily inspired by github.com/opentracing-contrib/go-grpc's openTracingClientStream.
type instrumentedClientStream struct {
metric *prometheus.HistogramVec
start time.Time
method string
grpc.ClientStream
metric *prometheus.HistogramVec
start time.Time
method string
serverStreams bool
finished *atomic.Bool
finishedChan chan struct{}
stream grpc.ClientStream
}
func (s *instrumentedClientStream) SendMsg(m interface{}) error {
err := s.ClientStream.SendMsg(m)
if err == nil {
return nil
func (s *instrumentedClientStream) Trailer() metadata.MD {
return s.stream.Trailer()
}
func (s *instrumentedClientStream) Context() context.Context {
return s.stream.Context()
}
func (s *instrumentedClientStream) awaitCompletion(ctx context.Context) {
go func() {
select {
case <-s.finishedChan:
// Stream has finished for another reason, nothing more to do.
case <-ctx.Done():
s.finish(ctx.Err())
}
}()
}
func (s *instrumentedClientStream) finish(err error) {
if !s.finished.CompareAndSwap(false, true) {
return
}
if err == io.EOF {
s.metric.WithLabelValues(s.method, errorCode(nil)).Observe(time.Since(s.start).Seconds())
} else {
s.metric.WithLabelValues(s.method, errorCode(err)).Observe(time.Since(s.start).Seconds())
close(s.finishedChan)
s.metric.WithLabelValues(s.method, errorCode(err)).Observe(time.Since(s.start).Seconds())
}
func (s *instrumentedClientStream) SendMsg(m interface{}) error {
err := s.stream.SendMsg(m)
if err == nil || err == io.EOF {
// If SendMsg returns io.EOF, the true error is available from RecvMsg, so we shouldn't consider the stream failed at this point.
return err
}
s.finish(err)
return err
}
func (s *instrumentedClientStream) RecvMsg(m interface{}) error {
err := s.ClientStream.RecvMsg(m)
err := s.stream.RecvMsg(m)
if !s.serverStreams {
// Unary server: this is the only message we'll receive, so the stream has ended.
s.finish(err)
return err
}
if err == nil {
return nil
}
if err == io.EOF {
s.metric.WithLabelValues(s.method, errorCode(nil)).Observe(time.Since(s.start).Seconds())
s.finish(nil)
} else {
s.metric.WithLabelValues(s.method, errorCode(err)).Observe(time.Since(s.start).Seconds())
s.finish(err)
}
return err
}
func (s *instrumentedClientStream) Header() (metadata.MD, error) {
md, err := s.ClientStream.Header()
md, err := s.stream.Header()
if err != nil {
s.metric.WithLabelValues(s.method, errorCode(err)).Observe(time.Since(s.start).Seconds())
s.finish(err)
}
return md, err
}
func (s *instrumentedClientStream) CloseSend() error {
err := s.stream.CloseSend()
if err != nil {
s.finish(err)
}
return err
}
// errorCode converts an error into an error code string.
func errorCode(err error) string {
if err == nil {
@ -133,7 +182,7 @@ func errorCode(err error) string {
if errResp, ok := httpgrpc.HTTPResponseFromError(err); ok {
statusFamily := int(errResp.Code / 100)
return strconv.Itoa(statusFamily) + "xx"
} else if grpcUtils.IsCanceled(err) {
} else if grpcutil.IsCanceled(err) {
return "cancel"
} else {
return "error"

@ -21,6 +21,7 @@ import (
"github.com/opentracing/opentracing-go"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/prometheus/common/config"
"github.com/prometheus/exporter-toolkit/web"
"github.com/soheilhy/cmux"
"golang.org/x/net/netutil"
@ -56,10 +57,13 @@ type SignalHandler interface {
// TLSConfig contains TLS parameters for Config.
type TLSConfig struct {
TLSCertPath string `yaml:"cert_file"`
TLSKeyPath string `yaml:"key_file"`
ClientAuth string `yaml:"client_auth_type"`
ClientCAs string `yaml:"client_ca_file"`
TLSCert string `yaml:"cert"`
TLSKey config.Secret `yaml:"key"`
ClientCAsText string `yaml:"client_ca"`
TLSCertPath string `yaml:"cert_file"`
TLSKeyPath string `yaml:"key_file"`
ClientAuth string `yaml:"client_auth_type"`
ClientCAs string `yaml:"client_ca_file"`
}
// Config for a Server
@ -259,7 +263,7 @@ func newServer(cfg Config, metrics *Metrics) (*Server, error) {
if cfg.RouteHTTPToGRPC {
grpchttpmux = cmux.New(httpListener)
httpListener = grpchttpmux.Match(cmux.HTTP1Fast())
httpListener = grpchttpmux.Match(cmux.HTTP1Fast("PATCH"))
grpcOnHTTPListener = grpchttpmux.Match(cmux.HTTP2())
}
@ -289,30 +293,38 @@ func newServer(cfg Config, metrics *Metrics) (*Server, error) {
// Setup TLS
var httpTLSConfig *tls.Config
if len(cfg.HTTPTLSConfig.TLSCertPath) > 0 && len(cfg.HTTPTLSConfig.TLSKeyPath) > 0 {
if (len(cfg.HTTPTLSConfig.TLSCertPath) > 0 || len(cfg.HTTPTLSConfig.TLSCert) > 0) &&
(len(cfg.HTTPTLSConfig.TLSKeyPath) > 0 || len(cfg.HTTPTLSConfig.TLSKey) > 0) {
// Note: ConfigToTLSConfig from prometheus/exporter-toolkit is awaiting security review.
httpTLSConfig, err = web.ConfigToTLSConfig(&web.TLSConfig{
TLSCertPath: cfg.HTTPTLSConfig.TLSCertPath,
TLSKeyPath: cfg.HTTPTLSConfig.TLSKeyPath,
ClientAuth: cfg.HTTPTLSConfig.ClientAuth,
ClientCAs: cfg.HTTPTLSConfig.ClientCAs,
CipherSuites: cipherSuites,
MinVersion: minVersion,
TLSCert: cfg.HTTPTLSConfig.TLSCert,
TLSKey: config.Secret(cfg.HTTPTLSConfig.TLSKey),
ClientCAsText: cfg.HTTPTLSConfig.ClientCAsText,
TLSCertPath: cfg.HTTPTLSConfig.TLSCertPath,
TLSKeyPath: cfg.HTTPTLSConfig.TLSKeyPath,
ClientAuth: cfg.HTTPTLSConfig.ClientAuth,
ClientCAs: cfg.HTTPTLSConfig.ClientCAs,
CipherSuites: cipherSuites,
MinVersion: minVersion,
})
if err != nil {
return nil, fmt.Errorf("error generating http tls config: %v", err)
}
}
var grpcTLSConfig *tls.Config
if len(cfg.GRPCTLSConfig.TLSCertPath) > 0 && len(cfg.GRPCTLSConfig.TLSKeyPath) > 0 {
if (len(cfg.GRPCTLSConfig.TLSCertPath) > 0 || len(cfg.GRPCTLSConfig.TLSCert) > 0) &&
(len(cfg.GRPCTLSConfig.TLSKeyPath) > 0 || len(cfg.GRPCTLSConfig.TLSKey) > 0) {
// Note: ConfigToTLSConfig from prometheus/exporter-toolkit is awaiting security review.
grpcTLSConfig, err = web.ConfigToTLSConfig(&web.TLSConfig{
TLSCertPath: cfg.GRPCTLSConfig.TLSCertPath,
TLSKeyPath: cfg.GRPCTLSConfig.TLSKeyPath,
ClientAuth: cfg.GRPCTLSConfig.ClientAuth,
ClientCAs: cfg.GRPCTLSConfig.ClientCAs,
CipherSuites: cipherSuites,
MinVersion: minVersion,
TLSCert: cfg.GRPCTLSConfig.TLSCert,
TLSKey: config.Secret(cfg.GRPCTLSConfig.TLSKey),
ClientCAsText: cfg.GRPCTLSConfig.ClientCAsText,
TLSCertPath: cfg.GRPCTLSConfig.TLSCertPath,
TLSKeyPath: cfg.GRPCTLSConfig.TLSKeyPath,
ClientAuth: cfg.GRPCTLSConfig.ClientAuth,
ClientCAs: cfg.GRPCTLSConfig.ClientCAs,
CipherSuites: cipherSuites,
MinVersion: minVersion,
})
if err != nil {
return nil, fmt.Errorf("error generating grpc tls config: %v", err)

@ -1,3 +1,7 @@
// Provenance-includes-location: https://github.com/weaveworks/common/blob/main/test/diff.go
// Provenance-includes-license: Apache-2.0
// Provenance-includes-copyright: Weaveworks Ltd.
package test
import (

@ -0,0 +1,26 @@
package test
import (
"reflect"
"testing"
"time"
)
// Poll repeatedly calls a function until the function returns the correct response or until poll timeout.
func Poll(t testing.TB, d time.Duration, want interface{}, have func() interface{}) {
t.Helper()
deadline := time.Now().Add(d)
for {
if time.Now().After(deadline) {
break
}
if reflect.DeepEqual(want, have()) {
return
}
time.Sleep(d / 100)
}
h := have()
if !reflect.DeepEqual(want, h) {
t.Fatalf("expected %v, got %v", want, h)
}
}

@ -579,8 +579,7 @@ func NewRoundTripperFromConfig(cfg HTTPClientConfig, name string, optFuncs ...HT
// No need for a RoundTripper that reloads the CA file automatically.
return newRT(tlsConfig)
}
return NewTLSRoundTripper(tlsConfig, cfg.TLSConfig.CAFile, cfg.TLSConfig.CertFile, cfg.TLSConfig.KeyFile, newRT)
return NewTLSRoundTripper(tlsConfig, cfg.TLSConfig.roundTripperSettings(), newRT)
}
type authorizationCredentialsRoundTripper struct {
@ -750,7 +749,7 @@ func (rt *oauth2RoundTripper) RoundTrip(req *http.Request) (*http.Response, erro
if len(rt.config.TLSConfig.CAFile) == 0 {
t, _ = tlsTransport(tlsConfig)
} else {
t, err = NewTLSRoundTripper(tlsConfig, rt.config.TLSConfig.CAFile, rt.config.TLSConfig.CertFile, rt.config.TLSConfig.KeyFile, tlsTransport)
t, err = NewTLSRoundTripper(tlsConfig, rt.config.TLSConfig.roundTripperSettings(), tlsTransport)
if err != nil {
return nil, err
}
@ -817,6 +816,10 @@ func cloneRequest(r *http.Request) *http.Request {
// NewTLSConfig creates a new tls.Config from the given TLSConfig.
func NewTLSConfig(cfg *TLSConfig) (*tls.Config, error) {
if err := cfg.Validate(); err != nil {
return nil, err
}
tlsConfig := &tls.Config{
InsecureSkipVerify: cfg.InsecureSkipVerify,
MinVersion: uint16(cfg.MinVersion),
@ -831,7 +834,11 @@ func NewTLSConfig(cfg *TLSConfig) (*tls.Config, error) {
// If a CA cert is provided then let's read it in so we can validate the
// scrape target's certificate properly.
if len(cfg.CAFile) > 0 {
if len(cfg.CA) > 0 {
if !updateRootCA(tlsConfig, []byte(cfg.CA)) {
return nil, fmt.Errorf("unable to use inline CA cert")
}
} else if len(cfg.CAFile) > 0 {
b, err := readCAFile(cfg.CAFile)
if err != nil {
return nil, err
@ -844,12 +851,9 @@ func NewTLSConfig(cfg *TLSConfig) (*tls.Config, error) {
if len(cfg.ServerName) > 0 {
tlsConfig.ServerName = cfg.ServerName
}
// If a client cert & key is provided then configure TLS config accordingly.
if len(cfg.CertFile) > 0 && len(cfg.KeyFile) == 0 {
return nil, fmt.Errorf("client cert file %q specified without client key file", cfg.CertFile)
} else if len(cfg.KeyFile) > 0 && len(cfg.CertFile) == 0 {
return nil, fmt.Errorf("client key file %q specified without client cert file", cfg.KeyFile)
} else if len(cfg.CertFile) > 0 && len(cfg.KeyFile) > 0 {
if cfg.usingClientCert() && cfg.usingClientKey() {
// Verify that client cert and key are valid.
if _, err := cfg.getClientCertificate(nil); err != nil {
return nil, err
@ -862,6 +866,12 @@ func NewTLSConfig(cfg *TLSConfig) (*tls.Config, error) {
// TLSConfig configures the options for TLS connections.
type TLSConfig struct {
// Text of the CA cert to use for the targets.
CA string `yaml:"ca,omitempty" json:"ca,omitempty"`
// Text of the client cert file for the targets.
Cert string `yaml:"cert,omitempty" json:"cert,omitempty"`
// Text of the client key file for the targets.
Key Secret `yaml:"key,omitempty" json:"key,omitempty"`
// The CA cert to use for the targets.
CAFile string `yaml:"ca_file,omitempty" json:"ca_file,omitempty"`
// The client cert file for the targets.
@ -891,29 +901,77 @@ func (c *TLSConfig) SetDirectory(dir string) {
// UnmarshalYAML implements the yaml.Unmarshaler interface.
func (c *TLSConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
type plain TLSConfig
return unmarshal((*plain)(c))
if err := unmarshal((*plain)(c)); err != nil {
return err
}
return c.Validate()
}
// readCertAndKey reads the cert and key files from the disk.
func readCertAndKey(certFile, keyFile string) ([]byte, []byte, error) {
certData, err := os.ReadFile(certFile)
if err != nil {
return nil, nil, err
// Validate validates the TLSConfig to check that only one of the inlined or
// file-based fields for the TLS CA, client certificate, and client key are
// used.
func (c *TLSConfig) Validate() error {
if len(c.CA) > 0 && len(c.CAFile) > 0 {
return fmt.Errorf("at most one of ca and ca_file must be configured")
}
if len(c.Cert) > 0 && len(c.CertFile) > 0 {
return fmt.Errorf("at most one of cert and cert_file must be configured")
}
if len(c.Key) > 0 && len(c.KeyFile) > 0 {
return fmt.Errorf("at most one of key and key_file must be configured")
}
keyData, err := os.ReadFile(keyFile)
if err != nil {
return nil, nil, err
if c.usingClientCert() && !c.usingClientKey() {
return fmt.Errorf("exactly one of key or key_file must be configured when a client certificate is configured")
} else if c.usingClientKey() && !c.usingClientCert() {
return fmt.Errorf("exactly one of cert or cert_file must be configured when a client key is configured")
}
return certData, keyData, nil
return nil
}
func (c *TLSConfig) usingClientCert() bool {
return len(c.Cert) > 0 || len(c.CertFile) > 0
}
func (c *TLSConfig) usingClientKey() bool {
return len(c.Key) > 0 || len(c.KeyFile) > 0
}
func (c *TLSConfig) roundTripperSettings() TLSRoundTripperSettings {
return TLSRoundTripperSettings{
CA: c.CA,
CAFile: c.CAFile,
Cert: c.Cert,
CertFile: c.CertFile,
Key: string(c.Key),
KeyFile: c.KeyFile,
}
}
// getClientCertificate reads the pair of client cert and key from disk and returns a tls.Certificate.
func (c *TLSConfig) getClientCertificate(_ *tls.CertificateRequestInfo) (*tls.Certificate, error) {
certData, keyData, err := readCertAndKey(c.CertFile, c.KeyFile)
if err != nil {
return nil, fmt.Errorf("unable to read specified client cert (%s) & key (%s): %s", c.CertFile, c.KeyFile, err)
var (
certData, keyData []byte
err error
)
if c.CertFile != "" {
certData, err = os.ReadFile(c.CertFile)
if err != nil {
return nil, fmt.Errorf("unable to read specified client cert (%s): %s", c.CertFile, err)
}
} else {
certData = []byte(c.Cert)
}
if c.KeyFile != "" {
keyData, err = os.ReadFile(c.KeyFile)
if err != nil {
return nil, fmt.Errorf("unable to read specified client key (%s): %s", c.KeyFile, err)
}
} else {
keyData = []byte(c.Key)
}
cert, err := tls.X509KeyPair(certData, keyData)
@ -946,30 +1004,32 @@ func updateRootCA(cfg *tls.Config, b []byte) bool {
// tlsRoundTripper is a RoundTripper that updates automatically its TLS
// configuration whenever the content of the CA file changes.
type tlsRoundTripper struct {
caFile string
certFile string
keyFile string
settings TLSRoundTripperSettings
// newRT returns a new RoundTripper.
newRT func(*tls.Config) (http.RoundTripper, error)
mtx sync.RWMutex
rt http.RoundTripper
hashCAFile []byte
hashCertFile []byte
hashKeyFile []byte
hashCAData []byte
hashCertData []byte
hashKeyData []byte
tlsConfig *tls.Config
}
type TLSRoundTripperSettings struct {
CA, CAFile string
Cert, CertFile string
Key, KeyFile string
}
func NewTLSRoundTripper(
cfg *tls.Config,
caFile, certFile, keyFile string,
settings TLSRoundTripperSettings,
newRT func(*tls.Config) (http.RoundTripper, error),
) (http.RoundTripper, error) {
t := &tlsRoundTripper{
caFile: caFile,
certFile: certFile,
keyFile: keyFile,
settings: settings,
newRT: newRT,
tlsConfig: cfg,
}
@ -979,7 +1039,7 @@ func NewTLSRoundTripper(
return nil, err
}
t.rt = rt
_, t.hashCAFile, t.hashCertFile, t.hashKeyFile, err = t.getTLSFilesWithHash()
_, t.hashCAData, t.hashCertData, t.hashKeyData, err = t.getTLSDataWithHash()
if err != nil {
return nil, err
}
@ -987,36 +1047,66 @@ func NewTLSRoundTripper(
return t, nil
}
func (t *tlsRoundTripper) getTLSFilesWithHash() ([]byte, []byte, []byte, []byte, error) {
b1, err := readCAFile(t.caFile)
if err != nil {
return nil, nil, nil, nil, err
func (t *tlsRoundTripper) getTLSDataWithHash() ([]byte, []byte, []byte, []byte, error) {
var (
caBytes, certBytes, keyBytes []byte
err error
)
if t.settings.CAFile != "" {
caBytes, err = os.ReadFile(t.settings.CAFile)
if err != nil {
return nil, nil, nil, nil, err
}
} else if t.settings.CA != "" {
caBytes = []byte(t.settings.CA)
}
if t.settings.CertFile != "" {
certBytes, err = os.ReadFile(t.settings.CertFile)
if err != nil {
return nil, nil, nil, nil, err
}
} else if t.settings.Cert != "" {
certBytes = []byte(t.settings.Cert)
}
h1 := sha256.Sum256(b1)
var h2, h3 [32]byte
if t.certFile != "" {
b2, b3, err := readCertAndKey(t.certFile, t.keyFile)
if t.settings.KeyFile != "" {
keyBytes, err = os.ReadFile(t.settings.KeyFile)
if err != nil {
return nil, nil, nil, nil, err
}
h2, h3 = sha256.Sum256(b2), sha256.Sum256(b3)
} else if t.settings.Key != "" {
keyBytes = []byte(t.settings.Key)
}
var caHash, certHash, keyHash [32]byte
if len(caBytes) > 0 {
caHash = sha256.Sum256(caBytes)
}
if len(certBytes) > 0 {
certHash = sha256.Sum256(certBytes)
}
if len(keyBytes) > 0 {
keyHash = sha256.Sum256(keyBytes)
}
return b1, h1[:], h2[:], h3[:], nil
return caBytes, caHash[:], certHash[:], keyHash[:], nil
}
// RoundTrip implements the http.RoundTrip interface.
func (t *tlsRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
caData, caHash, certHash, keyHash, err := t.getTLSFilesWithHash()
caData, caHash, certHash, keyHash, err := t.getTLSDataWithHash()
if err != nil {
return nil, err
}
t.mtx.RLock()
equal := bytes.Equal(caHash[:], t.hashCAFile) &&
bytes.Equal(certHash[:], t.hashCertFile) &&
bytes.Equal(keyHash[:], t.hashKeyFile)
equal := bytes.Equal(caHash[:], t.hashCAData) &&
bytes.Equal(certHash[:], t.hashCertData) &&
bytes.Equal(keyHash[:], t.hashKeyData)
rt := t.rt
t.mtx.RUnlock()
if equal {
@ -1029,7 +1119,7 @@ func (t *tlsRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
// using GetClientCertificate.
tlsConfig := t.tlsConfig.Clone()
if !updateRootCA(tlsConfig, caData) {
return nil, fmt.Errorf("unable to use specified CA cert %s", t.caFile)
return nil, fmt.Errorf("unable to use specified CA cert %s", t.settings.CAFile)
}
rt, err = t.newRT(tlsConfig)
if err != nil {
@ -1039,9 +1129,9 @@ func (t *tlsRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
t.mtx.Lock()
t.rt = rt
t.hashCAFile = caHash[:]
t.hashCertFile = certHash[:]
t.hashKeyFile = keyHash[:]
t.hashCAData = caHash[:]
t.hashCertData = certHash[:]
t.hashKeyData = keyHash[:]
t.mtx.Unlock()
return rt.RoundTrip(req)

@ -5,9 +5,14 @@ body {
header {
background-color: {{.HeaderColor}};
color: #fff;
font-size: 2rem;
font-size: 1rem;
padding: 1rem;
}
main {
padding: 1rem;
}
label {
display: inline-block;
width: {{.Form.Width}}em;
}
{{.ExtraCSS}}

@ -31,10 +31,29 @@ type LandingConfig struct {
CSS string // CSS style tag for the landing page.
Name string // The name of the exporter, generally suffixed by _exporter.
Description string // A short description about the exporter.
Form LandingForm // A POST form.
Links []LandingLinks // Links displayed on the landing page.
ExtraHTML string // Additional HTML to be embedded.
ExtraCSS string // Additional CSS to be embedded.
Version string // The version displayed.
}
// LandingForm provides a configuration struct for creating a POST form on the landing page.
type LandingForm struct {
Action string
Inputs []LandingFormInput
Width float64
}
// LandingFormInput represents a single form input field.
type LandingFormInput struct {
Label string
Type string
Name string
Placeholder string
Value string
}
type LandingLinks struct {
Address string // The URL the link points to.
Text string // The text of the link.
@ -54,6 +73,15 @@ var (
func NewLandingPage(c LandingConfig) (*LandingPageHandler, error) {
var buf bytes.Buffer
length := 0
for _, input := range c.Form.Inputs {
inputLength := len(input.Label)
if inputLength > length {
length = inputLength
}
}
c.Form.Width = (float64(length) + 1) / 2
if c.CSS == "" {
if c.HeaderColor == "" {
// Default to Prometheus orange.
@ -78,5 +106,6 @@ func NewLandingPage(c LandingConfig) (*LandingPageHandler, error) {
}
func (h *LandingPageHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
w.Header().Add("Content-Type", "text/html; charset=UTF-8")
w.Write(h.landingPage)
}

@ -19,6 +19,17 @@
{{ end }}
</ul>
</div>
{{ if .Form.Action }}
<div>
<form action="{{ .Form.Action}}">
{{ range .Form.Inputs }}
<label>{{ .Label }}:</label>&nbsp;<input type="{{ .Type }}" name="{{ .Name }}" placeholder="{{ .Placeholder }}" value="{{ .Value }}"><br>
{{ end }}
<input type="submit" value="Submit">
</form>
</div>
{{ end }}
{{ .ExtraHTML }}
</main>
</body>
</html>

@ -33,6 +33,7 @@ import (
var (
errNoTLSConfig = errors.New("TLS config is not present")
ErrNoListeners = errors.New("no web listen address or systemd socket flag specified")
)
type Config struct {
@ -42,15 +43,19 @@ type Config struct {
}
type TLSConfig struct {
TLSCertPath string `yaml:"cert_file"`
TLSKeyPath string `yaml:"key_file"`
ClientAuth string `yaml:"client_auth_type"`
ClientCAs string `yaml:"client_ca_file"`
CipherSuites []Cipher `yaml:"cipher_suites"`
CurvePreferences []Curve `yaml:"curve_preferences"`
MinVersion TLSVersion `yaml:"min_version"`
MaxVersion TLSVersion `yaml:"max_version"`
PreferServerCipherSuites bool `yaml:"prefer_server_cipher_suites"`
TLSCert string `yaml:"cert"`
TLSKey config_util.Secret `yaml:"key"`
ClientCAsText string `yaml:"client_ca"`
TLSCertPath string `yaml:"cert_file"`
TLSKeyPath string `yaml:"key_file"`
ClientAuth string `yaml:"client_auth_type"`
ClientCAs string `yaml:"client_ca_file"`
CipherSuites []Cipher `yaml:"cipher_suites"`
CurvePreferences []Curve `yaml:"curve_preferences"`
MinVersion TLSVersion `yaml:"min_version"`
MaxVersion TLSVersion `yaml:"max_version"`
PreferServerCipherSuites bool `yaml:"prefer_server_cipher_suites"`
ClientAllowedSans []string `yaml:"client_allowed_sans"`
}
type FlagConfig struct {
@ -66,6 +71,36 @@ func (t *TLSConfig) SetDirectory(dir string) {
t.ClientCAs = config_util.JoinDir(dir, t.ClientCAs)
}
// VerifyPeerCertificate will check the SAN entries of the client cert if there is configuration for it
func (t *TLSConfig) VerifyPeerCertificate(rawCerts [][]byte, _ [][]*x509.Certificate) error {
// sender cert comes first, see https://www.rfc-editor.org/rfc/rfc5246#section-7.4.2
cert, err := x509.ParseCertificate(rawCerts[0])
if err != nil {
return fmt.Errorf("error parsing client certificate: %s", err)
}
// Build up a slice of strings with all Subject Alternate Name values
sanValues := append(cert.DNSNames, cert.EmailAddresses...)
for _, ip := range cert.IPAddresses {
sanValues = append(sanValues, ip.String())
}
for _, uri := range cert.URIs {
sanValues = append(sanValues, uri.String())
}
for _, sanValue := range sanValues {
for _, allowedSan := range t.ClientAllowedSans {
if sanValue == allowedSan {
return nil
}
}
}
return fmt.Errorf("could not find allowed SANs in client cert, found: %v", t.ClientAllowedSans)
}
type HTTPConfig struct {
HTTP2 bool `yaml:"http2"`
Header map[string]string `yaml:"headers,omitempty"`
@ -100,22 +135,54 @@ func getTLSConfig(configPath string) (*tls.Config, error) {
return ConfigToTLSConfig(&c.TLSConfig)
}
// ConfigToTLSConfig generates the golang tls.Config from the TLSConfig struct.
func ConfigToTLSConfig(c *TLSConfig) (*tls.Config, error) {
if c.TLSCertPath == "" && c.TLSKeyPath == "" && c.ClientAuth == "" && c.ClientCAs == "" {
return nil, errNoTLSConfig
func validateTLSPaths(c *TLSConfig) error {
if c.TLSCertPath == "" && c.TLSCert == "" &&
c.TLSKeyPath == "" && c.TLSKey == "" &&
c.ClientCAs == "" && c.ClientCAsText == "" &&
c.ClientAuth == "" {
return errNoTLSConfig
}
if c.TLSCertPath == "" {
return nil, errors.New("missing cert_file")
if c.TLSCertPath == "" && c.TLSCert == "" {
return errors.New("missing one of cert or cert_file")
}
if c.TLSKeyPath == "" {
return nil, errors.New("missing key_file")
if c.TLSKeyPath == "" && c.TLSKey == "" {
return errors.New("missing one of key or key_file")
}
return nil
}
// ConfigToTLSConfig generates the golang tls.Config from the TLSConfig struct.
func ConfigToTLSConfig(c *TLSConfig) (*tls.Config, error) {
if err := validateTLSPaths(c); err != nil {
return nil, err
}
loadCert := func() (*tls.Certificate, error) {
cert, err := tls.LoadX509KeyPair(c.TLSCertPath, c.TLSKeyPath)
var certData, keyData []byte
var err error
if c.TLSCertPath != "" {
certData, err = os.ReadFile(c.TLSCertPath)
if err != nil {
return nil, fmt.Errorf("failed to read cert_file (%s): %s", c.TLSCertPath, err)
}
} else {
certData = []byte(c.TLSCert)
}
if c.TLSKeyPath != "" {
keyData, err = os.ReadFile(c.TLSKeyPath)
if err != nil {
return nil, fmt.Errorf("failed to read key_file (%s): %s", c.TLSKeyPath, err)
}
} else {
keyData = []byte(c.TLSKey)
}
cert, err := tls.X509KeyPair(certData, keyData)
if err != nil {
return nil, fmt.Errorf("failed to load X509KeyPair: %w", err)
}
@ -161,6 +228,15 @@ func ConfigToTLSConfig(c *TLSConfig) (*tls.Config, error) {
}
clientCAPool.AppendCertsFromPEM(clientCAFile)
cfg.ClientCAs = clientCAPool
} else if c.ClientCAsText != "" {
clientCAPool := x509.NewCertPool()
clientCAPool.AppendCertsFromPEM([]byte(c.ClientCAsText))
cfg.ClientCAs = clientCAPool
}
if c.ClientAllowedSans != nil {
// verify that the client cert contains an allowed SAN
cfg.VerifyPeerCertificate = c.VerifyPeerCertificate
}
switch c.ClientAuth {
@ -178,7 +254,7 @@ func ConfigToTLSConfig(c *TLSConfig) (*tls.Config, error) {
return nil, errors.New("Invalid ClientAuth: " + c.ClientAuth)
}
if c.ClientCAs != "" && cfg.ClientAuth == tls.NoClientCert {
if (c.ClientCAs != "" || c.ClientCAsText != "") && cfg.ClientAuth == tls.NoClientCert {
return nil, errors.New("Client CA's have been configured without a Client Auth Policy")
}
@ -203,7 +279,11 @@ func ServeMultiple(listeners []net.Listener, server *http.Server, flags *FlagCon
// WebSystemdSocket in the FlagConfig is true. The FlagConfig is also passed on
// to ServeMultiple.
func ListenAndServe(server *http.Server, flags *FlagConfig, logger log.Logger) error {
if *flags.WebSystemdSocket {
if flags.WebSystemdSocket == nil && (flags.WebListenAddresses == nil || len(*flags.WebListenAddresses) == 0) {
return ErrNoListeners
}
if flags.WebSystemdSocket != nil && *flags.WebSystemdSocket {
level.Info(logger).Log("msg", "Listening on systemd activated listeners instead of port listeners.")
listeners, err := activation.Listeners()
if err != nil {
@ -214,6 +294,7 @@ func ListenAndServe(server *http.Server, flags *FlagConfig, logger log.Logger) e
}
return ServeMultiple(listeners, server, flags, logger)
}
listeners := make([]net.Listener, 0, len(*flags.WebListenAddresses))
for _, address := range *flags.WebListenAddresses {
listener, err := net.Listen("tcp", address)

@ -1,175 +0,0 @@
./tools/integration/assert.sh is a copy of
https://github.com/lehmannro/assert.sh/blob/master/assert.sh
Since it was imported from its original source, it has only received
cosmetic modifications. As it is licensed under the LGPL-3, here's the
license text in its entirety:
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

@ -1,191 +0,0 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
Copyright 2014-2016 Weaveworks Ltd.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

@ -1,3 +0,0 @@
Weave
Copyright 2016 Weaveworks Ltd.
This product includes software developed at Weaveworks Ltd.

@ -20,7 +20,7 @@ type token struct{}
// A zero Group is valid, has no limit on the number of active goroutines,
// and does not cancel on error.
type Group struct {
cancel func()
cancel func(error)
wg sync.WaitGroup
@ -43,7 +43,7 @@ func (g *Group) done() {
// returns a non-nil error or the first time Wait returns, whichever occurs
// first.
func WithContext(ctx context.Context) (*Group, context.Context) {
ctx, cancel := context.WithCancel(ctx)
ctx, cancel := withCancelCause(ctx)
return &Group{cancel: cancel}, ctx
}
@ -52,7 +52,7 @@ func WithContext(ctx context.Context) (*Group, context.Context) {
func (g *Group) Wait() error {
g.wg.Wait()
if g.cancel != nil {
g.cancel()
g.cancel(g.err)
}
return g.err
}
@ -76,7 +76,7 @@ func (g *Group) Go(f func() error) {
g.errOnce.Do(func() {
g.err = err
if g.cancel != nil {
g.cancel()
g.cancel(g.err)
}
})
}
@ -105,7 +105,7 @@ func (g *Group) TryGo(f func() error) bool {
g.errOnce.Do(func() {
g.err = err
if g.cancel != nil {
g.cancel()
g.cancel(g.err)
}
})
}

@ -0,0 +1,14 @@
// Copyright 2023 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build go1.20
// +build go1.20
package errgroup
import "context"
func withCancelCause(parent context.Context) (context.Context, func(error)) {
return context.WithCancelCause(parent)
}

@ -0,0 +1,15 @@
// Copyright 2023 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build !go1.20
// +build !go1.20
package errgroup
import "context"
func withCancelCause(parent context.Context) (context.Context, func(error)) {
ctx, cancel := context.WithCancel(parent)
return ctx, func(error) { cancel() }
}

20
vendor/modules.txt vendored

@ -251,7 +251,7 @@ github.com/armon/go-metrics/prometheus
# github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2
## explicit; go 1.13
github.com/asaskevich/govalidator
# github.com/aws/aws-sdk-go v1.44.315
# github.com/aws/aws-sdk-go v1.44.321
## explicit; go 1.11
github.com/aws/aws-sdk-go/aws
github.com/aws/aws-sdk-go/aws/arn
@ -826,8 +826,9 @@ github.com/gorilla/websocket
# github.com/grafana/cloudflare-go v0.0.0-20230110200409-c627cf6792f2
## explicit; go 1.17
github.com/grafana/cloudflare-go
# github.com/grafana/dskit v0.0.0-20230804003603-740f56bd2934
## explicit; go 1.18
# github.com/grafana/dskit v0.0.0-20230811062909-a2c425ae7975
## explicit; go 1.19
github.com/grafana/dskit/aws
github.com/grafana/dskit/backoff
github.com/grafana/dskit/concurrency
github.com/grafana/dskit/crypto/tls
@ -867,6 +868,7 @@ github.com/grafana/dskit/services
github.com/grafana/dskit/signals
github.com/grafana/dskit/spanlogger
github.com/grafana/dskit/tenant
github.com/grafana/dskit/test
github.com/grafana/dskit/tracing
github.com/grafana/dskit/user
# github.com/grafana/go-gelf/v2 v2.0.1
@ -1196,7 +1198,7 @@ github.com/prometheus/client_golang/prometheus/testutil/promlint
# github.com/prometheus/client_model v0.4.0
## explicit; go 1.18
github.com/prometheus/client_model/go
# github.com/prometheus/common v0.43.0
# github.com/prometheus/common v0.44.0
## explicit; go 1.18
github.com/prometheus/common/config
github.com/prometheus/common/expfmt
@ -1207,7 +1209,7 @@ github.com/prometheus/common/version
# github.com/prometheus/common/sigv4 v0.1.0
## explicit; go 1.15
github.com/prometheus/common/sigv4
# github.com/prometheus/exporter-toolkit v0.9.1
# github.com/prometheus/exporter-toolkit v0.10.1-0.20230714054209-2f4150c63f97
## explicit; go 1.18
github.com/prometheus/exporter-toolkit/web
# github.com/prometheus/procfs v0.10.1
@ -1386,10 +1388,6 @@ github.com/uber/jaeger-lib/metrics/prometheus
# github.com/ugorji/go/codec v1.1.7
## explicit
github.com/ugorji/go/codec
# github.com/weaveworks/common v0.0.0-20230511094633-334485600903
## explicit; go 1.14
github.com/weaveworks/common/aws
github.com/weaveworks/common/test
# github.com/weaveworks/promrus v1.2.0
## explicit
github.com/weaveworks/promrus
@ -1571,8 +1569,8 @@ golang.org/x/oauth2/google/internal/externalaccount
golang.org/x/oauth2/internal
golang.org/x/oauth2/jws
golang.org/x/oauth2/jwt
# golang.org/x/sync v0.2.0
## explicit
# golang.org/x/sync v0.3.0
## explicit; go 1.17
golang.org/x/sync/errgroup
golang.org/x/sync/semaphore
# golang.org/x/sys v0.10.0

Loading…
Cancel
Save