Skip to content

Conversation

@zaunist
Copy link
Contributor

@zaunist zaunist commented Mar 4, 2022

What this PR does / why we need it:

Currently, server-info is refactored, so we should backport to 2.10 release. Because 2.10 is a LTS version.

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

@spacewander spacewander changed the title fix: backport server-info to 2.10 change: backport server-info to 2.10 Mar 4, 2022
@zaunist
Copy link
Contributor Author

zaunist commented Mar 4, 2022

cc @tzssangglass @spacewander

return nil, err
end

return res, nil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove , nil

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I don't return nil, how can I be sure there is no err?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the default value is nil in this case

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked the other methods in etcd.lua, push, delete, set, etc. all return nil, and I think I'm correct in returning nil here. Shouldn't the code style of a repository be uniform? Even if the default value is nil, it should be explicitly shown in the code, so that the logic of the code is clearer.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

, nil is useless, so we should remove it and keep the code simpler

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checke APISIX repo, other file has the same situation. Example:

There are more places where there is a similar situation, where nil is returned when err equals nil, do we need to be uniform for those as well?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can create a new issue, fix them later

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it.

[error]
--- error_log
timer created to report server info, interval: 60
qr/^{"boot_time":\d+,"etcd_version":"[\d\.]+","hostname":"[a-zA-Z\-0-9\.]+","id":[a-zA-Z\-0-9]+,"version":"[\d\.]+"}$/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure why you remove test cases when you add many codes?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So please add more test cases for the added codes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this change, we are using keepalive to replace the put operation, and testing keepalive requires verification of revision changes in etcd. However, since test-nginx reloads nginx every time you run a test, this may cause the revision to change, and I have not found a way to verify the keepalive.

@zaunist zaunist requested a review from membphis March 7, 2022 02:31
Copy link
Member

@membphis membphis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zaunist
Copy link
Contributor Author

zaunist commented Mar 8, 2022

I have create an issue for uniform code style #6541. So we can do it in other PRs.

@spacewander spacewander merged commit 60987be into apache:release/2.10 Mar 8, 2022
@zaunist zaunist deleted the feat/backport_server_info branch March 8, 2022 06:00
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.

6 participants