
Beim Versuch zu debuggenPatronenVerbindung zu Consul, ich habe versucht, selbst einen einfachen Python-Connector zu Consul zu schreiben.
Das ist, was ich mache (Python3, Centos7)
import consul
c = consul.Consul(host='consul-host',port=port,token='some-token')
c.kv.get('/v1/kv/some/long/path/bar')
Das ist, was ich bekomme (derselbe Fehler, den Patroni erzeugt):
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.6/site-packages/consul/base.py", line 554, in get
params=params)
File "/usr/local/lib/python3.6/site-packages/consul/std.py", line 22, in get
self.session.get(uri, verify=self.verify, cert=self.cert)))
File "/usr/local/lib/python3.6/site-packages/consul/base.py", line 223, in cb
CB._status(response, allow_404=allow_404)
File "/usr/local/lib/python3.6/site-packages/consul/base.py", line 181, in _status
raise ACLPermissionDenied(response.body)
consul.base.ACLPermissionDenied: rpc error making call: Permission denied
Curl funktioniert mit diesem Token einwandfrei.
curl --header "X-Consul-Token:some-token" http://consul-host:port/v1/kv/some/long/path/bar | jq .
[
{
"LockIndex": 0,
"Key": "/v1/kv/some/long/path/bar",
"Flags": 0,
"Value": "Zm9v",
"CreateIndex": 2951475,
"ModifyIndex": 2951475
}
]
Irgendwelche Ideen, was ich falsch mache? Danke.
Antwort1
Ihr Traceback zeigt aufKonsul/base.py:554:
return self.agent.http.get(
CB.json(index=True, decode=decode, one=one),
'/v1/kv/%s' % key,
params=params)
Da Sie den Schlüssel übergeben, '/v1/kv/some/long/path/bar'
wird der Endpunkt erreichthttp://consul-host:port/v1/kv/v1/kv/ein/langer/Pfad/barund nichthttp://consul-host:port/v1/kv/some/long/path/bar