Skip to content

Commit 0bd670a

Browse files
authored
bug fix: return bootstrap when validating config (envoyproxy#17499)
Signed-off-by: qinggniq <livewithblank@gmail.com>
1 parent 0d2418e commit 0bd670a

File tree

5 files changed

+103
-10
lines changed

5 files changed

+103
-10
lines changed

source/server/config_validation/server.cc

+8-9
Original file line numberDiff line numberDiff line change
@@ -78,22 +78,21 @@ void ValidationInstance::initialize(const Options& options,
7878
// If we get all the way through that stripped-down initialization flow, to the point where we'd
7979
// be ready to serve, then the config has passed validation.
8080
// Handle configuration that needs to take place prior to the main configuration load.
81-
envoy::config::bootstrap::v3::Bootstrap bootstrap;
82-
InstanceUtil::loadBootstrapConfig(bootstrap, options,
81+
InstanceUtil::loadBootstrapConfig(bootstrap_, options,
8382
messageValidationContext().staticValidationVisitor(), *api_);
8483

85-
Config::Utility::createTagProducer(bootstrap);
86-
bootstrap.mutable_node()->set_hidden_envoy_deprecated_build_version(VersionInfo::version());
84+
Config::Utility::createTagProducer(bootstrap_);
85+
bootstrap_.mutable_node()->set_hidden_envoy_deprecated_build_version(VersionInfo::version());
8786

8887
local_info_ = std::make_unique<LocalInfo::LocalInfoImpl>(
89-
stats().symbolTable(), bootstrap.node(), bootstrap.node_context_params(), local_address,
88+
stats().symbolTable(), bootstrap_.node(), bootstrap_.node_context_params(), local_address,
9089
options.serviceZone(), options.serviceClusterName(), options.serviceNodeName());
9190

9291
overload_manager_ = std::make_unique<OverloadManagerImpl>(
93-
dispatcher(), stats(), threadLocal(), bootstrap.overload_manager(),
92+
dispatcher(), stats(), threadLocal(), bootstrap_.overload_manager(),
9493
messageValidationContext().staticValidationVisitor(), *api_, options_);
95-
Configuration::InitialImpl initial_config(bootstrap, options);
96-
initial_config.initAdminAccessLog(bootstrap, *this);
94+
Configuration::InitialImpl initial_config(bootstrap_, options);
95+
initial_config.initAdminAccessLog(bootstrap_, *this);
9796
admin_ = std::make_unique<Server::ValidationAdmin>(initial_config.admin().address());
9897
listener_manager_ =
9998
std::make_unique<ListenerManagerImpl>(*this, *this, *this, false, quic_stat_names_);
@@ -107,7 +106,7 @@ void ValidationInstance::initialize(const Options& options,
107106
localInfo(), *secret_manager_, messageValidationContext(), *api_, http_context_,
108107
grpc_context_, router_context_, accessLogManager(), singletonManager(), options,
109108
quic_stat_names_);
110-
config_.initialize(bootstrap, *this, *cluster_manager_factory_);
109+
config_.initialize(bootstrap_, *this, *cluster_manager_factory_);
111110
runtime().initialize(clusterManager());
112111
clusterManager().setInitializedCb([this]() -> void { init_manager_.initialize(init_watcher_); });
113112
}

source/server/config_validation/server.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ class ValidationInstance final : Logger::Loggable<Logger::Id::main>,
112112
bool enableReusePortDefault() override { return true; }
113113

114114
Configuration::StatsConfig& statsConfig() override { return config_.statsConfig(); }
115-
envoy::config::bootstrap::v3::Bootstrap& bootstrap() override { NOT_IMPLEMENTED_GCOVR_EXCL_LINE; }
115+
envoy::config::bootstrap::v3::Bootstrap& bootstrap() override { return bootstrap_; }
116116
Configuration::ServerFactoryContext& serverFactoryContext() override { return server_contexts_; }
117117
Configuration::TransportSocketFactoryContext& transportSocketFactoryContext() override {
118118
return server_contexts_;
@@ -199,6 +199,7 @@ class ValidationInstance final : Logger::Loggable<Logger::Id::main>,
199199
Event::DispatcherPtr dispatcher_;
200200
std::unique_ptr<Server::ValidationAdmin> admin_;
201201
Singleton::ManagerPtr singleton_manager_;
202+
envoy::config::bootstrap::v3::Bootstrap bootstrap_;
202203
std::unique_ptr<Runtime::ScopedLoaderSingleton> runtime_singleton_;
203204
Random::RandomGeneratorImpl random_generator_;
204205
std::unique_ptr<Ssl::ContextManager> ssl_context_manager_;

test/extensions/filters/http/ext_authz/BUILD

+5
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,15 @@ envoy_extension_cc_test(
5656
envoy_extension_cc_test(
5757
name = "ext_authz_integration_test",
5858
srcs = ["ext_authz_integration_test.cc"],
59+
data = [
60+
"ext_authz.yaml",
61+
],
5962
extension_names = ["envoy.filters.http.ext_authz"],
6063
deps = [
6164
"//source/extensions/filters/http/ext_authz:config",
65+
"//source/server/config_validation:server_lib",
6266
"//test/integration:http_integration_lib",
67+
"//test/mocks/server:options_mocks",
6368
"//test/test_common:utility_lib",
6469
"@envoy_api//envoy/config/bootstrap/v3:pkg_cc_proto",
6570
"@envoy_api//envoy/config/listener/v3:pkg_cc_proto",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Regression test for https://github.com/envoyproxy/envoy/issues/17344
2+
static_resources:
3+
listeners:
4+
- address:
5+
socket_address:
6+
address: 0.0.0.0
7+
port_value: 8080
8+
filter_chains:
9+
- filters:
10+
- name: envoy.filters.network.http_connection_manager
11+
typed_config:
12+
"@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
13+
stat_prefix: ingress_http
14+
route_config:
15+
name: local_route
16+
virtual_hosts:
17+
- name: local_service
18+
domains: ["*"]
19+
routes:
20+
- match:
21+
prefix: "/"
22+
route:
23+
cluster: local_service
24+
http_filters:
25+
- name: envoy.ext_authz
26+
typed_config:
27+
"@type": type.googleapis.com/envoy.extensions.filters.http.ext_authz.v3.ExtAuthz
28+
failure_mode_allow: false
29+
transport_api_version: V3
30+
status_on_error:
31+
code: 503
32+
grpc_service:
33+
envoy_grpc:
34+
cluster_name: ext_authz-service
35+
timeout: 0.5s
36+
with_request_body:
37+
max_request_bytes: 10240
38+
allow_partial_message: true
39+
pack_as_bytes: false
40+
- name: envoy.filters.http.router
41+
typed_config: {}
42+
clusters:
43+
- name: local_service
44+
connect_timeout: 30s
45+
type: STRICT_DNS
46+
lb_policy: ROUND_ROBIN
47+
load_assignment:
48+
cluster_name: local_service
49+
endpoints:
50+
- lb_endpoints:
51+
- endpoint:
52+
address:
53+
socket_address:
54+
address: main
55+
port_value: 8080
56+
- name: ext_authz-service
57+
type: STRICT_DNS
58+
lb_policy: ROUND_ROBIN
59+
typed_extension_protocol_options:
60+
envoy.extensions.upstreams.http.v3.HttpProtocolOptions:
61+
"@type": type.googleapis.com/envoy.extensions.upstreams.http.v3.HttpProtocolOptions
62+
explicit_http_config:
63+
http2_protocol_options: {}
64+
load_assignment:
65+
cluster_name: ext_authz-service
66+
endpoints:
67+
- lb_endpoints:
68+
- endpoint:
69+
address:
70+
socket_address:
71+
address: opa
72+
port_value: 80
73+
admin:
74+
address:
75+
socket_address:
76+
address: 0.0.0.0
77+
port_value: 8081

test/extensions/filters/http/ext_authz/ext_authz_integration_test.cc

+11
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
#include "envoy/service/auth/v3/external_auth.pb.h"
55

66
#include "source/common/common/macros.h"
7+
#include "source/server/config_validation/server.h"
78

89
#include "test/common/grpc/grpc_client_integration.h"
910
#include "test/integration/http_integration.h"
11+
#include "test/mocks/server/options.h"
1012
#include "test/test_common/utility.h"
1113

1214
#include "absl/strings/str_format.h"
@@ -887,4 +889,13 @@ TEST_P(ExtAuthzGrpcIntegrationTest, GoogleAsyncClientCreation) {
887889
cleanup();
888890
}
889891

892+
// Regression test for https://github.com/envoyproxy/envoy/issues/17344
893+
TEST(ExtConfigValidateTest, Validate) {
894+
Server::TestComponentFactory component_factory;
895+
EXPECT_TRUE(validateConfig(testing::NiceMock<Server::MockOptions>(TestEnvironment::runfilesPath(
896+
"test/extensions/filters/http/ext_authz/ext_authz.yaml")),
897+
Network::Address::InstanceConstSharedPtr(), component_factory,
898+
Thread::threadFactoryForTest(), Filesystem::fileSystemForTest()));
899+
}
900+
890901
} // namespace Envoy

0 commit comments

Comments
 (0)