Closed
Description
With this script, and v3.3.11 or v3.3.17, I see that etcdserver does not respond promptly when presented with an Authorization token that is expired but syntactically valid:
#!/bin/bash -x
ETCD_IMAGE=quay.io/coreos/etcd:${ETCD_VERSION:-v3.3.11}
docker rm -f etcdserver || true
docker run \
--detach \
--net=host \
--name etcdserver \
${ETCD_IMAGE} \
etcd \
--advertise-client-urls "http://127.0.0.1:2379" \
--listen-client-urls "http://0.0.0.0:2379"
function ectl {
docker run \
--rm \
-i \
--net=host \
-e ETCDCTL_API=3 \
-e ETCDCTL_ENDPOINTS=http://127.0.0.1:2379 \
${ETCD_IMAGE} \
etcdctl \
"$@"
}
ectl user add root --interactive=false <<EOF
rootpasswd
EOF
ectl auth enable
time timeout 5s curl -w '%{http_code}' -L http://127.0.0.1:2379/v3alpha/kv/range -X POST -d '{"key": "L2NhbGljbwo="}'
time timeout 5s curl -w '%{http_code}' -L http://127.0.0.1:2379/v3alpha/kv/range -H 'Authorization: IsbMEkdCkHxvTUkO.22' -X POST -d '{"key": "L2NhbGljbwo="}'
time timeout 5s curl -w '%{http_code}' -L http://127.0.0.1:2379/v3alpha/kv/range -H 'Authorization: IsbMEkdCkHxvTUkO.' -X POST -d '{"key": "L2NhbGljbwo="}'
The output for the last 3 curls shows:
+ timeout 5s curl -w '%{http_code}' -L http://127.0.0.1:2379/v3alpha/kv/range -X POST -d '{"key": "L2NhbGljbwo="}'
{"error":"etcdserver: user name is empty","code":3}400
real 0m0.008s
user 0m0.006s
sys 0m0.001s
+ timeout 5s curl -w '%{http_code}' -L http://127.0.0.1:2379/v3alpha/kv/range -H 'Authorization: IsbMEkdCkHxvTUkO.22' -X POST -d '{"key": "L2NhbGljbwo="}'
real 0m5.003s
user 0m0.008s
sys 0m0.002s
+ timeout 5s curl -w '%{http_code}' -L http://127.0.0.1:2379/v3alpha/kv/range -H 'Authorization: IsbMEkdCkHxvTUkO.' -X POST -d '{"key": "L2NhbGljbwo="}'
{"error":"etcdserver: invalid auth token","code":16}401
real 0m0.013s
user 0m0.007s
sys 0m0.005s
In other words, with no Authorization header, or with a malformed token, we get an immediate negative response (which is good). But with a well formed but non-current token, the etcd server appears to hang. (In other experiments, I've waited up to a minute.)
Is this behavior explicable or somehow expected?