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

V2 to v3 fragment #11213

Merged
merged 11 commits into from
Jul 6, 2020
Merged

V2 to v3 fragment #11213

merged 11 commits into from
Jul 6, 2020

Conversation

ankatare
Copy link
Contributor

For an explanation of how to fill out the fields, please see the relevant section
in PULL_REQUESTS.md

Commit Message: fragment changes from v2 to v3 API
Additional Description:
Risk Level:Low
Testing: integration and format testing
Docs Changes:
Release Notes:
[Optional Runtime guard:]
[Optional Fixes #10843
[Optional Deprecated:]

Copy link
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

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

Thanks for this major cleanup. The main thing I think we should do before shipping is ensuring that the parseFooFromV3Yaml rejects v2 configs.
/wait

test/common/upstream/cluster_manager_impl_test.cc Outdated Show resolved Hide resolved
test/common/upstream/utility.h Outdated Show resolved Hide resolved
@ankatare
Copy link
Contributor Author

@htuch Thanks for your review comments. I will update code as per your suggestion. Would be helpful if you could provide some code ref for the same.

@htuch
Copy link
Member

htuch commented May 20, 2020

@ankatare you want to invoke MessageUtil::loadFromYaml with do_boosting set to false.

@ankatare
Copy link
Contributor Author

@htuch ok, I will do that. Thanks for Help !!!

@ankatare
Copy link
Contributor Author

@htuch : please see possible code changes and it's implications.

File: test/test_common/utility.h
Function Change:
static void loadFromYaml(const std::string& yaml, Protobuf::Message& message,
bool preserve_original_type = false) {
MessageUtil::loadFromYaml(yaml, message, ProtobufMessage::getStrictValidationVisitor(),false);
if (!preserve_original_type) {
Config::VersionConverter::eraseOriginalTypeInformation(message);
}
}

Implications : Almost every test cases under test/.. will be affected due to this change and will be required some rework.

Please suggest if it is good to go. .

@htuch
Copy link
Member

htuch commented May 27, 2020

@ankatare why did you go with type erasure vs. avoiding boosting in the first place?

@ankatare
Copy link
Contributor Author

@htuch thanks for your quick comments.
Do you means to set "avoid do_boosting" from inside
function : MessageUtil::loadFromYam () {}. as i see execution of actual logic is happening inside MessageUtil::loadFromJson () {}

@htuch
Copy link
Member

htuch commented May 29, 2020

@ankatare see

bool do_boosting = true);
, the ability to control do_boosting already exists. I think this should be plumbed through to the test wrappers.

@ankatare
Copy link
Contributor Author

@htuch Thanks for comments. I will get back as soon as possible

@ankatare
Copy link
Contributor Author

ankatare commented Jun 3, 2020

@htuch Hi, functionality of do_boosting is already implemented in https://github.com/envoyproxy/envoy/blob/master/source/common/protobuf/utility.h#L222.
In my opinion i just need to set value of do_boosting to false (to avoid boosting) here and use in the test codes ... seems it was written to boost V2 config etc. Please let me know if my understanding is not correct here.

@htuch
Copy link
Member

htuch commented Jun 4, 2020

@ankatare yes, when you want to force it to parse as v2, you need to set do_boosting to false.

@ankatare
Copy link
Contributor Author

ankatare commented Jun 8, 2020

@htuch while applying avoid-boosting ( do_boosting = false ) in test code, 2 test cases are failing. (remaining are ok)
it seems for both to get passed boosting is required.
they are below test cases
https://github.com/envoyproxy/envoy/blob/master/test/common/upstream/cluster_manager_impl_test.cc#L419
and
https://github.com/envoyproxy/envoy/blob/master/test/common/upstream/cluster_manager_impl_test.cc#L539
please suggest way forward to proceed as we can't change exception output ?

@ankatare
Copy link
Contributor Author

ankatare commented Jun 8, 2020

@htuch or suggest from whom to take help.

@htuch
Copy link
Member

htuch commented Jun 9, 2020

@ankatare are you trying to treat these examples as v2 or v3?

@ankatare
Copy link
Contributor Author

ankatare commented Jun 9, 2020

@htuch Thanks for your response.
seems, these test cases using v3 config only.

@htuch
Copy link
Member

htuch commented Jun 9, 2020

@ankatare and you are saying that when you parse them as v3, with do_boosting = false, this fails?

@ankatare
Copy link
Contributor Author

@htuch yes.

@htuch
Copy link
Member

htuch commented Jun 10, 2020

You might want to run the test with --test_arg="-l trace" and see if there is some useful debug message. It should definitely be possible to parse v3 config as v3 without any boosting.

@ankatare
Copy link
Contributor Author

@htuch ok. Let me check. Will get back ASAP

@ankatare
Copy link
Contributor Author

@htuch see debug logs for
https://github.com/envoyproxy/envoy/blob/master/test/common/upstream/cluster_manager_impl_test.cc#L419
test/common/upstream/cluster_manager_impl_test.cc:397: Failure
Value of: std::string(e.what())
Expected: is equal to 0x25cf98 pointing to "cluster: LB policy hidden_envoy_deprecated_ORIGINAL_DST_LB is not valid for Cluster type STATIC. 'ORIGINAL_DST_LB' is allowed only with cluster type 'ORIGINAL_DST'"
Actual: "Protobuf message (type envoy.config.bootstrap.v3.Bootstrap reason INVALID_ARGUMENT:(static_resources.clusters[0].lb_policy): invalid value "original_dst_lb" for type TYPE_ENUM) has unknown fields"
Stack trace:
0x15b9dd1: Envoy::Upstream::(anonymous namespace)::ClusterManagerImplTest_OriginalDstLbRestriction2_Test::TestBody()
0x3816404: testing::internal::HandleSehExceptionsInMethodIfSupported<>()
0x38079be: testing::internal::HandleExceptionsInMethodIfSupported<>()
0x37f1c13: testing::Test::Run()
0x37f27fd: testing::TestInfo::Run()
... Google Test internal frames ...

