Skip to content

fix(admin): inject updatetime when the requst is PATCH with sub path#4765

Merged
tzssangglass merged 2 commits intoapache:masterfrom
spacewander:fpas
Aug 6, 2021
Merged

fix(admin): inject updatetime when the requst is PATCH with sub path#4765
tzssangglass merged 2 commits intoapache:masterfrom
spacewander:fpas

Conversation

@spacewander
Copy link
Copy Markdown
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
Copy Markdown
Contributor

@qizhendong1 qizhendong1 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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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>
if code then
return code, err
end
utils.inject_timestamp(new_value, nil, nil)
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor

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

if code then
return code, err
end
utils.inject_timestamp(node_value, nil, true)
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

@qizhendong1
Copy link
Copy Markdown
Contributor

qizhendong1 commented Aug 6, 2021

@spacewander can it be merged today ?

@spacewander
Copy link
Copy Markdown
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