Skip to content

Conversation

@hulining
Copy link

Description

This PR supports the consul_kv service discovery support token function described in #9532.

Checklist

  • I have explained the need for this PR and the problem it solves
  • I have explained the changes or the new features added to this PR
  • I have added tests corresponding to this change
    For testing, I don't know how to add test cases yet, but I tested locally that this function can be used normally.
  • I have updated the documentation to reflect this change
  • I have verified that this change is backward compatible (If not, please discuss on the APISIX mailing list first)

@leslie-tsang
Copy link
Member

Hello there, we need a test case for this feature. :)

@sevensolutions
Copy link
Contributor

sevensolutions commented Sep 20, 2023

I'am really waiting for this feature.
Where can we find the existing tests for the consul DNS provider, so i check what we need to add?

Edit: Ah, found it. They're here:
https://github.com/apache/apisix/blob/master/t/discovery/consul.t
https://github.com/apache/apisix/blob/master/t/discovery/consul_kv.t

I have no idea how to execute them right now, but i'll try to provide some tests here.

@monkeyDluffy6017
Copy link
Contributor

@leslie-tsang please help to finish this pr

@sevensolutions
Copy link
Contributor

I think i'am almost there. What i've done:

  1. Added a new consul service to ci/pod/docker-compose.first.yml which enables ACL
consul_3:
    image: consul:1.15.4
    restart: unless-stopped
    ports:
      - "8502:8500"
    command: [ "consul", "agent", "-server", "-bootstrap-expect=1", "-client", "0.0.0.0", "-log-level", "info", "-data-dir=/consul/data", "-enable-script-checks", "-ui", "-hcl", "acl = {\nenabled = true\ndefault_policy = \"deny\"\nenable_token_persistence = true\n}" ]
    networks:
      consul_net:
  1. Run make ci-env-up project_compose_ci=ci/pod/docker-compose.first.yml
  2. Added a new test in t/discovery/consul.t to bootstrap the ACL system
=== TEST 14: bootstrap acl
--- config
location /v1/acl {
    proxy_pass http://127.0.0.1:8502;
}
--- request eval
[
    "PUT /v1/acl/bootstrap\n" . "{\"BootstrapSecret\": \"2b778dd9-f5f1-6f29-b4b4-9a5fa948757a\"}"
]
--- error_code eval
[200]
  1. Then i've just copied one of the other tests.
  2. Executed tests with TEST_NGINX_BINARY=/usr/bin/openresty prove -It/test-nginx/lib -I./ -r t/discovery/consul.t

Is this the correct way to go?

@monkeyDluffy6017
Copy link
Contributor

monkeyDluffy6017 commented Sep 26, 2023

@sevensolutions Yeah, it's exactly what you said

@sevensolutions
Copy link
Contributor

sevensolutions commented Sep 26, 2023

@monkeyDluffy6017 thanks.

How can i get some logs from APISIX during development?
I'am getting a 500 Internal Server Error when i run curl "http://127.0.0.1:9180/apisix/admin/services/" -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' but i have no idea why.
Is there a special API-Key used in the development version?
I just started APISIX with make run

Edit: Found it.
I'am getting:

2023/09/26 19:05:19 [error] 1253677#1253677: exit_worker_by_lua error: ./apisix/plugins/ext-plugin/init.lua:18: module 'flatbuffers' not found:
no file '/home/daniel/apisix2/apisix//deps/share/lua/5.1/flatbuffers.lua'

@sevensolutions
Copy link
Contributor

Got it working. I've created #10278 for token support in consul including tests.

@monkeyDluffy6017
Copy link
Contributor

Thanks for your contribution! I'will close this pr, it's done by #10278

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants