forked from envoyproxy/envoy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ads-replacement: adding hook and cluster-manager support
Signed-off-by: Adi Suissa-Peleg <adip@google.com>
- Loading branch information
Showing
40 changed files
with
1,289 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#pragma once | ||
|
||
#include "envoy/common/pure.h" | ||
#include "envoy/config/core/v3/config_source.pb.h" | ||
|
||
#include "absl/status/status.h" | ||
|
||
namespace Envoy { | ||
namespace Config { | ||
|
||
/** | ||
* An xDS-Manager interface for all operations related to xDS connections and | ||
* resources in Envoy. | ||
* | ||
* This class is WIP. Currently supported functionality: | ||
* - Dynamically set the ADS configuration to be used. | ||
* | ||
* In general, this is intended to be used only on the main thread, as part of the Server instance | ||
* interface and config subsystem. | ||
*/ | ||
class XdsManager { | ||
public: | ||
virtual ~XdsManager() = default; | ||
|
||
/** | ||
* Set the ADS ConfigSource Envoy should use that will replace the current ADS | ||
* server. | ||
* @param ads_config the ADS config of the new server. | ||
* @return true if the ADS config is valid (points to a valid static server), | ||
* or false otherwise. | ||
*/ | ||
virtual absl::Status | ||
setAdsConfigSource(const envoy::config::core::v3::ApiConfigSource& config_source) PURE; | ||
}; | ||
|
||
using XdsManagerPtr = std::unique_ptr<XdsManager>; | ||
} // namespace Config | ||
} // namespace Envoy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#include "source/common/config/xds_manager_impl.h" | ||
|
||
#include "envoy/config/core/v3/config_source.pb.validate.h" | ||
|
||
#include "source/common/common/thread.h" | ||
|
||
namespace Envoy { | ||
namespace Config { | ||
|
||
absl::Status | ||
XdsManagerImpl::setAdsConfigSource(const envoy::config::core::v3::ApiConfigSource& config_source) { | ||
ASSERT_IS_MAIN_OR_TEST_THREAD(); | ||
RETURN_IF_NOT_OK(validateAdsConfig(config_source)); | ||
|
||
return cm_.replaceAds(config_source); | ||
} | ||
|
||
absl::Status | ||
XdsManagerImpl::validateAdsConfig(const envoy::config::core::v3::ApiConfigSource& config_source) { | ||
auto& validation_visitor = validation_context_.staticValidationVisitor(); | ||
TRY_ASSERT_MAIN_THREAD { MessageUtil::validate(config_source, validation_visitor); } | ||
END_TRY | ||
catch (const EnvoyException& e) { | ||
return absl::InternalError(e.what()); | ||
} | ||
return absl::OkStatus(); | ||
} | ||
|
||
} // namespace Config | ||
} // namespace Envoy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#pragma once | ||
|
||
#include "envoy/config/xds_manager.h" | ||
#include "envoy/upstream/cluster_manager.h" | ||
|
||
#include "source/common/common/thread.h" | ||
|
||
namespace Envoy { | ||
namespace Config { | ||
|
||
class XdsManagerImpl : public XdsManager { | ||
public: | ||
XdsManagerImpl(Upstream::ClusterManager& cm, | ||
ProtobufMessage::ValidationContext& validation_context) | ||
: cm_(cm), validation_context_(validation_context) {} | ||
|
||
// Config::ConfigSourceProvider | ||
absl::Status | ||
setAdsConfigSource(const envoy::config::core::v3::ApiConfigSource& config_source) override; | ||
|
||
private: | ||
// Validates (syntactically) the config_source by doing the PGV validation. | ||
absl::Status validateAdsConfig(const envoy::config::core::v3::ApiConfigSource& config_source); | ||
|
||
Upstream::ClusterManager& cm_; | ||
ProtobufMessage::ValidationContext& validation_context_; | ||
}; | ||
|
||
} // namespace Config | ||
} // namespace Envoy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.