Consul API some subdirs not listed

Hi, i have a Consul cluster and we have some KVs organized by Directories. When I am inside to the Shell machine, when I run the “consul kv get -keys TEST-SERVER/” command run perfectly and I can se de diferent subdirs inside (and all the KVs):

Output example with shell command (i put only the dirs here):

TEST-SERVER/App01/
TEST-SERVER/App02/
TEST-SERVER/App03/
TEST-SERVER/App04/

But, when I try to use the API with the command “curl http://server_url:8500/v1/TEST-SERVER/?keys” I have a respond without some values (these values are some dirs):

Example output with api (i put only the dirs here):

TEST-SERVER/App01/
TEST-SERVER/App04/

Why with the api i cant see these 2 others folders? How to fix-it?

In the UI is all of them listed.

Thanks for all people.

curl -k 'localhost:8500/v1/kv/TEST-SERVER/?recurse&keys

At the moment I can’ t test anything (don’t even know if the syntax is correct), but I think you should combine recurse with keys if there are any subdirs.

Hi, the command not work, becauseI see the same answer. TEST-SERVER is a folder and the sub-folders are diferents apps.

There is no point in showing me some records inside (TEST-SERVER) and some not:

REAL-CASE:
In Terminal I Can see 8 App Folders inside TEST-SERVER, but in API not (only 4). The problem is only with these folders, because in the list apear the diferents KVs that are inside.

Terminal:
image

Api:

In the sencond image we can see that the Green check are good response but, in red we can see that:

  • Don’t appear the result “TEST-SERVER/App3/”
  • Don’t appear the result “TEST-SERVER/App3/dir1/”
  • Don’t appear the result “TEST-SERVER/App3/dir1/subdir01/”
  • Don’t appear the result “TEST-SERVER/App3/dir2/”
  • Don’t appear the result “TEST-SERVER/App5/”
  • Don’t appear the result “TEST-SERVER/App5/dir2/”
  • Don’t appear the result “TEST-SERVER/App6/”
  • Don’t appear the result “TEST-SERVER/App8/”

I think that with these examples it’s more easy understand my problem. This can be occur because some KV are imported or something like this ??

Hi to all !!

I have found that, when you create the KVs with kv export and kv import this don’t create the keys for the diferents Folders.

  • This only create de KVs group by the diferents folders and the web UI can “translate” them to organize the diferentes KV paths.

I don’t know if this is a BUG to fix them or what but, if you want these Folders to show in your API call you have to create it again.

For example, you can see that you have one app organize like this in the UI:

Environment01 > App01 > kv01

Normally the API-call (root directory) have to say something like this (yes i have all organized by environments):

[
“Environment01/”
“Environment01/App01/”
“Environment01/App01/kv01”
]

But, when you have created the KV you used the kv export and kv import command and you only recive something like this:

[
“Environment01/”
“Environment01/App01/kv01”
]

Where is the “App01” folder ?

OK, no problem. Now you have to create a new Folder with the name “App01” in the web UI inside to Environment and now you can see this respond in the api call:

[
“Environment01/”
“Environment01/App01/”
“Environment01/App01/kv01”
]

1 Like

Good to hear you’ve found the reason and a workaround.
Maybe you should create an issue on github. :wink:

1 Like