Gentoo Archives: gentoo-commits

From: William Hubbs <williamh@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: app-admin/vault/, app-admin/vault/files/
Date: Thu, 16 Sep 2021 22:08:03
Message-Id: 1631830068.7fa16bc47f1c8d140656cfa0492e989da5c1bf67.williamh@gentoo
1 commit: 7fa16bc47f1c8d140656cfa0492e989da5c1bf67
2 Author: Austin English <austin.m.english <AT> sony <DOT> com>
3 AuthorDate: Thu Sep 16 16:45:05 2021 +0000
4 Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
5 CommitDate: Thu Sep 16 22:07:48 2021 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=7fa16bc4
7
8 app-admin/vault: fix build with newer golang
9
10 Closes: https://bugs.gentoo.org/808791
11 Closes: https://bugs.gentoo.org/810317
12
13 Signed-off-by: Austin English <austin.m.english <AT> sony.com>
14 Signed-off-by: William Hubbs <williamh <AT> gentoo.org>
15
16 app-admin/vault/Manifest | 4 +-
17 app-admin/vault/files/vault-1.8.2-go-limiter.patch | 264 +++++++++++++++++++++
18 app-admin/vault/vault-1.8.2.ebuild | 6 +-
19 3 files changed, 270 insertions(+), 4 deletions(-)
20
21 diff --git a/app-admin/vault/Manifest b/app-admin/vault/Manifest
22 index 26de2c69e80..42ba4317b9e 100644
23 --- a/app-admin/vault/Manifest
24 +++ b/app-admin/vault/Manifest
25 @@ -1120,8 +1120,8 @@ DIST github.com%2Fsean-%2Fconswriter%2F@v%2Fv0.0.0-20180208195008-f5ae3917a627.m
26 DIST github.com%2Fsean-%2Fpager%2F@v%2Fv0.0.0-20180208200047-666be9bf53b5.mod 30 BLAKE2B 77431281d4cec52a254453afe8c7438154b0ecae0116ba085401536adc1f71f6a7eea8b0e2181893b004d805e3ff8b3a7f212ac82e41877cd08c2cf0fc47af05 SHA512 5101454134688f96467dbbdf475b1d9bd9e446c29eb2cd04b85430ea0130c09dcbd8141d5ca0d63e63b74349c3dbf59d978ef2115a03c920ff2abfad10fe9a62
27 DIST github.com%2Fsean-%2Fseed%2F@v%2Fv0.0.0-20170313163322-e2103e2c3529.mod 29 BLAKE2B 8f509981164937fb0aab63b0344ddbf25c183b926a6e87400e745f6aee9dcc478f0ed455c62a9753722954acb3506be5f7810915a15d03647668e7bb707c09c0 SHA512 c7dc34c7a73c5899ca207c0cac88dd38ddebaffa04b5dd511a86dd10160e60be2806dfc6e079a5871b0cb6142f53d7d7dc87ddbe3fb19240bf894430feac5875
28 DIST github.com%2Fsean-%2Fseed%2F@v%2Fv0.0.0-20170313163322-e2103e2c3529.zip 4415 BLAKE2B f50a9fd1f74506625ae9460c6071bbbd1dd3ad3d83264fb7def028c757e8ad8f865fc7255db6e9b5cdb7a1744ac1f741bc6184f064eee7108f6fc0facc81f639 SHA512 acd19ece301ac146ae50dd784e3dc1c2cbc0c00a562fc5d2759b7b8a4acf0b5bf83d5bcd54122130877a1568a13709c28ab7e1cc7ba269ec91aa1b1a86c2065a
29 -DIST github.com%2Fsethvargo%2Fgo-limiter%2F@v%2Fv0.3.0.mod 48 BLAKE2B 33ddfe8d645092d307c8b8acd8b1c0c8c0c91224a6b0eb3bac20d707be49acc3d437cf00d341d4d37857a9ac4b5303d1df717d2a46ce717941ab7eedbfd133bd SHA512 4266c966fbdba482455fdd13f37891847cff194d1a6d169be35167b729c6e36e9517d72c5a5fda048d8465ada31927b0f3d00fe455e5339c554829e7fb914d2a
30 -DIST github.com%2Fsethvargo%2Fgo-limiter%2F@v%2Fv0.3.0.zip 32198 BLAKE2B d779ed09d9e00d6ff18be20b48068a1877d623070d2f74bebb6816d3a139b311276caf8f3f3099a6b6940e8d5ddaaae07719fb86f117f9ec987483b1573561d5 SHA512 35f0ae21b2af7e125e4c18a36a0c6695b024f9f53facf6f025c71237cd12658cd507d05b6d8e8249c53477b56ed7c8e0a960232715e7243da2a3f00d6dcdcd68
31 +DIST github.com%2Fsethvargo%2Fgo-limiter%2F@v%2Fv0.7.1.mod 48 BLAKE2B 33ddfe8d645092d307c8b8acd8b1c0c8c0c91224a6b0eb3bac20d707be49acc3d437cf00d341d4d37857a9ac4b5303d1df717d2a46ce717941ab7eedbfd133bd SHA512 4266c966fbdba482455fdd13f37891847cff194d1a6d169be35167b729c6e36e9517d72c5a5fda048d8465ada31927b0f3d00fe455e5339c554829e7fb914d2a
32 +DIST github.com%2Fsethvargo%2Fgo-limiter%2F@v%2Fv0.7.1.zip 24454 BLAKE2B 4958546c0be405c760d03db84554b582ae770c08893c1dd77445f655d76714a93a5c1f2a9d5cc9590564002df9c6e81eafc2d44082c6da50a0f2ef18152e1d17 SHA512 e303b4042ed3f18743bc0d11700c40e5661a32472802dd1a5f9cd4131d520c774dd98cd62c056b6bf45739600cea5cb6052eb02a113fb091316cf1c11b5c819b
33 DIST github.com%2Fshirou%2Fgopsutil%2F@v%2Fv3.21.5+incompatible.mod 34 BLAKE2B 790ec7277e4654961540dd09fcb7962328547009b0181183b7cb64972b872d30986d1e53ded5961588d89508c913b2b56dd7af3625d0e8d7be2253b6bcf59576 SHA512 a5f5d88a767a855b6ff24d7e2e0c4aeb81fb1365a7e81ed989b4c605a7a6c61dc52d7ce97fc672c21020ef56f597dce679184e5e8d3d199678487e6bebaa8127
34 DIST github.com%2Fshirou%2Fgopsutil%2F@v%2Fv3.21.5+incompatible.zip 257791 BLAKE2B d0c44078120582d20e3c3eb60d0ecfc2c8547323ea68eddaffee5614243b4410518eabaf0c17b24351cd269d85bfc5f32151bcb56680793682a17b61e8881204 SHA512 c2d405ad66b1e3d6860ef21dacb6b7f0a5daef57267c32773cb26ea9983ba75df39e6b3ab5bc97c4c0eb133e17eb587a565da30d89139982fd90102765d27ca9
35 DIST github.com%2Fshopspring%2Fdecimal%2F@v%2Fv0.0.0-20180709203117-cd690d0c9e24.mod 37 BLAKE2B 9945435440e0d3be57cdb12cab697382fe91c56329289bbde332bbd1fd15928a5101d7fcadd89064ecbd103130514a1cad383db097d02d596138fad0348c15d0 SHA512 7f46d39bc8f24a5c5c1ff513c0f0018d5341a008526a49bf0b3694008c272b3080b0386a44ba6c27f2894bef19dfbec5095c9189ed222ed5a55797788668315e
36
37 diff --git a/app-admin/vault/files/vault-1.8.2-go-limiter.patch b/app-admin/vault/files/vault-1.8.2-go-limiter.patch
38 new file mode 100644
39 index 00000000000..3aef43e5c17
40 --- /dev/null
41 +++ b/app-admin/vault/files/vault-1.8.2-go-limiter.patch
42 @@ -0,0 +1,264 @@
43 +This is a combination of upstream commits:
44 +b368a675955707db4e940da29a1043871a3781b6
45 +21ea03e0f874991086d2f1bcdc285216878bd566
46 +
47 +Fixes https://bugs.gentoo.org/808791
48 +Fixes https://bugs.gentoo.org/810317
49 +
50 +diff --git a/go.mod b/go.mod
51 +index 548c0590f..22a8833e2 100644
52 +--- a/go.mod
53 ++++ b/go.mod
54 +@@ -150,7 +150,7 @@ require (
55 + github.com/ryanuber/go-glob v1.0.0
56 + github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da
57 + github.com/sasha-s/go-deadlock v0.2.0
58 +- github.com/sethvargo/go-limiter v0.3.0
59 ++ github.com/sethvargo/go-limiter v0.7.1
60 + github.com/shirou/gopsutil v3.21.5+incompatible
61 + github.com/stretchr/testify v1.7.0
62 + github.com/tidwall/pretty v1.0.1 // indirect
63 +diff --git a/go.sum b/go.sum
64 +index c5b3b410d..98a5dd0a8 100644
65 +--- a/go.sum
66 ++++ b/go.sum
67 +@@ -1120,8 +1120,8 @@ github.com/sean-/conswriter v0.0.0-20180208195008-f5ae3917a627/go.mod h1:7zjs06q
68 + github.com/sean-/pager v0.0.0-20180208200047-666be9bf53b5/go.mod h1:BeybITEsBEg6qbIiqJ6/Bqeq25bCLbL7YFmpaFfJDuM=
69 + github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 h1:nn5Wsu0esKSJiIVhscUtVbo7ada43DJhG55ua/hjS5I=
70 + github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
71 +-github.com/sethvargo/go-limiter v0.3.0 h1:yRMc+Qs2yqw6YJp6UxrO2iUs6DOSq4zcnljbB7/rMns=
72 +-github.com/sethvargo/go-limiter v0.3.0/go.mod h1:C0kbSFbiriE5k2FFOe18M1YZbAR2Fiwf72uGu0CXCcU=
73 ++github.com/sethvargo/go-limiter v0.7.1 h1:wWNhTj0pxjyJ7wuJHpRJpYwJn+bUnjYfw2a85eu5w9U=
74 ++github.com/sethvargo/go-limiter v0.7.1/go.mod h1:C0kbSFbiriE5k2FFOe18M1YZbAR2Fiwf72uGu0CXCcU=
75 + github.com/shirou/gopsutil v3.21.5+incompatible h1:OloQyEerMi7JUrXiNzy8wQ5XN+baemxSl12QgIzt0jc=
76 + github.com/shirou/gopsutil v3.21.5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
77 + github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24 h1:pntxY8Ary0t43dCZ5dqY4YTJCObLY1kIXl0uzMv+7DE=
78 +diff --git a/http/util.go b/http/util.go
79 +index 0550a93c7..cbb364843 100644
80 +--- a/http/util.go
81 ++++ b/http/util.go
82 +@@ -48,7 +48,7 @@ func rateLimitQuotaWrapping(handler http.Handler, core *vault.Core) http.Handler
83 + return
84 + }
85 +
86 +- quotaResp, err := core.ApplyRateLimitQuota(&quotas.Request{
87 ++ quotaResp, err := core.ApplyRateLimitQuota(r.Context(), &quotas.Request{
88 + Type: quotas.TypeRateLimit,
89 + Path: path,
90 + MountPath: strings.TrimPrefix(core.MatchingMount(r.Context(), path), ns.Path),
91 +diff --git a/vault/core.go b/vault/core.go
92 +index 3b6e461fd..27741e8c6 100644
93 +--- a/vault/core.go
94 ++++ b/vault/core.go
95 +@@ -2744,7 +2744,7 @@ func (c *Core) setupQuotas(ctx context.Context, isPerfStandby bool) error {
96 +
97 + // ApplyRateLimitQuota checks the request against all the applicable quota rules.
98 + // If the given request's path is exempt, no rate limiting will be applied.
99 +-func (c *Core) ApplyRateLimitQuota(req *quotas.Request) (quotas.Response, error) {
100 ++func (c *Core) ApplyRateLimitQuota(ctx context.Context, req *quotas.Request) (quotas.Response, error) {
101 + req.Type = quotas.TypeRateLimit
102 +
103 + resp := quotas.Response{
104 +@@ -2758,7 +2758,7 @@ func (c *Core) ApplyRateLimitQuota(req *quotas.Request) (quotas.Response, error)
105 + return resp, nil
106 + }
107 +
108 +- return c.quotaManager.ApplyQuota(req)
109 ++ return c.quotaManager.ApplyQuota(ctx, req)
110 + }
111 +
112 + return resp, nil
113 +diff --git a/vault/quotas/quotas.go b/vault/quotas/quotas.go
114 +index 68cc72f9f..80ee59521 100644
115 +--- a/vault/quotas/quotas.go
116 ++++ b/vault/quotas/quotas.go
117 +@@ -168,7 +168,7 @@ type Manager struct {
118 + // Quota represents the common properties of every quota type
119 + type Quota interface {
120 + // allow checks the if the request is allowed by the quota type implementation.
121 +- allow(*Request) (Response, error)
122 ++ allow(context.Context, *Request) (Response, error)
123 +
124 + // quotaID is the identifier of the quota rule
125 + quotaID() string
126 +@@ -181,7 +181,7 @@ type Quota interface {
127 +
128 + // close defines any cleanup behavior that needs to be executed when a quota
129 + // rule is deleted.
130 +- close() error
131 ++ close(context.Context) error
132 +
133 + // handleRemount takes in the new mount path in the quota
134 + handleRemount(string)
135 +@@ -287,7 +287,7 @@ func (m *Manager) setQuotaLocked(ctx context.Context, qType string, quota Quota,
136 + // If there already exists an entry in the db, remove that first.
137 + if raw != nil {
138 + quota := raw.(Quota)
139 +- if err := quota.close(); err != nil {
140 ++ if err := quota.close(ctx); err != nil {
141 + return err
142 + }
143 + err = txn.Delete(qType, raw)
144 +@@ -518,7 +518,7 @@ func (m *Manager) DeleteQuota(ctx context.Context, qType string, name string) er
145 + }
146 +
147 + quota := raw.(Quota)
148 +- if err := quota.close(); err != nil {
149 ++ if err := quota.close(ctx); err != nil {
150 + return err
151 + }
152 +
153 +@@ -541,7 +541,7 @@ func (m *Manager) DeleteQuota(ctx context.Context, qType string, name string) er
154 + // ApplyQuota runs the request against any quota rule that is applicable to it. If
155 + // there are multiple quota rule that matches the request parameters, rule that
156 + // takes precedence will be used to allow/reject the request.
157 +-func (m *Manager) ApplyQuota(req *Request) (Response, error) {
158 ++func (m *Manager) ApplyQuota(ctx context.Context, req *Request) (Response, error) {
159 + var resp Response
160 +
161 + quota, err := m.QueryQuota(req)
162 +@@ -562,7 +562,7 @@ func (m *Manager) ApplyQuota(req *Request) (Response, error) {
163 + return resp, nil
164 + }
165 +
166 +- return quota.allow(req)
167 ++ return quota.allow(ctx, req)
168 + }
169 +
170 + // SetEnableRateLimitAuditLogging updates the operator preference regarding the
171 +diff --git a/vault/quotas/quotas_rate_limit.go b/vault/quotas/quotas_rate_limit.go
172 +index 64117b002..ad58b2af3 100644
173 +--- a/vault/quotas/quotas_rate_limit.go
174 ++++ b/vault/quotas/quotas_rate_limit.go
175 +@@ -1,6 +1,7 @@
176 + package quotas
177 +
178 + import (
179 ++ "context"
180 + "encoding/hex"
181 + "fmt"
182 + "math"
183 +@@ -264,7 +265,7 @@ func (rlq *RateLimitQuota) QuotaName() string {
184 + // returned if the request ID or address is empty. If the path is exempt, the
185 + // quota will not be evaluated. Otherwise, the client rate limiter is retrieved
186 + // by address and the rate limit quota is checked against that limiter.
187 +-func (rlq *RateLimitQuota) allow(req *Request) (Response, error) {
188 ++func (rlq *RateLimitQuota) allow(ctx context.Context, req *Request) (Response, error) {
189 + resp := Response{
190 + Headers: make(map[string]string),
191 + }
192 +@@ -300,7 +301,11 @@ func (rlq *RateLimitQuota) allow(req *Request) (Response, error) {
193 + }
194 + }
195 +
196 +- limit, remaining, reset, allow := rlq.store.Take(req.ClientAddress)
197 ++ limit, remaining, reset, allow, err := rlq.store.Take(ctx, req.ClientAddress)
198 ++ if err != nil {
199 ++ return resp, err
200 ++ }
201 ++
202 + resp.Allowed = allow
203 + resp.Headers[httplimit.HeaderRateLimitLimit] = strconv.FormatUint(limit, 10)
204 + resp.Headers[httplimit.HeaderRateLimitRemaining] = strconv.FormatUint(remaining, 10)
205 +@@ -320,13 +325,13 @@ func (rlq *RateLimitQuota) allow(req *Request) (Response, error) {
206 +
207 + // close stops the current running client purge loop.
208 + // It should be called with the write lock held.
209 +-func (rlq *RateLimitQuota) close() error {
210 ++func (rlq *RateLimitQuota) close(ctx context.Context) error {
211 + if rlq.purgeBlocked {
212 + close(rlq.closePurgeBlockedCh)
213 + }
214 +
215 + if rlq.store != nil {
216 +- return rlq.store.Close()
217 ++ return rlq.store.Close(ctx)
218 + }
219 +
220 + return nil
221 +diff --git a/vault/quotas/quotas_rate_limit_test.go b/vault/quotas/quotas_rate_limit_test.go
222 +index 27225e338..21f35dac3 100644
223 +--- a/vault/quotas/quotas_rate_limit_test.go
224 ++++ b/vault/quotas/quotas_rate_limit_test.go
225 +@@ -37,7 +37,7 @@ func TestNewRateLimitQuota(t *testing.T) {
226 + err := tc.rlq.initialize(logging.NewVaultLogger(log.Trace), metricsutil.BlackholeSink())
227 + require.Equal(t, tc.expectErr, err != nil, err)
228 + if err == nil {
229 +- require.Nil(t, tc.rlq.close())
230 ++ require.Nil(t, tc.rlq.close(context.Background()))
231 + }
232 + })
233 + }
234 +@@ -46,7 +46,7 @@ func TestNewRateLimitQuota(t *testing.T) {
235 + func TestRateLimitQuota_Close(t *testing.T) {
236 + rlq := NewRateLimitQuota("test-rate-limiter", "qa", "/foo/bar", 16.7, time.Second, time.Minute)
237 + require.NoError(t, rlq.initialize(logging.NewVaultLogger(log.Trace), metricsutil.BlackholeSink()))
238 +- require.NoError(t, rlq.close())
239 ++ require.NoError(t, rlq.close(context.Background()))
240 +
241 + time.Sleep(time.Second) // allow enough time for purgeClientsLoop to receive on closeCh
242 + require.False(t, rlq.getPurgeBlocked(), "expected blocked client purging to be disabled after explicit close")
243 +@@ -66,14 +66,14 @@ func TestRateLimitQuota_Allow(t *testing.T) {
244 + }
245 +
246 + require.NoError(t, rlq.initialize(logging.NewVaultLogger(log.Trace), metricsutil.BlackholeSink()))
247 +- defer rlq.close()
248 ++ defer rlq.close(context.Background())
249 +
250 + var wg sync.WaitGroup
251 +
252 + reqFunc := func(addr string, atomicNumAllow, atomicNumFail *atomic.Int32) {
253 + defer wg.Done()
254 +
255 +- resp, err := rlq.allow(&Request{ClientAddress: addr})
256 ++ resp, err := rlq.allow(context.Background(), &Request{ClientAddress: addr})
257 + if err != nil {
258 + return
259 + }
260 +@@ -141,7 +141,7 @@ func TestRateLimitQuota_Allow_WithBlock(t *testing.T) {
261 + }
262 +
263 + require.NoError(t, rlq.initialize(logging.NewVaultLogger(log.Trace), metricsutil.BlackholeSink()))
264 +- defer rlq.close()
265 ++ defer rlq.close(context.Background())
266 + require.True(t, rlq.getPurgeBlocked())
267 +
268 + var wg sync.WaitGroup
269 +@@ -149,7 +149,7 @@ func TestRateLimitQuota_Allow_WithBlock(t *testing.T) {
270 + reqFunc := func(addr string, atomicNumAllow, atomicNumFail *atomic.Int32) {
271 + defer wg.Done()
272 +
273 +- resp, err := rlq.allow(&Request{ClientAddress: addr})
274 ++ resp, err := rlq.allow(context.Background(), &Request{ClientAddress: addr})
275 + if err != nil {
276 + return
277 + }
278 +@@ -221,5 +221,5 @@ func TestRateLimitQuota_Update(t *testing.T) {
279 + require.NoError(t, qm.SetQuota(context.Background(), TypeRateLimit.String(), quota, true))
280 + require.NoError(t, qm.SetQuota(context.Background(), TypeRateLimit.String(), quota, true))
281 +
282 +- require.Nil(t, quota.close())
283 ++ require.Nil(t, quota.close(context.Background()))
284 + }
285 +diff --git a/vault/quotas/quotas_util.go b/vault/quotas/quotas_util.go
286 +index dc2fcdfac..7c0732f67 100644
287 +--- a/vault/quotas/quotas_util.go
288 ++++ b/vault/quotas/quotas_util.go
289 +@@ -40,7 +40,7 @@ func (*entManager) Reset() error {
290 +
291 + type LeaseCountQuota struct{}
292 +
293 +-func (l LeaseCountQuota) allow(request *Request) (Response, error) {
294 ++func (l LeaseCountQuota) allow(_ context.Context, _ *Request) (Response, error) {
295 + panic("implement me")
296 + }
297 +
298 +@@ -56,7 +56,7 @@ func (l LeaseCountQuota) initialize(logger log.Logger, sink *metricsutil.Cluster
299 + panic("implement me")
300 + }
301 +
302 +-func (l LeaseCountQuota) close() error {
303 ++func (l LeaseCountQuota) close(_ context.Context) error {
304 + panic("implement me")
305 + }
306 +
307
308 diff --git a/app-admin/vault/vault-1.8.2.ebuild b/app-admin/vault/vault-1.8.2.ebuild
309 index 57bba092722..7f8468a86e1 100644
310 --- a/app-admin/vault/vault-1.8.2.ebuild
311 +++ b/app-admin/vault/vault-1.8.2.ebuild
312 @@ -1130,8 +1130,8 @@ EGO_SUM=(
313 "github.com/sean-/pager v0.0.0-20180208200047-666be9bf53b5/go.mod"
314 "github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529"
315 "github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod"
316 -"github.com/sethvargo/go-limiter v0.3.0"
317 -"github.com/sethvargo/go-limiter v0.3.0/go.mod"
318 +"github.com/sethvargo/go-limiter v0.7.1"
319 +"github.com/sethvargo/go-limiter v0.7.1/go.mod"
320 "github.com/shirou/gopsutil v3.21.5+incompatible"
321 "github.com/shirou/gopsutil v3.21.5+incompatible/go.mod"
322 "github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24"
323 @@ -1780,6 +1780,8 @@ FILECAPS=(
324 -m 755 'cap_ipc_lock=+ep' usr/bin/${PN}
325 )
326
327 +PATCHES=( "${FILESDIR}"/${P}-go-limiter.patch )
328 +
329 RESTRICT+=" test"
330
331 src_prepare() {