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

dubbo_proxy: Adds a routing matcher for the Dubbo protocol. #5571

Merged
merged 9 commits into from
Jan 23, 2019

Conversation

gengleilei
Copy link
Contributor

Description: Adds a routing matcher for the Dubbo protocol.
Risk Level: low
Testing: unit test
Docs Changes: N/A
Release Notes: N/A
[Optional Fixes #Issue] #3998
[Optional Deprecated:]

this is only part of the code for DubboProxy, the rest of the code hasn't been committed yet, complete implementation: https://github.com/gengleilei/envoy/tree/feature-dubbo-router-develop/source/extensions/filters/network/dubbo_proxy

@gengleilei gengleilei requested a review from lizan as a code owner January 11, 2019 08:33
@lizan lizan requested a review from zyfjeff January 11, 2019 08:39
@lizan lizan self-assigned this Jan 11, 2019

// A list of individual Dubbo filters that make up the filter chain for requests made to the
// Dubbo proxy. Order matters as the filters are processed sequentially. For backwards
// compatibility, if no thrift_filters are specified, a default Dubbo router filter
Copy link
Member

Choose a reason for hiding this comment

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

thrift -> dubbo

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

// * For range [-10,0), route will match for header value -1, but not for 0,
// "somestring", 10.9,
// "-1somestring"
envoy.type.Int64Range range_match = 4;
Copy link
Member

Choose a reason for hiding this comment

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

If the type of the parameter is not an integer, is this range matching useful?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, The type definition is not needed. I delete it.

syntax = "proto3";

package envoy.config.filter.network.dubbo_proxy.v2alpha1;
option java_package = "io.envoyproxy.envoy.config.filter.network.thrift_proxy.v2alpha1";
Copy link
Member

Choose a reason for hiding this comment

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

Remove

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

package envoy.extensions.filters.network.dubbo_proxy.v2alpha1;
option java_package = "io.envoyproxy.envoy.extensions.filters.network.dubbo_proxy.v2alpha1";
package envoy.config.filter.network.dubbo_proxy.v2alpha1;
option java_package = "io.envoyproxy.envoy.config.filter.network.thrift_proxy.v2alpha1";
Copy link
Member

Choose a reason for hiding this comment

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

Remove

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

namespace Router {

bool Utility::isContainWildcard(const std::string& input) {
return (input.find('*') != std::string::npos) || (input.find('?') != std::string::npos);
Copy link
Member

Choose a reason for hiding this comment

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

https://en.wikipedia.org/wiki/Glob_(programming)
Do you want to support the full wildcard? or you just want to support the * and ? ?, I suggest that it is the same as the virtual host, only * is supported.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Dubbo routing matches need to support wildcard * and ?.

const envoy::config::filter::network::dubbo_proxy::v2alpha1::Route& route)
: cluster_name_(route.route().cluster()) {
for (const auto& header_map : route.match().headers()) {
config_headers_.push_back(header_map);
Copy link
Member

Choose a reason for hiding this comment

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

emplace_back ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

namespace DubboProxy {
namespace Router {

class Utility {
Copy link
Member

Choose a reason for hiding this comment

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

I prefer using an anonymous namespace

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 have moved utility class to utiliti.h file.

public Logger::Loggable<Logger::Id::dubbo> {
public:
RouteEntryImplBase(const envoy::config::filter::network::dubbo_proxy::v2alpha1::Route& route);
virtual ~RouteEntryImplBase() {}
Copy link
Member

Choose a reason for hiding this comment

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

= default

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done


ParameterRouteEntryImpl::ParameterData::ParameterData(const ParameterConfig& config) {
index_ = config.index();
type_ = config.type();
Copy link
Member

Choose a reason for hiding this comment

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

Where is it used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

type_ is useless. I deleted it.

RouteConstSharedPtr MultiRouteMatcher::route(const MessageMetadata& metadata,
uint64_t random_value) const {
for (const auto& route_matcher : route_matcher_list_) {
ENVOY_LOG(debug, "dubbo route matcher: route matching failed");
Copy link
Member

Choose a reason for hiding this comment

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

route matching failed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry,i delete it.


RouteConstSharedPtr RouteMatcher::route(const MessageMetadata& metadata,
uint64_t random_value) const {
if (interface_name_ == metadata.service_name() &&
Copy link
Member

Choose a reason for hiding this comment

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

Can interface_name and service_name be unified?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It has been uniformly named service name.

zyfjeff
zyfjeff previously approved these changes Jan 15, 2019
Copy link
Member

@zyfjeff zyfjeff left a comment

Choose a reason for hiding this comment

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

LGTM, just some nits.

@lizan
I passed the first round of review

@gengleilei
Copy link
Contributor Author

/retest

@repokitteh-read-only
Copy link

🔨 rebuilding ci/circleci: tsan (failed build)

🐱

Caused by: a #5571 (comment) was created by @gengleilei.

see: more, trace.

@gengleilei
Copy link
Contributor Author

@lizan Is there any other code review opinion ?

Copy link
Member

@lizan lizan left a comment

Choose a reason for hiding this comment

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

Sorry for the delay.

Copy link
Member

@lizan lizan left a comment

Choose a reason for hiding this comment

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

Great, sorry for the confusion

using envoy::config::filter::network::dubbo_proxy::v2alpha1::RouteMatch;

// Verify configuration rules.
MessageUtil::validate(config);
Copy link
Member

Choose a reason for hiding this comment

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

Ah sorry I misunderstood so ignore my previous comment, you don't need this...


private:
const Matchers::StringMatcher method_name_;
absl::optional<std::shared_ptr<ParameterRouteEntryImpl>> parameter_route_;
Copy link
Member

Choose a reason for hiding this comment

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

do you need to differentiate nullopt vs nullptr? If no simple shared_ptr should be enough.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@gengleilei
Copy link
Contributor Author

@lizan Is there any other code review opinion ?

Copy link
Member

@lizan lizan left a comment

Choose a reason for hiding this comment

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

LGTM


package envoy.config.filter.network.dubbo_proxy.v2alpha1;
option java_package = "io.envoyproxy.envoy.config.filter.network.dubbo_proxy.v2alpha1";
option java_multiple_files = true;
Copy link
Member

Choose a reason for hiding this comment

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

can you merge master? I think this line is no longer needed (will fail master CI)

Signed-off-by: leilei.gll <leilei.gll@alibaba-inc.com>
Signed-off-by: leilei.gll <leilei.gll@alibaba-inc.com>
Signed-off-by: leilei.gll <leilei.gll@alibaba-inc.com>
Signed-off-by: leilei.gll <leilei.gll@alibaba-inc.com>
Signed-off-by: leilei.gll <leilei.gll@alibaba-inc.com>
Signed-off-by: leilei.gll <leilei.gll@alibaba-inc.com>
… utility class.

Signed-off-by: leilei.gll <leilei.gll@alibaba-inc.com>
Signed-off-by: leilei.gll <leilei.gll@alibaba-inc.com>
@gengleilei gengleilei force-pushed the feature-dubbo-router-ex branch from 33ae24e to bbe4d86 Compare January 23, 2019 11:43
Signed-off-by: leilei.gll <leilei.gll@alibaba-inc.com>
Copy link
Member

@lizan lizan left a comment

Choose a reason for hiding this comment

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

@gengleilei in the future, please do not rebase and force-push, instead you can merge master. force-push will make it harder to follow review history.

@lizan lizan merged commit 57b1982 into envoyproxy:master Jan 23, 2019
@gengleilei
Copy link
Contributor Author

@lizan Ok, thank you for reminder.

danzh2010 pushed a commit to danzh2010/envoy that referenced this pull request Jan 24, 2019
…xy#5571)

*Description*: Adds a routing matcher for the Dubbo protocol. envoyproxy#3998
*Risk Level*: low
*Testing*: unit test
*Docs Changes*: N/A
*Release Notes*: N/A

this is only part of the code for DubboProxy, the rest of the code hasn't been committed yet, complete implementation: https://github.com/gengleilei/envoy/tree/feature-dubbo-router-develop/source/extensions/filters/network/dubbo_proxy

Signed-off-by: leilei.gll <leilei.gll@alibaba-inc.com>

Signed-off-by: Dan Zhang <danzh@google.com>
@gengleilei gengleilei deleted the feature-dubbo-router-ex branch January 29, 2019 07:31
danzh2010 pushed a commit to danzh2010/envoy that referenced this pull request Jan 31, 2019
…xy#5571)

*Description*: Adds a routing matcher for the Dubbo protocol. envoyproxy#3998
*Risk Level*: low
*Testing*: unit test
*Docs Changes*: N/A
*Release Notes*: N/A

this is only part of the code for DubboProxy, the rest of the code hasn't been committed yet, complete implementation: https://github.com/gengleilei/envoy/tree/feature-dubbo-router-develop/source/extensions/filters/network/dubbo_proxy

Signed-off-by: leilei.gll <leilei.gll@alibaba-inc.com>
fredlas pushed a commit to fredlas/envoy that referenced this pull request Mar 5, 2019
…xy#5571)

*Description*: Adds a routing matcher for the Dubbo protocol. envoyproxy#3998
*Risk Level*: low
*Testing*: unit test
*Docs Changes*: N/A
*Release Notes*: N/A

this is only part of the code for DubboProxy, the rest of the code hasn't been committed yet, complete implementation: https://github.com/gengleilei/envoy/tree/feature-dubbo-router-develop/source/extensions/filters/network/dubbo_proxy

Signed-off-by: leilei.gll <leilei.gll@alibaba-inc.com>
Signed-off-by: Fred Douglas <fredlas@google.com>
// Dubbo proxy. Order matters as the filters are processed sequentially. For backwards
// compatibility, if no dubbo_filters are specified, a default Dubbo router filter
// (`envoy.filters.dubbo.router`) is used.
repeated DubboFilter dubbo_filters = 5;
Copy link
Contributor

Choose a reason for hiding this comment

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

@gengleilei I am new to dubbo, my question is how to setup individual Dubbo filters?

I can not find any other supported filters except envoy.filters.dubbo.router .

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You can refer to the Router (router_impl.h), you need to implement DubboFilters: : DecoderFilter interface, yaml configuration is as follows:
stat_prefix: ingress
route_config:
name: local_route
dubbo_filters:
- name: envoy.filters.dubbo.mock_filter
config:
"@type": type.googleapis.com/google.protobuf.Struct
value:
name: test_service

Copy link
Contributor

Choose a reason for hiding this comment

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

IC, this is for advanced users, need to hack into the envoy code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The Filter based extension mechanism is similar to HTTP. Dubbo does not define a unique Filter mechanism. of course, if you have good suggestions, we are also very welcome to build together.

Copy link
Contributor

Choose a reason for hiding this comment

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

I got this error, any idea?

[2019-08-06 02:35:19.872][27][error][dubbo] [external/envoy/source/extensions/filters/network/dubbo_proxy/conn_manager.cc:132] [C35] dubbo error: invalid dubbo mes
sage magic number 20186

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.

4 participants