|
|
@ -26,8 +26,6 @@ |
|
|
|
#include "src/core/ext/xds/xds_certificate_provider.h" |
|
|
|
#include "src/core/ext/xds/xds_certificate_provider.h" |
|
|
|
#include "src/core/ext/xds/xds_channel_stack_modifier.h" |
|
|
|
#include "src/core/ext/xds/xds_channel_stack_modifier.h" |
|
|
|
#include "src/core/ext/xds/xds_client.h" |
|
|
|
#include "src/core/ext/xds/xds_client.h" |
|
|
|
#include "src/core/ext/xds/xds_listener.h" |
|
|
|
|
|
|
|
#include "src/core/ext/xds/xds_route_config.h" |
|
|
|
|
|
|
|
#include "src/core/ext/xds/xds_routing.h" |
|
|
|
#include "src/core/ext/xds/xds_routing.h" |
|
|
|
#include "src/core/lib/address_utils/sockaddr_utils.h" |
|
|
|
#include "src/core/lib/address_utils/sockaddr_utils.h" |
|
|
|
#include "src/core/lib/channel/channel_args.h" |
|
|
|
#include "src/core/lib/channel/channel_args.h" |
|
|
@ -88,7 +86,7 @@ class XdsServerConfigFetcher : public grpc_server_config_fetcher { |
|
|
|
// update received was a fatal error (resource does not exist), the server
|
|
|
|
// update received was a fatal error (resource does not exist), the server
|
|
|
|
// listener is made to stop listening.
|
|
|
|
// listener is made to stop listening.
|
|
|
|
class XdsServerConfigFetcher::ListenerWatcher |
|
|
|
class XdsServerConfigFetcher::ListenerWatcher |
|
|
|
: public XdsListenerResourceType::WatcherInterface { |
|
|
|
: public XdsClient::ListenerWatcherInterface { |
|
|
|
public: |
|
|
|
public: |
|
|
|
ListenerWatcher(RefCountedPtr<XdsClient> xds_client, |
|
|
|
ListenerWatcher(RefCountedPtr<XdsClient> xds_client, |
|
|
|
std::unique_ptr<grpc_server_config_fetcher::WatcherInterface> |
|
|
|
std::unique_ptr<grpc_server_config_fetcher::WatcherInterface> |
|
|
@ -219,7 +217,7 @@ class XdsServerConfigFetcher::ListenerWatcher::FilterChainMatchManager |
|
|
|
// with the latest updates and new connections do not need to wait for the RDS
|
|
|
|
// with the latest updates and new connections do not need to wait for the RDS
|
|
|
|
// resources to be fetched.
|
|
|
|
// resources to be fetched.
|
|
|
|
class XdsServerConfigFetcher::ListenerWatcher::FilterChainMatchManager:: |
|
|
|
class XdsServerConfigFetcher::ListenerWatcher::FilterChainMatchManager:: |
|
|
|
RouteConfigWatcher : public XdsRouteConfigResourceType::WatcherInterface { |
|
|
|
RouteConfigWatcher : public XdsClient::RouteConfigWatcherInterface { |
|
|
|
public: |
|
|
|
public: |
|
|
|
RouteConfigWatcher( |
|
|
|
RouteConfigWatcher( |
|
|
|
std::string resource_name, |
|
|
|
std::string resource_name, |
|
|
@ -383,7 +381,7 @@ class XdsServerConfigFetcher::ListenerWatcher::FilterChainMatchManager:: |
|
|
|
// DynamicXdsServerConfigSelectorProvider
|
|
|
|
// DynamicXdsServerConfigSelectorProvider
|
|
|
|
class XdsServerConfigFetcher::ListenerWatcher::FilterChainMatchManager:: |
|
|
|
class XdsServerConfigFetcher::ListenerWatcher::FilterChainMatchManager:: |
|
|
|
DynamicXdsServerConfigSelectorProvider::RouteConfigWatcher |
|
|
|
DynamicXdsServerConfigSelectorProvider::RouteConfigWatcher |
|
|
|
: public XdsRouteConfigResourceType::WatcherInterface { |
|
|
|
: public XdsClient::RouteConfigWatcherInterface { |
|
|
|
public: |
|
|
|
public: |
|
|
|
explicit RouteConfigWatcher( |
|
|
|
explicit RouteConfigWatcher( |
|
|
|
RefCountedPtr<DynamicXdsServerConfigSelectorProvider> parent) |
|
|
|
RefCountedPtr<DynamicXdsServerConfigSelectorProvider> parent) |
|
|
@ -420,8 +418,7 @@ void XdsServerConfigFetcher::StartWatch( |
|
|
|
xds_client_, std::move(watcher), serving_status_notifier_, |
|
|
|
xds_client_, std::move(watcher), serving_status_notifier_, |
|
|
|
listening_address); |
|
|
|
listening_address); |
|
|
|
auto* listener_watcher_ptr = listener_watcher.get(); |
|
|
|
auto* listener_watcher_ptr = listener_watcher.get(); |
|
|
|
XdsListenerResourceType::StartWatch( |
|
|
|
xds_client_->WatchListenerData( |
|
|
|
xds_client_.get(), |
|
|
|
|
|
|
|
absl::StrReplaceAll( |
|
|
|
absl::StrReplaceAll( |
|
|
|
xds_client_->bootstrap().server_listener_resource_name_template(), |
|
|
|
xds_client_->bootstrap().server_listener_resource_name_template(), |
|
|
|
{{"%s", listening_address}}), |
|
|
|
{{"%s", listening_address}}), |
|
|
@ -436,8 +433,7 @@ void XdsServerConfigFetcher::CancelWatch( |
|
|
|
auto it = listener_watchers_.find(watcher); |
|
|
|
auto it = listener_watchers_.find(watcher); |
|
|
|
if (it != listener_watchers_.end()) { |
|
|
|
if (it != listener_watchers_.end()) { |
|
|
|
// Cancel the watch on the listener before erasing
|
|
|
|
// Cancel the watch on the listener before erasing
|
|
|
|
XdsListenerResourceType::CancelWatch( |
|
|
|
xds_client_->CancelListenerDataWatch( |
|
|
|
xds_client_.get(), |
|
|
|
|
|
|
|
absl::StrReplaceAll( |
|
|
|
absl::StrReplaceAll( |
|
|
|
xds_client_->bootstrap().server_listener_resource_name_template(), |
|
|
|
xds_client_->bootstrap().server_listener_resource_name_template(), |
|
|
|
{{"%s", it->second->listening_address()}}), |
|
|
|
{{"%s", it->second->listening_address()}}), |
|
|
@ -622,8 +618,8 @@ void XdsServerConfigFetcher::ListenerWatcher::FilterChainMatchManager:: |
|
|
|
MakeRefCounted<RouteConfigWatcher>(resource_name, WeakRef()); |
|
|
|
MakeRefCounted<RouteConfigWatcher>(resource_name, WeakRef()); |
|
|
|
rds_map_.emplace(resource_name, RdsUpdateState{route_config_watcher.get(), |
|
|
|
rds_map_.emplace(resource_name, RdsUpdateState{route_config_watcher.get(), |
|
|
|
absl::nullopt}); |
|
|
|
absl::nullopt}); |
|
|
|
XdsRouteConfigResourceType::StartWatch(xds_client_.get(), resource_name, |
|
|
|
xds_client_->WatchRouteConfigData(resource_name, |
|
|
|
std::move(route_config_watcher)); |
|
|
|
std::move(route_config_watcher)); |
|
|
|
} |
|
|
|
} |
|
|
|
if (rds_resources_yet_to_fetch_ != 0) { |
|
|
|
if (rds_resources_yet_to_fetch_ != 0) { |
|
|
|
listener_watcher_ = std::move(listener_watcher); |
|
|
|
listener_watcher_ = std::move(listener_watcher); |
|
|
@ -642,8 +638,7 @@ void XdsServerConfigFetcher::ListenerWatcher::FilterChainMatchManager:: |
|
|
|
MutexLock lock(&mu_); |
|
|
|
MutexLock lock(&mu_); |
|
|
|
// Cancel the RDS watches to clear up the weak refs
|
|
|
|
// Cancel the RDS watches to clear up the weak refs
|
|
|
|
for (const auto& entry : rds_map_) { |
|
|
|
for (const auto& entry : rds_map_) { |
|
|
|
XdsRouteConfigResourceType::CancelWatch(xds_client_.get(), entry.first, |
|
|
|
xds_client_->CancelRouteConfigDataWatch(entry.first, entry.second.watcher, |
|
|
|
entry.second.watcher, |
|
|
|
|
|
|
|
false /* delay_unsubscription */); |
|
|
|
false /* delay_unsubscription */); |
|
|
|
} |
|
|
|
} |
|
|
|
// Also give up the ref on ListenerWatcher since it won't be needed anymore
|
|
|
|
// Also give up the ref on ListenerWatcher since it won't be needed anymore
|
|
|
@ -1164,8 +1159,8 @@ XdsServerConfigFetcher::ListenerWatcher::FilterChainMatchManager:: |
|
|
|
GPR_ASSERT(!resource_name_.empty()); |
|
|
|
GPR_ASSERT(!resource_name_.empty()); |
|
|
|
auto route_config_watcher = MakeRefCounted<RouteConfigWatcher>(Ref()); |
|
|
|
auto route_config_watcher = MakeRefCounted<RouteConfigWatcher>(Ref()); |
|
|
|
route_config_watcher_ = route_config_watcher.get(); |
|
|
|
route_config_watcher_ = route_config_watcher.get(); |
|
|
|
XdsRouteConfigResourceType::StartWatch(xds_client_.get(), resource_name_, |
|
|
|
xds_client_->WatchRouteConfigData(resource_name_, |
|
|
|
std::move(route_config_watcher)); |
|
|
|
std::move(route_config_watcher)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
absl::StatusOr<RefCountedPtr<ServerConfigSelector>> |
|
|
|
absl::StatusOr<RefCountedPtr<ServerConfigSelector>> |
|
|
@ -1189,8 +1184,7 @@ XdsServerConfigFetcher::ListenerWatcher::FilterChainMatchManager:: |
|
|
|
|
|
|
|
|
|
|
|
void XdsServerConfigFetcher::ListenerWatcher::FilterChainMatchManager:: |
|
|
|
void XdsServerConfigFetcher::ListenerWatcher::FilterChainMatchManager:: |
|
|
|
DynamicXdsServerConfigSelectorProvider::CancelWatch() { |
|
|
|
DynamicXdsServerConfigSelectorProvider::CancelWatch() { |
|
|
|
XdsRouteConfigResourceType::CancelWatch(xds_client_.get(), resource_name_, |
|
|
|
xds_client_->CancelRouteConfigDataWatch(resource_name_, route_config_watcher_, |
|
|
|
route_config_watcher_, |
|
|
|
|
|
|
|
false /* delay_unsubscription */); |
|
|
|
false /* delay_unsubscription */); |
|
|
|
MutexLock lock(&mu_); |
|
|
|
MutexLock lock(&mu_); |
|
|
|
watcher_.reset(); |
|
|
|
watcher_.reset(); |
|
|
|