-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(admin): inject updatetime when the requst is PATCH with sub path #4765
Conversation
Fix apache#4763 Signed-off-by: spacewander <spacewanderlzx@gmail.com>
if code >= 300 then | ||
ngx.status = code | ||
end | ||
ngx.say(message) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest add PATCH body is json format like
curl http://127.0.0.1:9080/apisix/admin/upstreams/100/nodes -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -i -X PATCH -d '
{
"39.97.63.215:80": 1,
"39.97.63.215:81": 1
}'
The patch request body support json format
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PATCH with json has been covered by
Line 348 in 183351c
=== TEST 10: patch upstream(new nodes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PATCH with json has been covered by
Line 348 in 183351c
=== TEST 10: patch upstream(new nodes)
we have auto test cases, why we don't find this issue ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This case is not covered by the test cases.
Signed-off-by: spacewander <spacewanderlzx@gmail.com>
apisix/admin/upstreams.lua
Outdated
@@ -204,12 +204,12 @@ function _M.patch(id, conf, sub_path) | |||
if code then | |||
return code, err | |||
end | |||
utils.inject_timestamp(new_value, nil, nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. Fixed in the new commit
if not conf.update_time or (patch_conf and patch_conf.update_time == nil) then | ||
if not conf.update_time or | ||
-- For PATCH request, the modification is passed as 'patch_conf' | ||
-- If the sub path is used, the 'patch_conf' will be a placeholder `true` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the place holder is nil
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if the path_conf placeholder is true,
(patch_conf and (patch_conf == true or patch_conf.update_time == nil)) =>
( true and (true == true or true.update_time == nil) ), true.update_time will raise error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, if path_conf is true, true.update_time doesn't been executed.
@@ -150,14 +150,14 @@ function _M.patch(id, conf, sub_path) | |||
if code then | |||
return code, err | |||
end | |||
utils.inject_timestamp(node_value, nil, true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The laste args is nil
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The seme as below, only upstream is right
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. The placeholder is true. See other changed files.
@spacewander can it be merged today ? |
@zhendongcmss |
Fix #4763
Signed-off-by: spacewander spacewanderlzx@gmail.com
What this PR does / why we need it:
Pre-submission checklist: