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 2021/05/31 01:57:54 UTC

[GitHub] [apisix] Yiyiyimu opened a new pull request #4342: fix: add error handling when use customized config

Yiyiyimu opened a new pull request #4342:
URL: https://github.com/apache/apisix/pull/4342


   Signed-off-by: yiyiyimu <wo...@gmail.com>
   
   ### What this PR does / why we need it:
   Ref: #4337 
   
   When implementing with #2101, no error handling is implemented so with the invalid config file, apisix would still start without the correct config setup. Here to fix it.
   
   One thing to mention, since I failed to figure out how to get stderr separately when running shell command in Lua, considering normally stdout of `ls` and `mv` would always be empty (on ubuntu), I forward stderr to stdout to get the error msg and fail fast. Not sure if it's working in all OS.
   
   ### Pre-submission checklist:
   
   * [x] Did you explain what problem does this PR solve? Or what new features have been added?
   * [x] Have you added corresponding test cases?
   * [ ] Have you modified the corresponding document?
   * [ ] Is this PR backward compatible? **If it is not backward compatible, please discuss on the [mailing list](https://github.com/apache/apisix/tree/master#community) first**
   


-- 
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:
users@infra.apache.org



[GitHub] [apisix] spacewander merged pull request #4342: fix: add error handling when use customized config

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


   


-- 
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:
users@infra.apache.org



[GitHub] [apisix] spacewander commented on a change in pull request #4342: fix: add error handling when use customized config

Posted by GitBox <gi...@apache.org>.
spacewander commented on a change in pull request #4342:
URL: https://github.com/apache/apisix/pull/4342#discussion_r642173876



##########
File path: apisix/cli/ops.lua
##########
@@ -657,8 +658,18 @@ local function start(env, ...)
     if customized_yaml then
         profile.apisix_home = env.apisix_home .. "/"
         local local_conf_path = profile:yaml_path("config")
-        util.execute_cmd("mv " .. local_conf_path .. " " .. local_conf_path .. ".bak")
-        util.execute_cmd("ln " .. customized_yaml .. " " .. local_conf_path)
+
+        local err = util.execute_cmd_with_error("mv " .. local_conf_path .. " "
+                                                .. local_conf_path .. ".bak")
+        if len(err) > 0 then

Review comment:
       Use `#err` is enough

##########
File path: apisix/cli/util.lua
##########
@@ -47,6 +47,14 @@ function _M.execute_cmd(cmd)
     return data
 end
 
+_M.execute_cmd = execute_cmd
+
+-- For ls and mv which stdout would be always be empty,

Review comment:
       For commands which stdout




-- 
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:
users@infra.apache.org



[GitHub] [apisix] Yiyiyimu commented on pull request #4342: fix: add error handling when use customized config

Posted by GitBox <gi...@apache.org>.
Yiyiyimu commented on pull request #4342:
URL: https://github.com/apache/apisix/pull/4342#issuecomment-851649695


   @spacewander PTAL


-- 
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:
users@infra.apache.org



[GitHub] [apisix] Yiyiyimu commented on a change in pull request #4342: fix: add error handling when use customized config

Posted by GitBox <gi...@apache.org>.
Yiyiyimu commented on a change in pull request #4342:
URL: https://github.com/apache/apisix/pull/4342#discussion_r642186986



##########
File path: apisix/cli/ops.lua
##########
@@ -657,8 +658,18 @@ local function start(env, ...)
     if customized_yaml then
         profile.apisix_home = env.apisix_home .. "/"
         local local_conf_path = profile:yaml_path("config")
-        util.execute_cmd("mv " .. local_conf_path .. " " .. local_conf_path .. ".bak")
-        util.execute_cmd("ln " .. customized_yaml .. " " .. local_conf_path)
+
+        local err = util.execute_cmd_with_error("mv " .. local_conf_path .. " "
+                                                .. local_conf_path .. ".bak")
+        if len(err) > 0 then

Review comment:
       Thx! Fixed




-- 
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:
users@infra.apache.org