[ FAILED ] ClusterManagerImplTest.OriginalDstLbRestriction2 (201 ms)

@ankatare
Copy link
Contributor Author

@htuch following code is executing. i checked with debug output
https://github.com/envoyproxy/envoy/blob/master/source/common/protobuf/utility.cc#L310

@htuch
Copy link
Member

htuch commented Jun 10, 2020

@ankatare that is v2 config if it's using ORIGINAL_DST_LB, which was deprecated. Should this be a fragment you hand convert to v3?

@ankatare
Copy link
Contributor Author

@htuch yeah, while looking at this particular field it seems V2 config and it is deprecated as per doc https://www.envoyproxy.io/docs/envoy/latest/api-v2/api/v2/cluster.proto#envoy-api-enum-cluster-lbpolicy.
and suggest to use "cluster_provided" as a value for lb_policy in V3.
but i have not modified it, as this particular test code is meant for original_dst_lb only for type static. ( looking at exception o/p )
please guide me as i am bit confused here :(

@htuch
Copy link
Member

htuch commented Jun 10, 2020

In this case, I think we should allow boosting, as the EXPECT_THROW is trying to show end-to-end what is expected. So, this is basically parse v2 with explicit boosting.

@ankatare
Copy link
Contributor Author

@htuch Thanks a lot for this help. I will update code and get back ASAP.

Signed-off-by: Abhay Narayan Katare <[email protected]>
Signed-off-by: Abhay Narayan Katare <[email protected]>
@ankatare
Copy link
Contributor Author

ankatare commented Jul 1, 2020

@htuch need help to understand this build error , things were fine in my local env. i posted this issue in envoy-ci channel as well.

@ankatare
Copy link
Contributor Author

ankatare commented Jul 1, 2020

@htuch please review changes. i incorporated all of your comments.

Copy link
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

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

Thanks. Looks like good progress in some places, but I think we need to have:

  • Most of the v2 fragments updated to v3 (except for the deprecated feature tests).
  • Not set avoid_boosting in most place (except for the deprecated features tests).
    /wait

@ankatare
Copy link
Contributor Author

ankatare commented Jul 1, 2020

@htuch for some of the test cases i need to allow do_boosting (even they are not DEPRECATED) as the EXPECT_THROW is trying to show end-to-end what is expected. So, this is basically parse v2 with explicit boosting. same we discussed above.

@ankatare
Copy link
Contributor Author

ankatare commented Jul 1, 2020

image

@ankatare
Copy link
Contributor Author

ankatare commented Jul 1, 2020

@htuch for this comments i would say yes, it is a default parameter as false for loadFromYamlAndValidate . Since i needed to parse avoid_boosting as 4th parameter in function argument.

image

@ankatare
Copy link
Contributor Author

ankatare commented Jul 1, 2020

@htuch for this case, to get it pass i just modified function arguments llist as in the another test cases i modified testutil::loadFromYamlAndValidate and it was calling it internally. so i am planning to change name one by one. after code is merged please suggest.
image

Copy link
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

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

Looks good. One thing I'm curious about is we see almost no changes to the config; does this mean our config examples are v3 safe for the most part? @adisuissa was this basically what you also observed?

test/test_common/utility.h Outdated Show resolved Hide resolved
@ankatare
Copy link
Contributor Author

ankatare commented Jul 1, 2020

@htuch thanks a lot for all your time on review my code.

@htuch
Copy link
Member

htuch commented Jul 1, 2020

@ankatare no worries; where possible, can you reply using GitHub threads BTW? It's hard to follow conversations with screenshot (although my Slack conversations are fair game for screenshotting ;-) )

@ankatare
Copy link
Contributor Author

ankatare commented Jul 1, 2020

@htuch really sorry and it is my bad. somehow i am not seeing reply on your individual inputs in my window. it's only a button of "resolve conversation".
i don't know how to enable option, please help.

@adisuissa
Copy link
Contributor

Looks good. One thing I'm curious about is we see almost no changes to the config; does this mean our config examples are v3 safe for the most part? @adisuissa was this basically what you also observed?

Most configs were either v3 or v2+upgrade safe.

@ankatare
Copy link
Contributor Author

ankatare commented Jul 2, 2020

@htuch @adisuissa : thanks for your review comments, i will get back ASAP.

@ankatare ankatare force-pushed the v2_to_v3_fragment branch from 109f9f4 to c3608d2 Compare July 4, 2020 10:49
@ankatare
Copy link
Contributor Author

ankatare commented Jul 4, 2020

@htuch incorporated review comments. thanks for your time to review it.

@ankatare
Copy link
Contributor Author

ankatare commented Jul 4, 2020

@adisuissa incorporated review comments. thanks for your time to review it.

Copy link
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

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

LGTM, thanks! As discussed offline, @ankatare will work on some of the test cases I had questions around in the next PR.

@htuch htuch merged commit e73738f into envoyproxy:master Jul 6, 2020
@ankatare ankatare deleted the v2_to_v3_fragment branch July 14, 2020 06:19
scheler pushed a commit to scheler/envoy that referenced this pull request Aug 4, 2020
Risk Level:Low
Testing: integration and format testing

Part of envoyproxy#10843

Signed-off-by: Abhay Narayan Katare <[email protected]>
Signed-off-by: scheler <[email protected]>
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.

Convert v2 API test fragments to v3
3 participants