Skip to content
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

Merged
merged 2 commits into from
Aug 6, 2021

Conversation

spacewander
Copy link
Member

Fix #4763

Signed-off-by: spacewander spacewanderlzx@gmail.com

What this PR does / why we need it:

Pre-submission checklist:

  • Did you explain what problem does this PR solve? Or what new features have been added?
  • 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 first

Fix apache#4763

Signed-off-by: spacewander <spacewanderlzx@gmail.com>
@spacewander spacewander marked this pull request as ready for review August 6, 2021 05:06
if code >= 300 then
ngx.status = code
end
ngx.say(message)
Copy link
Contributor

@zhendongcmss zhendongcmss Aug 6, 2021

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

Copy link
Member Author

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

=== TEST 10: patch upstream(new nodes)

Copy link
Contributor

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

=== TEST 10: patch upstream(new nodes)

we have auto test cases, why we don't find this issue ?

Copy link
Member

@tzssangglass tzssangglass Aug 6, 2021

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>
@@ -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)
Copy link
Member Author

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`
Copy link
Contributor

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

Copy link
Contributor

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

Copy link
Contributor

@zhendongcmss zhendongcmss Aug 6, 2021

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)
Copy link
Contributor

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

Copy link
Contributor

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

Copy link
Member Author

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.

@zhendongcmss
Copy link
Contributor

zhendongcmss commented Aug 6, 2021

@spacewander can it be merged today ?

@spacewander
Copy link
Member Author

@zhendongcmss
It depends on when we have enough approving reviews.

@tzssangglass tzssangglass merged commit 7a1287a into apache:master Aug 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: using HTTP PATCH method to modify plugin pemeters return 405
4 participants