Skip to content

(Don't use this commit) make mixer cluster name configurable#993

Merged
istio-merge-robot merged 9 commits intomasterfrom
config_mixer_cluster
Feb 6, 2018
Merged

(Don't use this commit) make mixer cluster name configurable#993
istio-merge-robot merged 9 commits intomasterfrom
config_mixer_cluster

Conversation

@rshriram
Copy link
Copy Markdown
Member

@rshriram rshriram commented Feb 5, 2018

Please see istio/api#358 for context.
Essentially remove hardcoded "mixer_server" and allow users to override the name, in addition to allowing separate clusters for check vs reports so that it makes it easier to load balance/manage the system.

@rshriram rshriram requested review from lizan and qiwzhang February 5, 2018 22:34
@googlebot googlebot added the cla: yes Set by the Google CLA bot to indicate the author of a PR has signed the Google CLA. label Feb 5, 2018
Copy link
Copy Markdown
Contributor

@lizan lizan left a comment

Choose a reason for hiding this comment

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

Please fix the format too.

Comment thread src/envoy/mixer/grpc_transport.cc Outdated
const std::string& cluster_name,
const HeaderMap* headers) {
return [&cm, headers](const RequestType& request, ResponseType* response,
return [&cm, &cluster_name, headers](const RequestType& request, ResponseType* response,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

does cluster_name outlive the returned function? If not sure, capture by value.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think it does? Because we used to pass kMixerServerClusterName variable to GrpcTransport.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

kMixerServerClusterName is a global constant so it definitely outlives. But does the cluster_name outlive?

Comment thread src/envoy/mixer/config.cc Outdated
config->set_disable_report_batch(json.getBoolean(kDisableReportBatch, false));

config->set_check_cluster(json.getString(kCheckCluster, kDefaultMixerClusterName));
config->set_report_cluster(json.getString(kReportCluster, kDefaultMixerClusterName));
Copy link
Copy Markdown
Contributor

@qiwzhang qiwzhang Feb 5, 2018

Choose a reason for hiding this comment

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

This is the wrong place to set it. Sorry for the misleading, this function should be called "ReadLegacyTransportConfig"

In the mixer_filter config, if there is a "v2" field,
these data will be override by the data from "v2". In our case, we are using "v2" which is set by Pilot

https://github.com/istio/proxy/blob/master/src/envoy/mixer/config.cc#L115

You have to set these two fields after ReadV2Config() call

and check if they are not set by Pilot, set their default value as "mixer_server"

Comment thread src/envoy/mixer/config.cc Outdated
legacy_quotas.clear();
}

transport_config->set_check_cluster(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We should check if check_cluster is non-empty. If it is non-empty, it is set by Pilot, we should not override it

Comment thread src/envoy/mixer/config.cc Outdated
using ::istio::mixer::v1::config::client::TransportConfig;

#define PROTOBUF_GET_STRING_OR_DEFAULT(message, field_name, default_value) \
((message).has_##field_name() ? (message).field_name() : (default_value))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

protobuf primary type, such as string, does not generate "has_" function. Only the message type does.
it has default value, string default is empty.

Shriram Rajagopalan added 2 commits February 6, 2018 16:32
@lizan
Copy link
Copy Markdown
Contributor

lizan commented Feb 6, 2018

/lgtm

@istio-merge-robot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lizan

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@istio-merge-robot
Copy link
Copy Markdown

/test all [submit-queue is verifying that this PR is safe to merge]

report_cluster_ = mixer_config.report_cluster;

controller_ = ::istio::mixer_control::http::Controller::Create(options);
CreateEnvironment(cm, dispatcher, random, check_cluster_, report_cluster_,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think you will not need check_cluster_ and report_cluster_ in MixerControl object if you don't pass reference to CreateEnvironment(). Just pass std::string and make a copy

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

passing const reference is fine as long as the lamda in GetFunc captures cluster_name as copy, so just remove check_cluster_ and report_cluster_ is good.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Oh I needed to persist these variables in mixer control object because there is a GetFunc call in http_filter.cc that does mixer_control_->... ..
Ideally, i would have liked to stuff them into the options object, but that happens to be defined in mixerclient (spreading to too many repos).

Does that your point @qiwzhang ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I see. That one is per-route Check transport function. My suggestion is:

in both HTTPMixerControl and TcpMixerControl store a const reference to MixerConfig

const MixerConfig& config_;

Expose it as

const MxerConfig& config() const { return config_; }

use the check_cluster_ as

config()->check_cluster()

It is better than store anothery copy in MixerControl

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Well, since the PR is merged. I will clean it up later.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Here is my PR #1001
to clean this up

@istio-merge-robot
Copy link
Copy Markdown

Automatic merge from submit-queue.

@istio-merge-robot istio-merge-robot merged commit 9595aff into master Feb 6, 2018
@qiwzhang qiwzhang changed the title make mixer cluster name configurable (Don't use this commit) make mixer cluster name configurable Feb 7, 2018
@rshriram rshriram deleted the config_mixer_cluster branch February 15, 2018 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes Set by the Google CLA bot to indicate the author of a PR has signed the Google CLA.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants