From 2f68fd3c2e79b5d0b6be199c732e5d161d00d8fd Mon Sep 17 00:00:00 2001 From: "data-plane-api(Azure Pipelines)" Date: Fri, 24 Mar 2023 08:06:50 +0000 Subject: [PATCH] golang extension: implement cluster_specifier_plugin to choose cluster dynamically (#25677) * wip: cluster specifier. Signed-off-by: doujiang24 * goland happy. Signed-off-by: doujiang24 * go module build ok. Signed-off-by: doujiang24 * resue the utils module. Signed-off-by: doujiang24 * golang filter test ok. Signed-off-by: doujiang24 * wip: C++ not compile ok yet. Signed-off-by: doujiang24 * c++ compile ok. Signed-off-by: doujiang24 * simple work. Signed-off-by: doujiang24 * change go.mod. Signed-off-by: doujiang24 * http filters test passed. Signed-off-by: doujiang24 * prepare cluster test. Signed-off-by: doujiang24 * cluster specifier test. Signed-off-by: doujiang24 * cluster specifier: make the headermap API simple. Signed-off-by: doujiang24 * test compile. Signed-off-by: doujiang24 * code tweak. Signed-off-by: doujiang24 * configFactory. Signed-off-by: doujiang24 * compile ok. Signed-off-by: doujiang24 * test: default_cluster. Signed-off-by: doujiang24 * tweak. Signed-off-by: doujiang24 * recover panic. Signed-off-by: doujiang24 * validator plugin_id from golang. Signed-off-by: doujiang24 * fix format. Signed-off-by: doujiang24 * make deps simplier. Signed-off-by: doujiang24 * tweak proto comments. Signed-off-by: doujiang24 * update go.mod. Signed-off-by: doujiang24 * format tweak. Signed-off-by: doujiang24 * add metadata. Signed-off-by: doujiang24 * add extenstion categories. Signed-off-by: doujiang24 * add doc. Signed-off-by: doujiang24 * doc cluster_specifier. Signed-off-by: doujiang24 * doc: extension category Signed-off-by: doujiang24 * used registry in Go filter plugin. Signed-off-by: doujiang24 * update deps. Signed-off-by: doujiang24 * upgrade golang/x/* version. Signed-off-by: doujiang24 * fix dso test. Signed-off-by: doujiang24 * revert change in examples/grpc-bridge/server/go.mod. Signed-off-by: doujiang24 * address comments. Signed-off-by: doujiang24 * style fix: NOLINT(readability-identifier-naming) Signed-off-by: doujiang24 * remove unused function. Signed-off-by: doujiang24 * clang code style fix. Signed-off-by: doujiang24 * address comments. Signed-off-by: doujiang24 * refactor dso load and Go API regsitry. Signed-off-by: doujiang24 * rename http/cluster_specifier => router/cluster_specifier. Signed-off-by: doujiang24 * address comments. Signed-off-by: doujiang24 * protected => private. Signed-off-by: doujiang24 * works. Signed-off-by: doujiang24 * fix format. Signed-off-by: doujiang24 * fix clang tidy. Signed-off-by: doujiang24 * address comments. Signed-off-by: doujiang24 * fix format. Signed-off-by: doujiang24 --------- Signed-off-by: doujiang24 Mirrored from https://github.com/envoyproxy/envoy @ 3c7612f595f67fd8905e172129b09d5dce66a89a --- BUILD | 1 + .../cluster_specifier/golang/v3alpha/BUILD | 12 +++++ .../golang/v3alpha/golang.proto | 51 +++++++++++++++++++ versioning/BUILD | 1 + 4 files changed, 65 insertions(+) create mode 100644 contrib/envoy/extensions/router/cluster_specifier/golang/v3alpha/BUILD create mode 100644 contrib/envoy/extensions/router/cluster_specifier/golang/v3alpha/golang.proto diff --git a/BUILD b/BUILD index 8786b5d7..c9d53165 100644 --- a/BUILD +++ b/BUILD @@ -96,6 +96,7 @@ proto_library( "//contrib/envoy/extensions/private_key_providers/cryptomb/v3alpha:pkg", "//contrib/envoy/extensions/private_key_providers/qat/v3alpha:pkg", "//contrib/envoy/extensions/regex_engines/hyperscan/v3alpha:pkg", + "//contrib/envoy/extensions/router/cluster_specifier/golang/v3alpha:pkg", "//contrib/envoy/extensions/vcl/v3alpha:pkg", "//envoy/admin/v3:pkg", "//envoy/config/accesslog/v3:pkg", diff --git a/contrib/envoy/extensions/router/cluster_specifier/golang/v3alpha/BUILD b/contrib/envoy/extensions/router/cluster_specifier/golang/v3alpha/BUILD new file mode 100644 index 00000000..ec1e778e --- /dev/null +++ b/contrib/envoy/extensions/router/cluster_specifier/golang/v3alpha/BUILD @@ -0,0 +1,12 @@ +# DO NOT EDIT. This file is generated by tools/proto_format/proto_sync.py. + +load("@envoy_api//bazel:api_build_system.bzl", "api_proto_package") + +licenses(["notice"]) # Apache 2 + +api_proto_package( + deps = [ + "@com_github_cncf_udpa//udpa/annotations:pkg", + "@com_github_cncf_udpa//xds/annotations/v3:pkg", + ], +) diff --git a/contrib/envoy/extensions/router/cluster_specifier/golang/v3alpha/golang.proto b/contrib/envoy/extensions/router/cluster_specifier/golang/v3alpha/golang.proto new file mode 100644 index 00000000..f22685af --- /dev/null +++ b/contrib/envoy/extensions/router/cluster_specifier/golang/v3alpha/golang.proto @@ -0,0 +1,51 @@ +syntax = "proto3"; + +package envoy.extensions.router.cluster_specifier.golang.v3alpha; + +import "google/protobuf/any.proto"; + +import "xds/annotations/v3/status.proto"; + +import "udpa/annotations/status.proto"; +import "validate/validate.proto"; + +option java_package = "io.envoyproxy.envoy.extensions.router.cluster_specifier.golang.v3alpha"; +option java_outer_classname = "GolangProto"; +option java_multiple_files = true; +option go_package = "github.com/envoyproxy/go-control-plane/envoy/extensions/router/cluster_specifier/golang/v3alpha"; +option (udpa.annotations.file_status).package_version_status = ACTIVE; +option (xds.annotations.v3.file_status).work_in_progress = true; + +// [#protodoc-title: Golang] +// +// For an overview of the Golang cluster specifier please see the :ref:`configuration reference documentation `. +// [#extension: envoy.router.cluster_specifier_plugin.golang] + +// [#extension-category: envoy.router.cluster_specifier_plugin] +message Config { + // Globally unique ID for a dynamic library file. + string library_id = 1 [(validate.rules).string = {min_len: 1}]; + + // Path to a dynamic library implementing the + // :repo:`ClusterSpecifier API ` + // interface. + // [#comment:TODO(wangfakang): Support for downloading libraries from remote repositories.] + string library_path = 2 [(validate.rules).string = {min_len: 1}]; + + // Default cluster. + // + // It will be used when the specifier interface return empty string or panic. + // + string default_cluster = 3 [(validate.rules).string = {min_len: 1}]; + + // Configuration for the Go cluster specifier plugin. + // + // .. note:: + // This configuration is only parsed in the go cluster specifier, and is therefore not validated + // by Envoy. + // + // See the :repo:`StreamFilter API ` + // for more information about how the plugin's configuration data can be accessed. + // + google.protobuf.Any config = 4; +} diff --git a/versioning/BUILD b/versioning/BUILD index 309506ce..651b30d2 100644 --- a/versioning/BUILD +++ b/versioning/BUILD @@ -34,6 +34,7 @@ proto_library( "//contrib/envoy/extensions/private_key_providers/cryptomb/v3alpha:pkg", "//contrib/envoy/extensions/private_key_providers/qat/v3alpha:pkg", "//contrib/envoy/extensions/regex_engines/hyperscan/v3alpha:pkg", + "//contrib/envoy/extensions/router/cluster_specifier/golang/v3alpha:pkg", "//contrib/envoy/extensions/vcl/v3alpha:pkg", "//envoy/admin/v3:pkg", "//envoy/config/accesslog/v3:pkg",