feat: support reading configuration form xds(mvp)#6614
Conversation
|
|
||
|
|
||
| ffi.cdef[[ | ||
| extern void CreateMock(void* writeRoute); |
There was a problem hiding this comment.
change it to standard C style: create_mock
There was a problem hiding this comment.
we should call a init() function here
There was a problem hiding this comment.
init() is the name of a reserved function of go, with special meaning, I replaced it with initial()
| - t/plugin | ||
| - t/admin t/cli t/config-center-yaml t/control t/core t/debug t/discovery t/error_page t/misc | ||
| - t/node t/router t/script t/stream-node t/utils t/wasm | ||
| - t/node t/router t/script t/stream-node t/utils t/wasm t/amesh-library |
| end | ||
| sys_conf["wasm"] = yaml_conf.wasm | ||
|
|
||
| sys_conf["config_center"] = yaml_conf.apisix.config_center |
| properties = { | ||
| config_center = { | ||
| enum = {"etcd", "yaml"}, | ||
| enum = {"etcd", "yaml", "shdict"}, |
There was a problem hiding this comment.
| enum = {"etcd", "yaml", "shdict"}, | |
| enum = {"etcd", "yaml", "xds"}, |
would be better?
|
|
||
|
|
||
| local function load_libamesh(lib_name) | ||
| ngx_timer_at(0, function(premature) |
| end | ||
|
|
||
|
|
||
| function _M.new(key, opts) |
There was a problem hiding this comment.
We can use injection for test?
Lines 32 to 50 in 15517fe
| - t/plugin | ||
| - t/admin t/cli t/config-center-yaml t/control t/core t/debug t/discovery t/error_page t/misc | ||
| - t/node t/router t/script t/stream-node t/utils t/wasm | ||
| - t/amesh-library t/node t/router t/script t/stream-node t/utils t/wasm |
| sudo dpkg -i tinygo_${TINYGO_VER}_amd64.deb | ||
| cd t/wasm && find . -type f -name "*.go" | xargs -Ip tinygo build -o p.wasm -scheduler=none -target=wasi p | ||
|
|
||
| - name: Build Amesh library |
| local string_gmatch = string.gmatch | ||
| local string_match = string.match | ||
| local io_open = io.open | ||
| local io_close = io.close |
There was a problem hiding this comment.
Put them to the module level?
| local tried_paths = new_tab(32, 0) | ||
| local i = 1 | ||
|
|
||
| for k, _ in string_gmatch(cpath, "[^;]+") do |
| local i = 1 | ||
|
|
||
| for k, _ in string_gmatch(cpath, "[^;]+") do | ||
| local fpath = string_match(k, "(.*/)") |
| require("apisix.balancer").init_worker() | ||
| load_balancer = require("apisix.balancer") | ||
|
|
||
| if core.config == require("apisix.core.config_shdict") then |
There was a problem hiding this comment.
I think we may need to unify the term, the shdict is the container, the xds is the way, I think here config_xds will be better.
There was a problem hiding this comment.
another option, we can use amesh
There was a problem hiding this comment.
@membphis I don't think so, from the point of view of Apache APISIX, what is amesh? Why do we need to care about a commercial product?
There was a problem hiding this comment.
yes, you are right. config_xds is fine
Signed-off-by: tzssangglass <[email protected]>
Signed-off-by: tzssangglass <[email protected]>
Signed-off-by: tzssangglass <[email protected]>
|
|
||
|
|
||
| function _M.init_worker() | ||
| local lib_name = "libxds.so" |
There was a problem hiding this comment.
Put it at the module level?
tao12345666333
left a comment
There was a problem hiding this comment.
In my opinion, I think all xds should be replaced with external or other names of similar meaning.
Although we are currently integrating Istio/xds, APISIX does not actually need to pay attention to whether the external Go application is docking with xDS or other protocols. If we name it external library, then users can use this mode to interface with any service, and even we can use it to watch etcd directly, it will be a very big change, and it will be more clear.
|
IMHO, |
| __DATA__ | ||
|
|
||
| === TEST 1: load Amesh library so successfully | ||
| --- yaml_config |
There was a problem hiding this comment.
Let's set the yaml_config in the file level?
| require("apisix.balancer").init_worker() | ||
| load_balancer = require("apisix.balancer") | ||
|
|
||
| if core.config == require("apisix.core.config_xds") then |
OK so we can keep this naming for now and let's move forward. |
| {% end %} | ||
|
|
||
| {% if config_center == "xds" then %} | ||
| lua_shared_dict router-config 10m; |
There was a problem hiding this comment.
| lua_shared_dict router-config 10m; | |
| lua_shared_dict xds-route-config 10m; |
would that be better?
| local new_tab = base.new_tab | ||
| local ffi = require ("ffi") | ||
| local C = ffi.C | ||
| local router_config = ngx.shared["router-config"] |
There was a problem hiding this comment.
It is not configuration for router, but for route.
|
|
||
| if not xdsagent then | ||
| tried_paths[#tried_paths + 1] = 'tried above paths but can not load ' .. lib_name | ||
| error("can not load Amesh library, tried paths: " .. |
There was a problem hiding this comment.
| error("can not load Amesh library, tried paths: " .. | |
| error("can not load xds library, tried paths: " .. |
# Conflicts: # t/APISIX.pm
| local new_tab = base.new_tab | ||
| local ffi = require ("ffi") | ||
| local C = ffi.C | ||
| local router_config = ngx.shared["xds-route-config"] |
There was a problem hiding this comment.
There are still using router in some places.
# Conflicts: # t/APISIX.pm
| local new_tab = base.new_tab | ||
| local ffi = require ("ffi") | ||
| local C = ffi.C | ||
| local route_config = ngx.shared["xds-route-config"] |
There was a problem hiding this comment.
| local route_config = ngx.shared["xds-route-config"] | |
| local route_config = ngx.shared["xds-route-config"] |
There was a problem hiding this comment.
I want to change it in the next PR😅, otherwise it will dismiss the previous approval.
| lua_shared_dict ext-plugin 1m; | ||
| lua_shared_dict kubernetes 1m; | ||
| lua_shared_dict tars 1m; | ||
| lua_shared_dict xds-route-config 1m; |
There was a problem hiding this comment.
Should we sync the setting in apisix/cli/ngx_tpl.lua ?
Change 1m to 10m
There was a problem hiding this comment.
It is enough in the test.
Description
Fixes # (issue)
Checklist