projects
/
arvados.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
20559: Test concurrent writes using same token.
[arvados.git]
/
services
/
ws
/
permission.go
diff --git
a/services/ws/permission.go
b/services/ws/permission.go
index a39a959312aed582957d8845dddfc70394b649a4..78158b12a1921748d46bfe579ded1d3ed1c5982e 100644
(file)
--- a/
services/ws/permission.go
+++ b/
services/ws/permission.go
@@
-2,14
+2,16
@@
//
// SPDX-License-Identifier: AGPL-3.0
//
// SPDX-License-Identifier: AGPL-3.0
-package
main
+package
ws
import (
import (
+ "context"
"net/http"
"net/url"
"time"
"net/http"
"net/url"
"time"
- "git.curoverse.com/arvados.git/sdk/go/arvados"
+ "git.arvados.org/arvados.git/sdk/go/arvados"
+ "git.arvados.org/arvados.git/sdk/go/ctxlog"
)
const (
)
const (
@@
-19,7
+21,7
@@
const (
type permChecker interface {
SetToken(token string)
type permChecker interface {
SetToken(token string)
- Check(uuid string) (bool, error)
+ Check(
ctx context.Context,
uuid string) (bool, error)
}
func newPermChecker(ac arvados.Client) permChecker {
}
func newPermChecker(ac arvados.Client) permChecker {
@@
-54,9
+56,9
@@
func (pc *cachingPermChecker) SetToken(token string) {
pc.cache = make(map[string]cacheEnt)
}
pc.cache = make(map[string]cacheEnt)
}
-func (pc *cachingPermChecker) Check(uuid string) (bool, error) {
+func (pc *cachingPermChecker) Check(
ctx context.Context,
uuid string) (bool, error) {
pc.nChecks++
pc.nChecks++
- logger :=
logger(nil
).
+ logger :=
ctxlog.FromContext(ctx
).
WithField("token", pc.Client.AuthToken).
WithField("uuid", uuid)
pc.tidy()
WithField("token", pc.Client.AuthToken).
WithField("uuid", uuid)
pc.tidy()
@@
-73,7
+75,9
@@
func (pc *cachingPermChecker) Check(uuid string) (bool, error) {
}
pc.nMisses++
}
pc.nMisses++
- err = pc.RequestAndDecode(&buf, "GET", path, nil, url.Values{
+ ctx, cancel := context.WithDeadline(context.Background(), time.Now().Add(time.Minute))
+ defer cancel()
+ err = pc.RequestAndDecodeContext(ctx, &buf, "GET", path, nil, url.Values{
"include_trash": {"true"},
"select": {`["uuid"]`},
})
"include_trash": {"true"},
"select": {`["uuid"]`},
})