hashicorp / consul

Consul is a distributed, highly available, and data center aware solution to connect and configure applications across dynamic, distributed infrastructure.
https://www.consul.io
Other
28.41k stars 4.43k forks source link

consul ui shows only one blank key for multiple KV created by /v1/txn #2536

Open tburt11 opened 7 years ago

tburt11 commented 7 years ago

consul version for both Client and Server

Consul v0.7.0 Protocol 2 spoken by default, understands 2 to 3 (agent will automatically use protocol >2 when speaking to compatible agents)

consul version for both Client and Server

Server single dev mode or multi-server cluster.

consul info for both Client and Server

Server:

agent:
    check_monitors = 0
    check_ttls = 0
    checks = 1
    services = 1
build:
    prerelease =
    revision = 'a189091
    version = 0.7.0
consul:
    bootstrap = true
    known_datacenters = 1
    leader = true
    leader_addr = 172.20.47.166:8300
    server = true
raft:
    applied_index = 21714
    commit_index = 21714
    fsm_pending = 0
    last_contact = never
    last_log_index = 21714
    last_log_term = 6
    last_snapshot_index = 16391
    last_snapshot_term = 2
    latest_configuration = [{Suffrage:Voter ID:172.20.47.166:8300 Address:172.20.47.166:8300}]
    latest_configuration_index = 1
    num_peers = 0
    protocol_version = 1
    protocol_version_max = 3
    protocol_version_min = 0
    snapshot_version_max = 1
    snapshot_version_min = 0
    state = Leader
    term = 6
runtime:
    arch = amd64
    cpu_count = 2
    goroutines = 54
    max_procs = 2
    os = linux
    version = go1.6.3
serf_lan:
    encrypted = false
    event_queue = 1
    event_time = 6
    failed = 0
    health_score = 0
    intent_queue = 0
    left = 0
    member_time = 1
    members = 1
    query_queue = 0
    query_time = 1
serf_wan:
    encrypted = false
    event_queue = 0
    event_time = 1
    failed = 0
    health_score = 0
    intent_queue = 0
    left = 0
    member_time = 1
    members = 1
    query_queue = 0
    query_time = 1

Operating system and Environment details

AWS amazon linux stock

Description of the Issue (and unexpected/desired result)

If a new KV is created with the /v1/txn api call, the key can be examined and recalled via the API, but the UI displays only one blank key.

Clicking the blank key causes the blank key to disappear, leaving the UI without an entry for the KV created via the API

Reproduction steps

Install and configure consul 0.7.0 configured with UI.

Add a key and value using the /v1/txn curl command.

View the created KV using a curl command.

View the UI and see only a single blank box where the key value should be.

screen shot 2016-11-28 at 2 14 36 pm screen shot 2016-11-28 at 2 13 33 pm

Log Fragments or Link to gist

Include appropriate Client or Server log fragments. If the log is longer than a few dozen lines, please include the URL to the gist.

TIP: Use -log-level=TRACE on the client and server to capture the maximum log detail.

tburt11 commented 7 years ago

The leading "/" appears to have some effect.

The keys in this example were created with a leading slash. This appears to be permissible in consul. Perhaps the leading slash is interpreted as the first char of key?

If a key of "/xxx" and a key of "xxx" are created, the second will appear in UI, the former appears as a blank box in UI.

If api is queried with: curl -s -curl http://172.20.47.166:8500/v1/kv/?recurse | jq '.' then both keys "/xxx" and "xxx" are defined, but only the latter is viewable in UI.

slackpad commented 7 years ago

Hi @tburt11 there are provisions to prevent adding a leading slash in the /v1/kv API, but the txn allows it through. It's interfering with how the UI asks for the keys by effectively creating another slash at the top - we should probably modify the /v1/txn endpoint to fail if you add the leading slash (or strip it) because you never want that as part of the key.

arunkumar-m commented 7 years ago

Submitted a pull request which will fail with status code 400, if there is a leading slash in one of the passed keys. Other options

  1. Silently ignore the keys with leading slashes. (or) 2. Strip the leading slashes and proceed.