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

used cjson.safe instead of pcall. #3674

Merged
merged 1 commit into from
Jan 18, 2019

Conversation

moonming
Copy link
Contributor

What this PR does / why we need it:
better performance and readable.
Which issue this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close that issue when PR gets merged): fixes #

Special notes for your reviewer:

@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jan 18, 2019
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jan 18, 2019
@ElvinEfendi
Copy link
Member

ElvinEfendi commented Jan 18, 2019

@moonming thanks for the PR! As far as I can tell cjson.safe will return error message as well in case of error, can you include that in log messages as well (like we were doing with pcall)?

Also it would be great if you add a new test case to https://github.com/kubernetes/ingress-nginx/blob/master/rootfs/etc/nginx/lua/test/configuration_test.lua to cover the case where JSON payload is not correct - to make sure the error handled properly without blowing up.

better performance

How's it better performance? Because we eliminate an extra function (pcall) call?

@moonming
Copy link
Contributor Author

moonming commented Jan 18, 2019

@ElvinEfendi added the error message to log, thx.

How's it better performance? Because we eliminate an extra function (pcall) call?

yes, it can eliminate an extra Lua function call.

@ElvinEfendi
Copy link
Member

rootfs/etc/nginx/lua/configuration.lua:62:22: (W421) shadowing definition of variable err on line 52

CI is failing because of this.

Once you fix the please squash your commits into one.

@moonming
Copy link
Contributor Author

fixed and squashed commits into one.

@ElvinEfendi
Copy link
Member

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 18, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ElvinEfendi, moonming

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 18, 2019
@k8s-ci-robot k8s-ci-robot merged commit 42d3f68 into kubernetes:master Jan 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants