Repository navigation
mysql proxy: Improve MySQL Proxy Codec - #14810
Conversation
Signed-off-by: qinggniq <[email protected]>
|
Hi @qinggniq, welcome and thank you for your contribution. We will try to review your Pull Request as quickly as possible. In the meantime, please take a look at the contribution guidelines if you have not done so already. |
Signed-off-by: qinggniq <[email protected]>
Signed-off-by: qinggniq <[email protected]> format Signed-off-by: qinggniq <[email protected]> spell Signed-off-by: qinggniq <[email protected]> spell Signed-off-by: qinggniq <[email protected]> spell Signed-off-by: qinggniq <[email protected]> spell Signed-off-by: qinggniq <[email protected]> format Signed-off-by: qinggniq <[email protected]>
Signed-off-by: qinggniq <[email protected]> remove bits header Signed-off-by: qinggniq <[email protected]>
Signed-off-by: qinggniq <[email protected]> remove bits header Signed-off-by: qinggniq <[email protected]>
Signed-off-by: qinggniq <[email protected]>
Signed-off-by: qinggniq <[email protected]> format Signed-off-by: qinggniq <[email protected]>
Signed-off-by: qinggniq <[email protected]>
|
@cpakulski can you take the first pass? |
|
Sure - I will take care of the first review pass. |
…achine, (2) use const std::string& instead of std::string as getter return type Signed-off-by: qinggniq <[email protected]> fix format Signed-off-by: qinggniq <[email protected]>
Signed-off-by: qinggniq <[email protected]>
Signed-off-by: qinggniq <[email protected]> format Signed-off-by: qinggniq <[email protected]> spell Signed-off-by: qinggniq <[email protected]>
|
@cpakulski What can I do to help you review? Should I split this pr into some separate prs, each contains changes of one codec? |
cpakulski
left a comment
There was a problem hiding this comment.
Some comments after the first pass.
Can you also check coverage? Additional tests must probably be added to increase coverage.
|
|
||
| int ClientLogin::parseResponseSsl(Buffer::Instance& buffer) { | ||
| if (BufferHelper::readUint32(buffer, client_cap_) != MYSQL_SUCCESS) { | ||
| ENVOY_LOG(info, "error when paring cap client ssl message"); |
There was a problem hiding this comment.
spelling: parsing .... The same below.
| if (BufferHelper::endOfBuffer(buffer)) { | ||
| // HandshakeV10 can terminate after Server Capabilities | ||
| return MYSQL_SUCCESS; | ||
| goto CHECK; |
There was a problem hiding this comment.
Can you restructure it so you do not use goto?
| constexpr int MYSQL_UT_SERVER_OK = 0; | ||
| constexpr int MYSQL_UT_SERVER_WARNINGS = 0x0001; | ||
|
|
||
| class MySQLCLoginRespTest : public testing::Test {}; |
There was a problem hiding this comment.
You dno not have to define fixture class if you do not have a common initialization for all classes or common data structures. You can put decode_data here instead of declaring it in each test. Otherwise delete fixture and declare tests as TEST not TEST_F.
| namespace NetworkFilters { | ||
| namespace MySQLProxy { | ||
|
|
||
| class MySQLCLoginTest : public testing::Test {}; |
| TEST_F(MySQLCLoginTest, MySQLParseLengthEncodedInteger) { | ||
| { | ||
| // encode 2 byte value | ||
| Buffer::InstancePtr buffer(new Buffer::OwnedImpl()); |
There was a problem hiding this comment.
Instead of using pointer, can you use Buffer::OwnedImpl and use drain method to clean it before you move to the next section of test?
| namespace NetworkFilters { | ||
| namespace MySQLProxy { | ||
|
|
||
| class MySQLGreetTest : public testing::Test {}; |
… of union Signed-off-by: qinggniq <[email protected]>
Signed-off-by: qinggniq <[email protected]>
Signed-off-by: qinggniq <[email protected]>
Signed-off-by: qinggniq <[email protected]>
Signed-off-by: qinggniq <[email protected]> format Signed-off-by: qinggniq <[email protected]> spell Signed-off-by: qinggniq <[email protected]>
|
@cpakulsk Some corner cases in |
Signed-off-by: qinggniq <[email protected]> fix file mod Signed-off-by: qinggniq <[email protected]>
|
@qinggniq I will review it first thing in the morning. Sorry for delay. |
cpakulski
left a comment
There was a problem hiding this comment.
I think we are very close. Thanks.
Just a few small comments. Your choice if you want to address them (code will be cleaner).
In the meantime I am going to do another full review pass of all changes.
| uint32_t init_len = buffer.length(); | ||
| ASSERT(init_len >= len); | ||
| if (BufferHelper::readUint8(buffer, resp_code_) != DecodeStatus::Success) { | ||
| ENVOY_LOG(info, "error parsing more plugin data in mysql Login auth more msg"); |
There was a problem hiding this comment.
Can you rephrase the error message to something like:
error parsing body of ....
The same message is used below.
The current message is bit unclear.
Signed-off-by: qinggniq <[email protected]>
|
/retest |
|
Retrying Azure Pipelines: |
|
/retest |
|
Retrying Azure Pipelines: |
|
ping @cpakulski |
| // cap flag, so just assume the CLIENT_PROTOCOL_41 is always set. ref | ||
| // https://github.com/mysql/mysql-connector-j/blob/release/8.0/src/main/protocol-impl/java/com/mysql/cj/protocol/a/result/OkPacket.java#L48 | ||
| if (BufferHelper::readUint16(buffer, warnings_) != DecodeStatus::Success) { | ||
| ENVOY_LOG(info, "error parsing warnings of ok msg"); |
There was a problem hiding this comment.
Should this be on debug level? I know these were "info", however, don't you think this will be super chatty? The same as all the above error messages I think.
There was a problem hiding this comment.
Yes, debug level is appropriate.
| uint32_t consumed_len = init_len - buffer.length(); | ||
| // The tail might contain info base on cap flag and status flag, but just consume all | ||
| if (BufferHelper::readStringBySize(buffer, len - consumed_len, info_) != DecodeStatus::Success) { | ||
| ENVOY_LOG(info, "error parsing info of ok msg"); |
Signed-off-by: qinggniq <[email protected]>
|
Thanks very much for your patient review @cpakulski. could you help merge it? |
Signed-off-by: qinggniq <[email protected]> doc: add mysql filter doc Signed-off-by: qinggniq <[email protected]> format Signed-off-by: qinggniq <[email protected]>
Signed-off-by: qinggniq <[email protected]>
| mysql.egress_mysql.protocol_errors: 0 | ||
| mysql.egress_mysql.queries_parse_error: 0 | ||
| mysql.egress_mysql.protocol_errors: 21 | ||
| mysql.egress_mysql.queries_parse_error: 2 |
There was a problem hiding this comment.
If you felt surprise for mysql.egress_mysql.protocol_errors: 21, ref this issue #14975.
There was a problem hiding this comment.
Yeah, IMHO the filter should not be stateful and check expected seq. It should just do parsing.
It was already reported here: #12868. I tried to look at that and thought that filter should not track seq numbers.
|
ping @cpakulski @dio |
|
@lizan. This PR LGTM. Can you take it over and merge it if you are ok with the changes? Thanks. |
Signed-off-by: qinggniq [email protected]
For an explanation of how to fill out the fields, please see the relevant section
in PULL_REQUESTS.md
Commit Message: Complete MySQL MySQL Proxy Codec. Fixed #14809
Additional Description: Now MySQL Proxy Codec can fully support MySQL Protocol
Risk Level: Low
Testing: unit test
Docs Changes: N/A
Release Notes: improve mysql proxy codec
Platform Specific Features:
[Optional Runtime guard:]
[Optional Fixes #Issue] #14809
[Optional Deprecated:]
[Optional API Considerations:]