You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2022/09/15 12:39:46 UTC

[GitHub] [apisix] zhendongcmss opened a new pull request, #7926: fix: check config.yaml plugins list is nil or not

zhendongcmss opened a new pull request, #7926:
URL: https://github.com/apache/apisix/pull/7926

   ### Description
   
   when config.yaml plugin list is nil, apisix will print an error.
   ```
   22/09/15 08:46:34 [warn] 49#49: *7 [lua] plugin.lua:271: load(): failed to read stream plugin list from local file, context: init_worker_by_lua*
   2022/09/15 08:46:34 [error] 46#46: *101 lua entry thread aborted: runtime error: /usr/local/apisix/apisix/admin/init.lua:318: bad argument #1 to 'ipairs' (table expected, got nil)
   stack traceback:
   coroutine 0:
           [C]: in function 'ipairs'
           /usr/local/apisix/apisix/admin/init.lua:318: in function 'sync_local_conf_to_etcd'
           /usr/local/apisix/apisix/admin/init.lua:421: in function </usr/local/apisix/apisix/admin/init.lua:415>, context: ngx.timer
   ```
   
   Fixes # (issue)
   
   ### 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
   - [ ] 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](https://github.com/apache/apisix/tree/master#community) first)
   
   <!--
   
   Note
   
   1. Mark the PR as draft until it's ready to be reviewed.
   2. Always add/update tests for any changes unless you have a good reason.
   3. Always update the documentation to reflect the changes made in the PR.
   4. Make a new commit to resolve conversations instead of `push -f`.
   5. To resolve merge conflicts, merge master instead of rebasing.
   6. Use "request review" to notify the reviewer after making changes.
   7. Only a reviewer can mark a conversation as resolved.
   
   -->
   


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] spacewander commented on a diff in pull request #7926: fix: check config.yaml plugins list is nil

Posted by GitBox <gi...@apache.org>.
spacewander commented on code in PR #7926:
URL: https://github.com/apache/apisix/pull/7926#discussion_r973709454


##########
apisix/admin/init.lua:
##########
@@ -258,17 +258,21 @@ local function sync_local_conf_to_etcd(reset)
     local local_conf = core.config.local_conf()
 
     local plugins = {}
-    for _, name in ipairs(local_conf.plugins) do
-        core.table.insert(plugins, {
-            name = name,
-        })
+    if local_conf.plugins then

Review Comment:
   In what situation people will use an empty plugin list?



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] zhendongcmss commented on a diff in pull request #7926: fix: check config.yaml plugins list is nil

Posted by GitBox <gi...@apache.org>.
zhendongcmss commented on code in PR #7926:
URL: https://github.com/apache/apisix/pull/7926#discussion_r974983140


##########
apisix/admin/init.lua:
##########
@@ -258,17 +258,21 @@ local function sync_local_conf_to_etcd(reset)
     local local_conf = core.config.local_conf()
 
     local plugins = {}
-    for _, name in ipairs(local_conf.plugins) do
-        core.table.insert(plugins, {
-            name = name,
-        })
+    if local_conf.plugins then
+        for _, name in ipairs(local_conf.plugins) do
+            core.table.insert(plugins, {
+                name = name,
+            })
+        end
     end
 
-    for _, name in ipairs(local_conf.stream_plugins) do
-        core.table.insert(plugins, {
-            name = name,
-            stream = true,
-        })
+    if local_conf.stream_plugins then

Review Comment:
   good idea



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] zhendongcmss commented on a diff in pull request #7926: fix: check config.yaml plugins list is nil

Posted by GitBox <gi...@apache.org>.
zhendongcmss commented on code in PR #7926:
URL: https://github.com/apache/apisix/pull/7926#discussion_r973813326


##########
apisix/admin/init.lua:
##########
@@ -258,17 +258,21 @@ local function sync_local_conf_to_etcd(reset)
     local local_conf = core.config.local_conf()
 
     local plugins = {}
-    for _, name in ipairs(local_conf.plugins) do
-        core.table.insert(plugins, {
-            name = name,
-        })
+    if local_conf.plugins then

Review Comment:
   In the production environment we turned off all unused plugins.



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] zhendongcmss commented on a diff in pull request #7926: fix: check config.yaml plugins list is nil

Posted by GitBox <gi...@apache.org>.
zhendongcmss commented on code in PR #7926:
URL: https://github.com/apache/apisix/pull/7926#discussion_r973813037


##########
apisix/admin/init.lua:
##########
@@ -258,17 +258,21 @@ local function sync_local_conf_to_etcd(reset)
     local local_conf = core.config.local_conf()
 
     local plugins = {}
-    for _, name in ipairs(local_conf.plugins) do
-        core.table.insert(plugins, {
-            name = name,
-        })
+    if local_conf.plugins then

Review Comment:
   In most cases the list of http plugins is not empty, but the list of stream plugins is empty.



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] spacewander merged pull request #7926: fix: check config.yaml plugins list is nil

Posted by GitBox <gi...@apache.org>.
spacewander merged PR #7926:
URL: https://github.com/apache/apisix/pull/7926


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] spacewander commented on a diff in pull request #7926: fix: check config.yaml plugins list is nil

Posted by GitBox <gi...@apache.org>.
spacewander commented on code in PR #7926:
URL: https://github.com/apache/apisix/pull/7926#discussion_r973879177


##########
apisix/admin/init.lua:
##########
@@ -258,17 +258,21 @@ local function sync_local_conf_to_etcd(reset)
     local local_conf = core.config.local_conf()
 
     local plugins = {}
-    for _, name in ipairs(local_conf.plugins) do
-        core.table.insert(plugins, {
-            name = name,
-        })
+    if local_conf.plugins then
+        for _, name in ipairs(local_conf.plugins) do
+            core.table.insert(plugins, {
+                name = name,
+            })
+        end
     end
 
-    for _, name in ipairs(local_conf.stream_plugins) do
-        core.table.insert(plugins, {
-            name = name,
-            stream = true,
-        })
+    if local_conf.stream_plugins then

Review Comment:
   Maybe we can add a default empty array in https://github.com/apache/apisix/blob/9129572f6302300ddeee3f2234393445d8ead781/apisix/cli/schema.lua#L247?
   
   So that we don't need to introduce extra checks.



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org