Skip to content

upstream: add CDS LbSubsetConfig to ClusterInfo#1837

Merged
htuch merged 3 commits intoenvoyproxy:masterfrom
turbinelabs:slb/cluster-slb-config-2
Oct 11, 2017
Merged

upstream: add CDS LbSubsetConfig to ClusterInfo#1837
htuch merged 3 commits intoenvoyproxy:masterfrom
turbinelabs:slb/cluster-slb-config-2

Conversation

@zuercher
Copy link
Copy Markdown
Member

Second PR split out of #1735.

This one adds the LbSubsetConfig data from the CDS Cluster message to the existing ClusterInfo class.

Signed-off-by: Stephan Zuercher <stephan@turbinelabs.io>
Signed-off-by: Stephan Zuercher <stephan@turbinelabs.io>
Copy link
Copy Markdown
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

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

LGTM modulo nits.

virtual ~LoadBalancerSubsetInfo() {}

/**
* @return true if load balancer subsets are configured.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: @return bool true if load ... etc. and below.

virtual bool isEnabled() const PURE;

/**
* @return the fallback policy used when route metadata does not match any subset.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

(can probably skip the namespace here though, since it's like half a mile long)

: enabled_(subset_config.subset_selectors_size() != 0),
fallback_policy_(subset_config.fallback_policy()),
default_subset_(subset_config.default_subset()) {
for (auto subset : subset_config.subset_selectors()) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

const auto&?

fallback_policy_(subset_config.fallback_policy()),
default_subset_(subset_config.default_subset()) {
for (auto subset : subset_config.subset_selectors()) {
if (subset.keys_size() > 0) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

!subset.keys().empty()

class LoadBalancerSubsetInfoImpl : public LoadBalancerSubsetInfo {
public:
LoadBalancerSubsetInfoImpl(const envoy::api::v2::Cluster::LbSubsetConfig& subset_config)
: enabled_(subset_config.subset_selectors_size() != 0),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

subset_config.subset_selectors.empty()?

const std::vector<std::set<std::string>>& subsetKeys() const override { return subset_keys_; }

private:
bool enabled_;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: some of these can be const as initialized in constructor.

auto subset_config = envoy::api::v2::Cluster::LbSubsetConfig::default_instance();
subset_config.set_fallback_policy(envoy::api::v2::Cluster::LbSubsetConfig::DEFAULT_SUBSET);
subset_config.mutable_default_subset()->mutable_fields()->insert({"key", subset_value});
subset_config.mutable_subset_selectors()->Add()->CopyFrom(subset_selector);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: If you build this in the reverse direction (i.e. acquire the selector via subset_config.mutable_subset_selectors()->Add()), you don't have to copy.

Signed-off-by: Stephan Zuercher <stephan@turbinelabs.io>
Copy link
Copy Markdown
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

LGTM pending any further @htuch comments.

@htuch htuch merged commit 6cb0983 into envoyproxy:master Oct 11, 2017
@zuercher zuercher deleted the slb/cluster-slb-config-2 branch October 25, 2017 22:36
rshriram pushed a commit to rshriram/envoy that referenced this pull request Oct 30, 2018
…oxy#1837)

* Add two new attributes:  request.url_path and request.queries

* Update api in repositories.bzl
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.

3 participants