[GitHub] [incubator-apisix-dashboard] juzhiyuan merged pull request #347: fix: transform vars error
juzhiyuan merged pull request #347: URL: https://github.com/apache/incubator-apisix-dashboard/pull/347 This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-apisix-dashboard] Rapiz1 opened a new issue #340: Lint failed on source
Rapiz1 opened a new issue #340: URL: https://github.com/apache/incubator-apisix-dashboard/issues/340 We should fix these issues before any attempt to set up a linter on Actions. ``` yarn run v1.22.4 warning package.json: "dependencies" has dependency "react-helmet-async" with range "^1.0.4" that collides with a dependency in "devDependencies" of the same name with version "1.0.6" $ umi g tmp && npm run lint:js && npm run lint:style && npm run lint:prettier npm WARN lifecycle The node binary used for scripts is /tmp/yarn--1595906147339-0.5859369794624159/node but npm is using /usr/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with. > apisix-dashboard@1.1.0 lint:js /project/incubator-apisix-dashboard > eslint --cache --ext .js,.jsx,.ts,.tsx --format=pretty ./src src/access.ts:1:16 ⚠1:16 Unexpected unnamed function. func-names src/pages/Route/transform.ts:11:9 ✖ 11:9 Variable name upstream_header must match one of the following formats: camelCase, PascalCase, UPPER_CASE @typescript-eslint/naming-convention ✖ 150:5 Variable name upstream_path must match one of the following formats: camelCase, PascalCase, UPPER_CASE @typescript-eslint/naming-convention ✖ 151:5 Variable name upstream_header must match one of the following formats: camelCase, PascalCase, UPPER_CASE @typescript-eslint/naming-convention ✖ 152:5 Variable name upstream_protocol must match one of the following formats: camelCase, PascalCase, UPPER_CASE @typescript-eslint/naming-convention ✖ 153:5 Variable name upstream_id must match one of the following formats: camelCase, PascalCase, UPPER_CASE @typescript-eslint/naming-convention src/pages/SSL/service.ts:9:10 ✖9:10 Variable name expire_start must match one of the following formats: camelCase, PascalCase, UPPER_CASE @typescript-eslint/naming-convention ✖9:24 Variable name expire_end must match one of the following formats: camelCase, PascalCase, UPPER_CASE @typescript-eslint/naming-convention ✖ 12:5 Use an object spread instead of Object.assign eg: { ...foo }. prefer-object-spread src/pages/Upstream/Create.tsx:6:25 ✖6:25 /project/incubator-apisix-dashboard/node_modules/umi/index.js imported multiple times. import/no-duplicates ✖7:25 /project/incubator-apisix-dashboard/node_modules/umi/index.js imported multiple times. import/no-duplicates ✖ 33:39 Unexpected string concatenation. prefer-template src/components/PluginPage/PluginPage.tsx:104:25 ✖ 104:25 Use an object spread instead of Object.assign eg: { ...foo }. prefer-object-spread ✖ 117:20 Use an object spread instead of Object.assign eg: { ...foo }. prefer-object-spread src/pages/Consumer/Create.tsx:4:25 ✖4:25 /project/incubator-apisix-dashboard/node_modules/umi/index.js imported multiple times. import/no-duplicates ✖5:25 /project/incubator-apisix-dashboard/node_modules/umi/index.js imported multiple times. import/no-duplicates src/pages/Consumer/List.tsx:8:25 ✖8:25 /project/incubator-apisix-dashboard/node_modules/umi/index.js imported multiple times. import/no-duplicates ✖9:25 /project/incubator-apisix-dashboard/node_modules/umi/index.js imported multiple times. import/no-duplicates src/pages/Route/List.tsx:7:25 ✖7:25 /project/incubator-apisix-dashboard/node_modules/umi/index.js imported multiple times. import/no-duplicates ✖8:25 /project/incubator-apisix-dashboard/node_modules/umi/index.js imported multiple times. import/no-duplicates src/pages/SSL/Create.tsx:5:25 ✖5:25 /project/incubator-apisix-dashboard/node_modules/umi/index.js imported multiple times. import/no-duplicates ✖8:25 /project/incubator-apisix-dashboard/node_modules/umi/index.js imported multiple times. import/no-duplicates src/pages/Upstream/List.tsx:6:25 ✖6:25 /project/incubator-apisix-dashboard/node_modules/umi/index.js imported multiple times. import/no-duplicates ✖7:25 /project/incubator-apisix-dashboard/node_modules/umi/index.js imported multiple times. import/no-duplicates src/components/PluginForm/locales/en-US.ts:72:62 ✖ 72:62 Unexpected template string expression. no-template-curly-in-string src/components/PluginForm/locales/zh-CN.ts:72:62
[GitHub] [incubator-apisix-dashboard] juzhiyuan merged pull request #343: feat(i18n): actionbar component
juzhiyuan merged pull request #343: URL: https://github.com/apache/incubator-apisix-dashboard/pull/343 This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-apisix] Hmemories commented on issue #1838: bug: discovery Eureka cannot automatically proxy to a new node
Hmemories commented on issue #1838: URL: https://github.com/apache/incubator-apisix/issues/1838#issuecomment-665085159 > @qiujiayu do you have time to take a look at this bug? Is this problem solved now? This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-apisix] gxthrj opened a new issue #1923: feature: Divide config.yaml into two files config-custom.yaml & config-default.yaml
gxthrj opened a new issue #1923: URL: https://github.com/apache/incubator-apisix/issues/1923 ### Issue description 1. When I deploy APISIX, only a small amount of configuration needs to be modified in conf.yaml. 2. When the APISIX version is upgraded, some configuration items may be added, and these configuration items may be ignored by the user and cause errors. proposal 1.Divide config.yaml into two files config-custom.yaml & config-default.yaml. 2.`config-default.yaml` is the most complete configuration. 3.`config-custom.yaml` define the user customized configuration. 4. merge the two config file, get final config. demo config-custom.yaml ```YAML apisix: node_listen: 80 allow_admin: - 10.0.0.0/24 admin_key: -name: "admin" key: asdfji213k335f136f87ad84b625c8df etcd: host: - "http://10.10.10.2:2379; - "http://10.10.10.3:2379; - "http://10.10.12.3:2379; ``` config-default.yaml keep the same with APISIX version generate the final configuration using `config-custom.yaml` to cover `config-default.yaml`. ### Environment * apisix version 1.4 * OS: This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[incubator-apisix-dashboard] branch master updated: feat(i18n): pluginpage component (#345)
This is an automated email from the ASF dual-hosted git repository. juzhiyuan pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-apisix-dashboard.git The following commit(s) were added to refs/heads/master by this push: new ce1b3a1 feat(i18n): pluginpage component (#345) ce1b3a1 is described below commit ce1b3a18292aa51c4d40c149f4cfa27a6f5b6489 Author: TikWind <65604564+tikw...@users.noreply.github.com> AuthorDate: Wed Jul 29 18:10:42 2020 +0800 feat(i18n): pluginpage component (#345) * i18n pluginpage * change pluginpage to PluginPage --- src/components/PluginPage/PluginCard.tsx | 4 +- src/components/PluginPage/PluginDrawer.tsx | 11 +- src/components/PluginPage/PluginPage.tsx | 6 +- src/components/PluginPage/index.ts | 4 +- src/components/PluginPage/locales/en-US.ts | 277 +++-- src/components/PluginPage/locales/zh-CN.ts | 274 ++-- src/locales/en-US.ts | 4 +- src/locales/zh-CN.ts | 4 +- 8 files changed, 303 insertions(+), 281 deletions(-) diff --git a/src/components/PluginPage/PluginCard.tsx b/src/components/PluginPage/PluginCard.tsx index bb3857a..d883c68 100644 --- a/src/components/PluginPage/PluginCard.tsx +++ b/src/components/PluginPage/PluginCard.tsx @@ -15,8 +15,8 @@ const PluginCard: React.FC = ({ name, actions }) => { diff --git a/src/components/PluginPage/PluginDrawer.tsx b/src/components/PluginPage/PluginDrawer.tsx index 3a8d3ce..fd0bfa2 100644 --- a/src/components/PluginPage/PluginDrawer.tsx +++ b/src/components/PluginPage/PluginDrawer.tsx @@ -3,6 +3,7 @@ import { Drawer, Button } from 'antd'; import { withTheme, FormProps } from '@rjsf/core'; import { Theme as AntDTheme } from '@rjsf/antd'; import { JSONSchema7 } from 'json-schema'; +import { useIntl } from 'umi'; interface Props { name?: string; @@ -27,6 +28,8 @@ const PluginDrawer: React.FC = ({ onClose, onFinish, }) => { + + const { formatMessage } = useIntl(); const PluginForm = withTheme(AntDTheme); if (!name) { @@ -38,7 +41,7 @@ const PluginDrawer: React.FC = ({ return ( = ({ {Boolean(active) && ( onInactive(name)}> - 禁用 + {formatMessage({ id: 'PluginPage.drawer.disabled' })} )} {Boolean(!active) && ( onActive(name)}> - 启用 + {formatMessage({ id: 'PluginPage.drawer.enable' })} )} @@ -68,7 +71,7 @@ const PluginDrawer: React.FC = ({ form.submit(); }} > - 确认 + {formatMessage({ id: 'PluginPage.drawer.confirm' })} )} diff --git a/src/components/PluginPage/PluginPage.tsx b/src/components/PluginPage/PluginPage.tsx index c1c3f68..f5ac114 100644 --- a/src/components/PluginPage/PluginPage.tsx +++ b/src/components/PluginPage/PluginPage.tsx @@ -9,6 +9,7 @@ import PluginCard from './PluginCard'; import PluginDrawer from './PluginDrawer'; import { getList, fetchPluginSchema } from './service'; import { PLUGIN_MAPPER_SOURCE } from './data'; +import { useIntl } from 'umi'; type Props = { disabled?: boolean; @@ -21,14 +22,15 @@ const PluginPage: React.FC = ({ data = {}, disabled, onChange }) => { const [activeList, setActiveList] = useState([]); const [inactiveList, setInactiveList] = useState([]); const [schema, setSchema] = useState(); + const { formatMessage } = useIntl(); const pluginList = [ { - title: '已启用', + title: formatMessage({ id: 'PluginPage.drawer.is.enabled' }), list: activeList, }, { - title: '未启用', + title: formatMessage({ id: 'PluginPage.drawer.not.enabled' }), list: inactiveList, }, ]; diff --git a/src/components/PluginPage/index.ts b/src/components/PluginPage/index.ts index 2a0db29..70c3194 100644 --- a/src/components/PluginPage/index.ts +++ b/src/components/PluginPage/index.ts @@ -2,5 +2,5 @@ export { default } from './PluginPage'; export { default as PluginCard } from './PluginCard'; export { default as PluginDrawer } from './PluginDrawer'; -export { default as PluginZhCN } from './locales/zh-CN'; -export { default as PluginEnUS } from './locales/en-US'; +export { default as PluginPageZhCN } from './locales/zh-CN'; +export { default as PluginPageEnUS } from './locales/en-US'; diff --git a/src/components/PluginPage/locales/en-US.ts b/src/components/PluginPage/locales/en-US.ts index 27332bf..2c0b309 100644 --- a/src/components/PluginPage/locales/en-US.ts +++ b/src/components/PluginPage/locales/en-US.ts @@ -1,163 +1,172 @@ export default { - 'PluginForm.plugin.limit-conn.desc': 'Limit the number of concurrent connections', -
[incubator-apisix] branch master updated: bugfix: run `apisix start` several times will start multi APISIX servers (#1913)
This is an automated email from the ASF dual-hosted git repository. membphis pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-apisix.git The following commit(s) were added to refs/heads/master by this push: new 333962a bugfix: run `apisix start` several times will start multi APISIX servers (#1913) 333962a is described below commit 333962a54bf51604fd46f392920850bf6c9ee5a6 Author: nic-chen <33000667+nic-c...@users.noreply.github.com> AuthorDate: Wed Jul 29 18:43:41 2020 +0800 bugfix: run `apisix start` several times will start multi APISIX servers (#1913) --- .travis/linux_openresty_runner.sh | 17 + bin/apisix| 15 +++ 2 files changed, 32 insertions(+) diff --git a/.travis/linux_openresty_runner.sh b/.travis/linux_openresty_runner.sh index 4abb356..d5922c6 100755 --- a/.travis/linux_openresty_runner.sh +++ b/.travis/linux_openresty_runner.sh @@ -141,6 +141,23 @@ script() { ./bin/apisix init_etcd ./bin/apisix start +#start again --> fial +res=`./bin/apisix start` +if [ "$res" != "APISIX is running..." ]; then +echo "failed: APISIX runs repeatedly" +exit 1 +fi + +#kill apisix +sudo kill -9 `ps aux | grep apisix | grep nginx | awk '{print $2}'` + +#start -> ok +res=`./bin/apisix start` +if [ "$res" == "APISIX is running..." ]; then +echo "failed: shouldn't stop APISIX running after kill the old process." +exit 1 +fi + sleep 1 cat logs/error.log diff --git a/bin/apisix b/bin/apisix index 3a2ee6c..762c326 100755 --- a/bin/apisix +++ b/bin/apisix @@ -854,6 +854,18 @@ local openresty_args = [[openresty -p ]] .. apisix_home .. [[ -c ]] .. apisix_home .. [[/conf/nginx.conf]] function _M.start(...) +-- check running +local pid_path = apisix_home .. "/logs/nginx.pid" +local pid, err = read_file(pid_path) +if pid then +local hd = io.popen("lsof -p " .. pid) +local res = hd:read("*a") +if res and res ~= "" then +print("APISIX is running...") +return nil +end +end + init(...) init_etcd(...) @@ -874,6 +886,9 @@ function _M.restart() end function _M.reload() +-- reinit nginx.conf +init() + local test_cmd = openresty_args .. [[ -t -q ]] -- When success, -- On linux, os.execute returns 0,
[incubator-apisix] branch master updated: makefile: add comments for `install` command. (#1912)
This is an automated email from the ASF dual-hosted git repository. membphis pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-apisix.git The following commit(s) were added to refs/heads/master by this push: new 3947f06 makefile: add comments for `install` command. (#1912) 3947f06 is described below commit 3947f06989f94f0381307361a39c3f6849a6f25d Author: YuanSheng Wang AuthorDate: Wed Jul 29 19:23:49 2020 +0800 makefile: add comments for `install` command. (#1912) * doc: update output of `make help` --- Makefile | 4 ++-- doc/how-to-build.md | 26 +- doc/zh-cn/how-to-build.md | 26 +- 3 files changed, 28 insertions(+), 28 deletions(-) diff --git a/Makefile b/Makefile index 5836e36..edfc950 100644 --- a/Makefile +++ b/Makefile @@ -36,7 +36,7 @@ endif LUAJIT_DIR ?= $(shell ${OR_EXEC} -V 2>&1 | grep prefix | grep -Eo 'prefix=(.*)/nginx\s+--' | grep -Eo '/.*/')luajit -### help: Show Makefile rules. +### help: Show Makefile rules .PHONY: help help: default @echo Makefile rules: @@ -112,7 +112,7 @@ reload: default $(OR_EXEC) -p $$PWD/ -c $$PWD/conf/nginx.conf -s reload -### install: Install the apisix +### install: Install the apisix (only for luarocks) .PHONY: install install: default $(INSTALL) -d /usr/local/apisix/ diff --git a/doc/how-to-build.md b/doc/how-to-build.md index 157baa3..50c825c 100644 --- a/doc/how-to-build.md +++ b/doc/how-to-build.md @@ -90,19 +90,19 @@ $ make stop $ make help Makefile rules: -help: Show Makefile rules. -deps: Installation dependencies -utils: Installation tools -lint: Lint Lua source code -init: Initialize the runtime environment -run: Start the apisix server -stop: Stop the apisix server -verify:Verify the configuration of apisix server -clean: Remove generated files -reload:Reload the apisix server -install: Install the apisix -test: Run the test case -license-check: Check lua souce code for Apache License +help: Show Makefile rules +deps: Installation dependencies +utils:Installation tools +lint: Lint Lua source code +init: Initialize the runtime environment +run: Start the apisix server +stop: Stop the apisix server +verify: Verify the configuration of apisix server +clean:Remove generated files +reload: Reload the apisix server +install: Install the apisix (only for luarocks) +test: Run the test case +license-check:Check Lua source code for Apache License ``` ## 4. Test diff --git a/doc/zh-cn/how-to-build.md b/doc/zh-cn/how-to-build.md index 56a1c18..5300491 100644 --- a/doc/zh-cn/how-to-build.md +++ b/doc/zh-cn/how-to-build.md @@ -88,19 +88,19 @@ $ make stop $ make help Makefile rules: -help: Show Makefile rules. -deps: Installation dependencies -utils: Installation tools -lint: Lint Lua source code -init: Initialize the runtime environment -run: Start the apisix server -stop: Stop the apisix server -verify:Verify the configuration of apisix server -clean: Remove generated files -reload:Reload the apisix server -install: Install the apisix -test: Run the test case -license-check: Check lua souce code for Apache License +help: Show Makefile rules +deps: Installation dependencies +utils:Installation tools +lint: Lint Lua source code +init: Initialize the runtime environment +run: Start the apisix server +stop: Stop the apisix server +verify: Verify the configuration of apisix server +clean:Remove generated files +reload: Reload the apisix server +install: Install the apisix (only for luarocks) +test: Run the test case +license-check:Check Lua source code for Apache License ``` ## 4. 运行测试案例
[incubator-apisix] branch master updated: doc: fix typos. (#1916)
This is an automated email from the ASF dual-hosted git repository. membphis pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-apisix.git The following commit(s) were added to refs/heads/master by this push: new 4c61baa doc: fix typos. (#1916) 4c61baa is described below commit 4c61baa7e980b2233ed52a89ba09e23cb1f06c9a Author: YuanSheng Wang AuthorDate: Wed Jul 29 19:23:08 2020 +0800 doc: fix typos. (#1916) url -> URL . --- FAQ.md | 2 +- FAQ_CN.md| 2 +- doc/admin-api.md | 2 +- doc/architecture-design.md | 6 +++--- doc/discovery.md | 2 +- doc/plugins/prometheus.md| 2 +- doc/plugins/proxy-rewrite.md | 2 +- doc/plugins/redirect.md | 2 +- doc/zh-cn/admin-api.md | 6 +++--- doc/zh-cn/architecture-design.md | 4 ++-- doc/zh-cn/discovery.md | 2 +- doc/zh-cn/plugins/http-logger.md | 3 ++- 12 files changed, 18 insertions(+), 17 deletions(-) diff --git a/FAQ.md b/FAQ.md index dbf365e..e82067e 100644 --- a/FAQ.md +++ b/FAQ.md @@ -73,7 +73,7 @@ If using a proxy doesn't solve this problem, you can add `--verbose` option duri ## How to support gray release via APISIX? -An example, `foo.com/product/index.html?id=204=2`, gray release based on `id` in the query string in uri as a condition: +An example, `foo.com/product/index.html?id=204=2`, gray release based on `id` in the query string in URL as a condition: 1. Group A:id <= 1000 2. Group B:id > 1000 diff --git a/FAQ_CN.md b/FAQ_CN.md index 334fc69..c4772eb 100644 --- a/FAQ_CN.md +++ b/FAQ_CN.md @@ -75,7 +75,7 @@ luarocks 服务。 运行 `luarocks config rocks_servers` 命令(这个命令 ## 如何通过 APISIX 支持灰度发布? -比如,`foo.com/product/index.html?id=204=2`, 根据 uri 中 query string 中的 `id` 作为条件来灰度发布: +比如,`foo.com/product/index.html?id=204=2`, 根据 URL 中 query string 中的 `id` 作为条件来灰度发布: 1. A组:id <= 1000 2. B组:id > 1000 diff --git a/doc/admin-api.md b/doc/admin-api.md index caa3b1d..f0ecb24 100644 --- a/doc/admin-api.md +++ b/doc/admin-api.md @@ -76,7 +76,7 @@ Config Example: { "id": "1", # id, unnecessary. "uri": "/release/a",# uri -"uris": ["/a","/b"],# A set of uri, uri and uris need only have a non-empty one. +"uris": ["/a","/b"],# A set of uri, URL and uris need only have a non-empty one. "methods": ["GET","POST"], # Can fill multiple methods "host": "aa.com", # host "hosts": ["a.com","b.com"], # A set of host. Host and hosts only need to be non-empty one. diff --git a/doc/architecture-design.md b/doc/architecture-design.md index 098808e..8de3fbb 100644 --- a/doc/architecture-design.md +++ b/doc/architecture-design.md @@ -80,7 +80,7 @@ We configure all the parameters directly in the Route, it's easy to set up, and The shortcomings mentioned above are independently abstracted in APISIX by the two concepts [Service](#service) and [Upstream](#upstream). -The route example created below is to proxy the request with uri `/index.html` to the Upstream service with the address `39.97.63.215:80`: +The route example created below is to proxy the request with URL `/index.html` to the Upstream service with the address `39.97.63.215:80`: ```shell $ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -i -d ' @@ -453,8 +453,8 @@ Set the route that best suits your business needs in the local configuration `co * `Absolute match `: Complete match for the given `uri` , such as `/foo/bar`,`/foo/glo`. * `Prefix match`: Use `*` at the end to represent the given `uri` as a prefix match. For example, `/foo*` allows matching `/foo/`, `/foo/a` and `/foo/b`. * `match priority`: first try absolute match, if you can't hit absolute match, try prefix match. -* `Any filter attribute`: Allows you to specify any Ningx built-in variable as a filter, such as uri request parameters, request headers, cookies, and so on. -* `radixtree_host_uri`: Use `host + uri` as the primary index (based on the `radixtree` engine), matching both host and uri for the current request. +* `Any filter attribute`: Allows you to specify any Ningx built-in variable as a filter, such as URL request parameters, request headers, cookies, and so on. +* `radixtree_host_uri`: Use `host + uri` as the primary index (based on the `radixtree` engine), matching both host and URL for the current request. * `apisix.router.ssl`: SSL loads the matching route. * `radixtree_sni`: (Default) Use `SNI` (Server Name Indication) as the primary index (based on the radixtree engine). diff --git a/doc/discovery.md b/doc/discovery.md index 96d36e8..ad5fbfd 100644 --- a/doc/discovery.md +++ b/doc/discovery.md @@ -183,7 +183,7 @@ eureka: ## Upstream setting -Here is an example of routing a request with a uri of "/user/*" to a
[incubator-apisix] branch master updated: bugfix: read the request body from the temporary file if it was cached. (#1863)
This is an automated email from the ASF dual-hosted git repository. membphis pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-apisix.git The following commit(s) were added to refs/heads/master by this push: new 20207c8 bugfix: read the request body from the temporary file if it was cached. (#1863) 20207c8 is described below commit 20207c8108b85f8481375315ea324153589276ec Author: YuanSheng Wang AuthorDate: Wed Jul 29 19:24:27 2020 +0800 bugfix: read the request body from the temporary file if it was cached. (#1863) --- apisix/admin/init.lua | 8 -- apisix/core/request.lua | 53 -- t/admin/routes.t| 75 - 3 files changed, 131 insertions(+), 5 deletions(-) diff --git a/apisix/admin/init.lua b/apisix/admin/init.lua index 158ba92..71cb25e 100644 --- a/apisix/admin/init.lua +++ b/apisix/admin/init.lua @@ -26,6 +26,7 @@ local require = require local reload_event = "/apisix/admin/plugins/reload" local ipairs = ipairs local events +local MAX_REQ_BODY = 1024 * 1024 * 1.5 -- 1.5 MiB local viewer_methods = { @@ -117,8 +118,11 @@ local function run() core.response.exit(404) end -ngx.req.read_body() -local req_body = ngx.req.get_body_data() +local req_body, err = core.request.get_body(MAX_REQ_BODY) +if err then +core.log.error("failed to read request body: ", err) +core.response.exit(400, {error_msg = "invalid request body: " .. err}) +end if req_body then local data, err = core.json.decode(req_body) diff --git a/apisix/core/request.lua b/apisix/core/request.lua index 1148234..7fe8cdd 100644 --- a/apisix/core/request.lua +++ b/apisix/core/request.lua @@ -14,14 +14,21 @@ -- See the License for the specific language governing permissions and -- limitations under the License. -- + +local lfs = require("lfs") local ngx = ngx local get_headers = ngx.req.get_headers local tonumber = tonumber local error= error local type = type local str_fmt = string.format +local io_open = io.open +local req_read_body = ngx.req.read_body +local req_get_body_data = ngx.req.get_body_data +local req_get_body_file = ngx.req.get_body_file + -local _M = {version = 0.1} +local _M = {} local function _headers(ctx) @@ -94,7 +101,49 @@ function _M.get_remote_client_port(ctx) ctx = ngx.ctx.api_ctx end return tonumber(ctx.var.remote_port) - end +end + + +local function get_file(file_name) +local f, err = io_open(file_name, 'r') +if not f then +return nil, err +end + +local req_body = f:read("*all") +f:close() +return req_body +end + + +function _M.get_body(max_size) +req_read_body() + +local req_body = req_get_body_data() +if req_body then +return req_body +end + +local file_name = req_get_body_file() +if not file_name then +return nil +end + +if max_size then +local size, err = lfs.attributes (file_name, "size") +if not size then +return nil, err +end + +if size > max_size then +return nil, "request size " .. size .. " is greater than the " +.. "maximum size " .. max_size .. " allowed" +end +end + +local req_body, err = get_file(file_name) +return req_body, err +end return _M diff --git a/t/admin/routes.t b/t/admin/routes.t index 0e0d198..1ec272d 100644 --- a/t/admin/routes.t +++ b/t/admin/routes.t @@ -1882,6 +1882,79 @@ GET /t } } --- request -GET /t +GET /t --- response_headers Content-Type: application/json + + + +=== TEST 52: set route with size 36k (temporary file to store request body) +--- config +location /t { +content_by_lua_block { +local t = require("lib.test_admin").test + +local core = require("apisix.core") +local s = string.rep("a", 1024 * 35) +local req_body = [[{ +"upstream": { +"nodes": { +"]] .. s .. [[": 1 +}, +"type": "roundrobin" +}, +"uri": "/index.html" +}]] + +local code, body = t('/apisix/admin/routes/1', +ngx.HTTP_PUT, req_body) + +if code >= 300 then +ngx.status = code +end + +ngx.say("req size: ", #req_body) +ngx.say(body) +} +} +--- request +GET /t +--- response_body +req size: 36066 +passed +--- error_log +a client request body is buffered to a temporary file + + + +=== TEST 53: route size more than 1.5 MiB +--- config +location /t { +content_by_lua_block { +local t = require("lib.test_admin").test +local s = string.rep( "a", 1024 * 1024 * 1.6 ) +local code, body =
[incubator-apisix] branch master updated: feature: add a new option, decide if we remove the "/" at the end of … (#1766)
This is an automated email from the ASF dual-hosted git repository. membphis pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-apisix.git The following commit(s) were added to refs/heads/master by this push: new f9a8a26 feature: add a new option, decide if we remove the "/" at the end of … (#1766) f9a8a26 is described below commit f9a8a26dd4ba6f114c382a0157ae6ba956ad26dd Author: YuanSheng Wang AuthorDate: Wed Jul 29 19:25:30 2020 +0800 feature: add a new option, decide if we remove the "/" at the end of … (#1766) * feature: add a new option, decide if we remove the "/" at the end of the URI before route matching. fix #1765 --- apisix/init.lua | 19 +-- conf/config.yaml| 2 + t/lib/server.lua| 4 ++ t/router/radixtree-uri-keep-end-slash.t | 96 + t/router/radixtree-uri-sanity.t | 55 +++ 5 files changed, 172 insertions(+), 4 deletions(-) diff --git a/apisix/init.lua b/apisix/init.lua index ad1131b..354290d 100644 --- a/apisix/init.lua +++ b/apisix/init.lua @@ -33,8 +33,10 @@ local ipairs= ipairs local tostring = tostring local type = type local ngx_now = ngx.now +local str_byte = string.byte +local str_sub = string.sub local load_balancer - +local local_conf local dns_resolver local lru_resolved_domain @@ -97,7 +99,7 @@ function _M.http_init_worker() require("apisix.debug").init_worker() require("apisix.upstream").init_worker() -local local_conf = core.config.local_conf() +local_conf = core.config.local_conf() local dns_resolver_valid = local_conf and local_conf.apisix and local_conf.apisix.dns_resolver_valid @@ -322,6 +324,15 @@ function _M.http_access_phase() api_ctx.global_rules = router.global_rules end +if local_conf.apisix and local_conf.apisix.delete_uri_tail_slash then +local uri = api_ctx.var.uri +if str_byte(uri, #uri) == str_byte("/") then +api_ctx.var.uri = str_sub(api_ctx.var.uri, 1, #uri - 1) +core.log.info("remove the end of uri '/', current uri: ", + api_ctx.var.uri) +end +end + router.router_http.match(api_ctx) core.log.info("matched route: ", @@ -585,7 +596,7 @@ end local function cors_admin() -local local_conf = core.config.local_conf() +local_conf = core.config.local_conf() if local_conf.apisix and not local_conf.apisix.enable_admin_cors then return end @@ -649,7 +660,7 @@ function _M.stream_init_worker() load_balancer = require("apisix.balancer").run -local local_conf = core.config.local_conf() +local_conf = core.config.local_conf() local dns_resolver_valid = local_conf and local_conf.apisix and local_conf.apisix.dns_resolver_valid diff --git a/conf/config.yaml b/conf/config.yaml index 58e1139..aea1e85 100644 --- a/conf/config.yaml +++ b/conf/config.yaml @@ -74,6 +74,8 @@ apisix: name: "viewer" key: 4054f7cf07e344346cd3f287985e76a2 role: viewer + + delete_uri_tail_slash: false# delete the '/' at the end of the URI router: http: 'radixtree_uri' # radixtree_uri: match route by uri(base on radixtree) # radixtree_host_uri: match route by host + uri(base on radixtree) diff --git a/t/lib/server.lua b/t/lib/server.lua index e34602c..dfbead6 100644 --- a/t/lib/server.lua +++ b/t/lib/server.lua @@ -28,6 +28,10 @@ function _M.hello1() ngx.say("hello1 world") end +function _M.hello_() +ngx.say("hello world") +end + function _M.server_port() ngx.print(ngx.var.server_port) end diff --git a/t/router/radixtree-uri-keep-end-slash.t b/t/router/radixtree-uri-keep-end-slash.t new file mode 100644 index 000..ec6e9ba --- /dev/null +++ b/t/router/radixtree-uri-keep-end-slash.t @@ -0,0 +1,96 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +use t::APISIX 'no_plan'; + +repeat_each(1); +log_level('info'); +worker_connections(256); +no_root_location(); +no_shuffle(); + +sub
[incubator-apisix] branch master updated: plugin(batch): change processor name and error return type fix (#1927)
This is an automated email from the ASF dual-hosted git repository. membphis pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-apisix.git The following commit(s) were added to refs/heads/master by this push: new 0ad813e plugin(batch): change processor name and error return type fix (#1927) 0ad813e is described below commit 0ad813eb51a8c132c66a212ab43e963c3dad576f Author: Nirojan Selvanathan AuthorDate: Wed Jul 29 14:54:58 2020 +0200 plugin(batch): change processor name and error return type fix (#1927) Fix #1522 Fix #1521 --- apisix/utils/batch-processor.lua | 20 ++-- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/apisix/utils/batch-processor.lua b/apisix/utils/batch-processor.lua index 20e8353..18919c3 100644 --- a/apisix/utils/batch-processor.lua +++ b/apisix/utils/batch-processor.lua @@ -21,9 +21,9 @@ local ipairs = ipairs local table = table local now = ngx.now local type = type -local Batch_Processor = {} -local Batch_Processor_mt = { -__index = Batch_Processor +local batch_processor = {} +local batch_processor_mt = { +__index = batch_processor } local execute_func local create_buffer_timer @@ -109,17 +109,17 @@ function create_buffer_timer(self) end -function Batch_Processor:new(func, config) +function batch_processor:new(func, config) local ok, err = core.schema.check(schema, config) if not ok then -return err +return nil, err end if not(type(func) == "function") then return nil, "Invalid argument, arg #1 must be a function" end -local batch_processor = { +local processor = { func = func, buffer_duration = config.buffer_duration, inactive_timeout = config.inactive_timeout, @@ -134,11 +134,11 @@ function Batch_Processor:new(func, config) last_entry_t = 0 } -return setmetatable(batch_processor, Batch_Processor_mt) +return setmetatable(processor, batch_processor_mt) end -function Batch_Processor:push(entry) +function batch_processor:push(entry) -- if the batch size is one then immediately send for processing if self.batch_max_size == 1 then local batch = { entries = { entry }, retry_count = 0 } @@ -166,7 +166,7 @@ function Batch_Processor:push(entry) end -function Batch_Processor:process_buffer() +function batch_processor:process_buffer() -- If entries are present in the buffer move the entries to processing if #self.entry_buffer.entries > 0 then core.log.debug("tranferring buffer entries to processing pipe line, ", @@ -182,4 +182,4 @@ function Batch_Processor:process_buffer() end -return Batch_Processor +return batch_processor
[incubator-apisix] branch master updated: bugfix: update comment to 30 seconds in config.yaml (#1929)
This is an automated email from the ASF dual-hosted git repository. wenming pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-apisix.git The following commit(s) were added to refs/heads/master by this push: new 0034c66 bugfix: update comment to 30 seconds in config.yaml (#1929) 0034c66 is described below commit 0034c66586f43116957b3ef6b932b36bb746040b Author: Swayam Raina AuthorDate: Wed Jul 29 20:39:02 2020 +0530 bugfix: update comment to 30 seconds in config.yaml (#1929) --- conf/config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/config.yaml b/conf/config.yaml index aea1e85..20ba925 100644 --- a/conf/config.yaml +++ b/conf/config.yaml @@ -127,7 +127,7 @@ etcd: host: # it's possible to define multiple etcd hosts addresses of the same etcd cluster. - "http://127.0.0.1:2379; # multiple etcd address prefix: "/apisix" # apisix configurations prefix - timeout: 30 # 3 seconds + timeout: 30 # 30 seconds # user: root # root username for etcd # password: 5tHkHhYkjr6cQY# root password for etcd #eureka:
[GitHub] [incubator-apisix-dashboard] membphis edited a comment on pull request #347: fix: transform vars error
membphis edited a comment on pull request #347: URL: https://github.com/apache/incubator-apisix-dashboard/pull/347#issuecomment-665611673 you can add an action name like `fix` or `close`, then the related issue will be closed automatically after your PR was merged. @LiteSun ``` fix #341 ``` ![image](https://user-images.githubusercontent.com/6814606/88795164-2a39f480-d1d2-11ea-8dda-11d584b4d43b.png) This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-apisix-dashboard] membphis commented on pull request #347: fix: transform vars error
membphis commented on pull request #347: URL: https://github.com/apache/incubator-apisix-dashboard/pull/347#issuecomment-665611673 you can add an action name like `fix` or `close`, then the related issue will be closed automatically after your PR was merged. ``` fix #341 ``` ![image](https://user-images.githubusercontent.com/6814606/88795164-2a39f480-d1d2-11ea-8dda-11d584b4d43b.png) This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-apisix] shuaijinchao opened a new pull request #1928: bugfix: fix limit-count plugin redis.ttl error.
shuaijinchao opened a new pull request #1928: URL: https://github.com/apache/incubator-apisix/pull/1928 ### What this PR does / why we need it: FIX #1901 ### Pre-submission checklist: * [x] Did you explain what problem does this PR solve? Or what new features have been added? * [x] Is this PR backward compatible? This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-apisix-dashboard] juzhiyuan commented on issue #346: 路由设置proxy-rewrite BUG
juzhiyuan commented on issue #346: URL: https://github.com/apache/incubator-apisix-dashboard/issues/346#issuecomment-665574308 emmm Where is the actually data sent to API? This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-apisix] membphis merged pull request #1912: makefile: add comments for `install` command.
membphis merged pull request #1912: URL: https://github.com/apache/incubator-apisix/pull/1912 This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-apisix-dashboard] TikWind opened a new pull request #348: feat: combine import
TikWind opened a new pull request #348: URL: https://github.com/apache/incubator-apisix-dashboard/pull/348 combine import This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-apisix] membphis merged pull request #1863: bugfix: read the request body from the temporary file if it was cached.
membphis merged pull request #1863: URL: https://github.com/apache/incubator-apisix/pull/1863 This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-apisix-dashboard] juzhiyuan closed issue #341: route setting bug
juzhiyuan closed issue #341: URL: https://github.com/apache/incubator-apisix-dashboard/issues/341 This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-apisix] membphis closed issue #1895: bug: ` make install ` did not install lua deps to apisix install dir
membphis closed issue #1895: URL: https://github.com/apache/incubator-apisix/issues/1895 This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-apisix] membphis commented on pull request #1927: batch processor name and error return type fix
membphis commented on pull request #1927: URL: https://github.com/apache/incubator-apisix/pull/1927#issuecomment-665646735 many thx, merged @sshniro This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-apisix] membphis commented on a change in pull request #1888: change: add more prometheus metrics(etcd modify index)
membphis commented on a change in pull request #1888: URL: https://github.com/apache/incubator-apisix/pull/1888#discussion_r462229428 ## File path: apisix/core/config_etcd.lua ## @@ -221,10 +221,22 @@ local function sync_data(self) return true end -local dir_res, err = waitdir(self.etcd_cli, self.key, self.prev_index + 1) +local dir_res, err = waitdir(self.etcd_cli, self.key, self.prev_index + 1, self.timeout) + log.info("waitdir key: ", self.key, " prev_index: ", self.prev_index + 1) log.info("res: ", json.delay_encode(dir_res, true)) if not dir_res then +-- for fetch the last etcd index +local key_res, _ = getkey(self.etcd_cli, self.key) +if key_res and key_res.headers then +local key_index = key_res.headers["X-Etcd-Index"] +local key_idx = key_index and tonumber(key_index) or 0 +if key_idx and key_idx > self.prev_index then +-- Avoid the index to exceed 1000 by updating other keys that will causing a full reload Review comment: this line is too long ## File path: apisix/core/config_etcd.lua ## @@ -221,10 +221,22 @@ local function sync_data(self) return true end -local dir_res, err = waitdir(self.etcd_cli, self.key, self.prev_index + 1) +local dir_res, err = waitdir(self.etcd_cli, self.key, self.prev_index + 1, self.timeout) + log.info("waitdir key: ", self.key, " prev_index: ", self.prev_index + 1) log.info("res: ", json.delay_encode(dir_res, true)) if not dir_res then +-- for fetch the last etcd index Review comment: that is wrong. we need to fetch the last etcd index before `local dir_res, err = waitdir(... ...` This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-apisix] shuaijinchao opened a new pull request #1932: doc: add `request-validation` plugin chinese document.
shuaijinchao opened a new pull request #1932: URL: https://github.com/apache/incubator-apisix/pull/1932 ### What this PR does / why we need it: FIX #1882 ### Pre-submission checklist: * [x] Did you explain what problem does this PR solve? Or what new features have been added? * [x] Have you modified the corresponding document? * [x] Is this PR backward compatible? This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-apisix] membphis commented on a change in pull request #1928: bugfix: fix limit-count plugin redis.ttl error.
membphis commented on a change in pull request #1928: URL: https://github.com/apache/incubator-apisix/pull/1928#discussion_r462273477 ## File path: apisix/plugins/limit-count/limit-count-redis.lua ## @@ -71,7 +71,8 @@ function _M.incoming(self, key) local remaining key = self.plugin_name .. tostring(key) -local ret = red:ttl(key) +-- todo: test case +local ret = red:ttl(key) or -2 Review comment: I think we need to cache the `err`, eg: `local ret, err = red:(...)` And we should write this error message to log, set the right response like `500`. This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-apisix] membphis closed issue #1765: feature: add a new option, decide if we remove the "/" at the end of the URI before route mathing
membphis closed issue #1765: URL: https://github.com/apache/incubator-apisix/issues/1765 This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [incubator-apisix] membphis closed issue #1522: change: `Batch_Processor` -> `batch_processor` (name style)
membphis closed issue #1522: URL: https://github.com/apache/incubator-apisix/issues/1522 This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org