Skip to content

set cluster/route/listener/vhost name len based on CLI opt#1871

Merged
mattklein123 merged 43 commits intoenvoyproxy:masterfrom
amalgam8:master
Oct 19, 2017
Merged

set cluster/route/listener/vhost name len based on CLI opt#1871
mattklein123 merged 43 commits intoenvoyproxy:masterfrom
amalgam8:master

Conversation

@rshriram
Copy link
Copy Markdown
Member

@rshriram rshriram commented Oct 16, 2017

Automatically set the max allowed length for cluster, route_config_name and listener name based on the max_stat_name_len specified. The name len is max_stat_name_len - 67 (which is the suffix reserved for internally generated stats).

Signed-off-by: Shriram Rajagopalan shriram@us.ibm.com

cc @hennna / @ggreenway FYI.

@mattklein123 this is per discussion on Slack.

Shriram Rajagopalan added 21 commits October 2, 2017 17:07
Signed-off-by: Shriram Rajagopalan <shriram@us.ibm.com>
Signed-off-by: Shriram Rajagopalan <shriram@us.ibm.com>
Signed-off-by: Shriram Rajagopalan <shriram@us.ibm.com>
fix
Signed-off-by: Shriram Rajagopalan <shriram@us.ibm.com>
Signed-off-by: Shriram Rajagopalan <shriram@us.ibm.com>
Signed-off-by: Shriram Rajagopalan <shriram@us.ibm.com>
Signed-off-by: Shriram Rajagopalan <shriram@us.ibm.com>
Signed-off-by: Shriram Rajagopalan <shriram@us.ibm.com>
Signed-off-by: Shriram Rajagopalan <shriram@us.ibm.com>
Signed-off-by: Shriram Rajagopalan <shriram@us.ibm.com>
Signed-off-by: Shriram Rajagopalan <shriram@us.ibm.com>
Signed-off-by: Shriram Rajagopalan <shriram@us.ibm.com>
Signed-off-by: Shriram Rajagopalan <shriram@us.ibm.com>
Signed-off-by: Shriram Rajagopalan <shriram@us.ibm.com>
Signed-off-by: Shriram Rajagopalan <shriram@us.ibm.com>
Signed-off-by: Shriram Rajagopalan <shriram@us.ibm.com>
Signed-off-by: Shriram Rajagopalan <shriram@us.ibm.com>
Signed-off-by: Shriram Rajagopalan <shriram@us.ibm.com>
Signed-off-by: Shriram Rajagopalan <shriram@us.ibm.com>
@rshriram rshriram changed the title Configurable cluster name length Configurable cluster name/route name/listener name length Oct 16, 2017
@rshriram rshriram changed the title Configurable cluster name/route name/listener name length Configurable cluster name name length Oct 16, 2017
@mattklein123
Copy link
Copy Markdown
Member

Quick pre-review comments: Will need doc changes. Also, we should do this for RDS and LDS also.

/**
* @return uint64_t the maximum name length of a cluster/route/listener.
*/
virtual uint64_t maxUserSuppliedNameLength() PURE;
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.

I think that it would be better to have this value be derived from the maxStatNameLen, or possibly have that one be derived from this one. Being able to specify both seems confusing.

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.

Yup exactly. No more options are needed. Please rework as @ggreenway suggests.

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.

Yeah good point. Does it suffice to just derive max cluster name length as max_stat_name_len - reserved_stat_suffix_len (which happens to be 67 at the moment) ? That would make things considerably simple.

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.

Yup that's exactly what I would do.

@htuch
Copy link
Copy Markdown
Member

htuch commented Oct 16, 2017

@hennna please review this from the Google side (I will do the final pass from us).

Shriram Rajagopalan added 2 commits October 17, 2017 00:19
Signed-off-by: Shriram Rajagopalan <shriram@us.ibm.com>
Signed-off-by: Shriram Rajagopalan <shriram@us.ibm.com>
@rshriram rshriram changed the title Configurable cluster name name length Configure cluster/route/listener name len based on max_stat_name_len Oct 17, 2017
@rshriram rshriram changed the title Configure cluster/route/listener name len based on max_stat_name_len set cluster/route/listener name len based on max_stat_name_len Oct 17, 2017
Signed-off-by: Shriram Rajagopalan <shriram@us.ibm.com>
@rshriram rshriram changed the title set cluster/route/listener name len based on max_stat_name_len set cluster/route/listener name len based on CLI opt Oct 17, 2017
for (uint64_t i = 0; i < num_stats_; i++) {
std::string name = fmt::format("{}zzzzzzzzzzzzzzzzzzzzzzzzzzzz", i)
.substr(0, Stats::RawStatData::maxNameLength());
.substr(0, Stats::RawStatData::maxObjNameLength());
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.

I think this should stay maxNameLength(), because it's directly creating the stat name

// If this isn't true then the hard coded part of the name isn't long enough to make the test
// valid.
EXPECT_EQ(ts.name_.size(), Stats::RawStatData::maxNameLength());
EXPECT_EQ(ts.name_.size(), Stats::RawStatData::maxObjNameLength());
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.

Same here: maxNameLength()

options_.maxStats(), options_.maxStatNameLength()));
EXPECT_EQ(hot_restart_->version(),
Envoy::Server::SharedMemory::version(options_.maxStats(),
options_.maxObjNameLength() +
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.

I think this is correct, but as per @mattklein123's request, can you make sure the version string is the same before and after your change (as a manual check)?

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.

with the new build its 9.200.16384.127 and with master build, its 9.200.16384.127 . so it matches!

Shriram Rajagopalan added 2 commits October 17, 2017 18:44
Signed-off-by: Shriram Rajagopalan <shriram@us.ibm.com>
Signed-off-by: Shriram Rajagopalan <shriram@us.ibm.com>
bazel/README.md Outdated

The default maximum number of stats in shared memory, and the default maximum length of a stat name,
can be overriden at compile-time by defining `ENVOY_DEFAULT_MAX_STATS` and `ENVOY_DEFAULT_MAX_STAT_NAME_LENGTH`,
The default maximum number of stats in shared memory, and the default maximum length of a cluster/
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: reflow text.

// Set a string field in a protobuf message with the corresponding string value
#define JSON_UTIL_SET_STRING_VALUE(json, message, field_name, value) \
do { \
(message).set_##field_name(value); \
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.

What does this have to do with JSON? Why is this macro needed at all?

TCLAP::ValueArg<uint64_t> max_stat_name_len("", "max-stat-name-len",
"Maximum name length for a stat", false,
ENVOY_DEFAULT_MAX_STAT_NAME_LENGTH, "uint64_t", cmd);
TCLAP::ValueArg<uint64_t> max_obj_name_len("", "max-obj-name-len",
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.

needs doc update

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.

ack. Sorry missed that totally.

"JSON at lines 4-6 does not conform to schema.\n Invalid schema: "
"#/properties/name\n Schema violation: maxLength\n Offending "
"document key: #/name");
EXPECT_THROW(create(parseBootstrapFromJson(json)), EnvoyException);
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.

Why does this throw now? What's the new error?

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.

This was always throwing an error. Earlier, it threw a JSON schema error with some message like "Invalid #/properties/name...." .. I merely changed this to use EnvoyException, as we are no longer validating the length using JSON schema.

In other words, UX wise, you would still get an exception when max length is exceeded, except it will be worded differently.

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.

Right, please keep EXPECT_THROW_WITH_MESSAGE and switch it to the new error.

Copy link
Copy Markdown
Contributor

@hennna hennna left a comment

Choose a reason for hiding this comment

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

Thanks! Looking forward to using this feature.

private:
static const size_t DEFAULT_MAX_NAME_SIZE = 127;
// total length must be equal to DEFAULT_MAX_NAME_SIZE
static const size_t MAX_STAT_SUFFIX_LENGTH = 67;
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.

Maybe document where this number comes from? It seems from #667 it was from a cluster stats name plus some buffer.

/**
* Returns the maximum length of a user supplied object (route/cluster/listener)
* name field in a stat. This length does not include a trailing NULL-terminator.
*/
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.

Should we instead have maxNameLength be derived from maxObjNameLength?

@@ -103,6 +115,8 @@ struct RawStatData {

private:
static const size_t DEFAULT_MAX_NAME_SIZE = 127;
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.

Should this be DEFAULT_MAX_OBJ_NAME_SIZE? Wondering if it would be better to have all max name size parameters be derived.

#if ENVOY_DEFAULT_MAX_STAT_NAME_LENGTH < 127
#error "ENVOY_DEFAULT_MAX_STAT_NAME_LENGTH must be >= 127"
#if ENVOY_DEFAULT_MAX_OBJ_NAME_LENGTH < 60
#error "ENVOY_DEFAULT_MAX_OBJ_NAME_LENGTH must be >= 60"
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.

Outside the scope of this PR... Will there come a time when we also want to have MAX_STAT_SUFFIX_LENGTH be configurable? Or is that better left hard coded and bumped up when necessary?

@rshriram
Copy link
Copy Markdown
Member Author

rshriram commented Oct 18, 2017 via email

Signed-off-by: Shriram Rajagopalan <shriram@us.ibm.com>
@rshriram
Copy link
Copy Markdown
Member Author

@mattklein123 / @junr03 I noticed this in the docs:

*vhost.<virtual host name>.vcluster.<virtual cluster name>.* namespace and include the following
statistics:

Given that this PR allows for configurable name lengths for clusters, how does it affect the above stat, which is concatenating two different user supplied identities?

Signed-off-by: Shriram Rajagopalan <shriram@us.ibm.com>
@mattklein123
Copy link
Copy Markdown
Member

Given that this PR allows for configurable name lengths for clusters, how does it affect the above stat, which is concatenating two different user supplied identities?

This occurred to me also. I think there are probably a bunch of random places where we should be guarding against user supplied stat names, etc. that might be too large. I would probably just open up a follow up ticket to audit.

Signed-off-by: Shriram Rajagopalan <shriram@us.ibm.com>
@rshriram
Copy link
Copy Markdown
Member Author

@mattklein123 I moved all the objNameLength checks into a separate file. Also added name length checks for virtual host (but not the virtual host + virtual cluster).
@hennna addressed your comments as well. PTAL

@rshriram rshriram changed the title set cluster/route/listener name len based on CLI opt set cluster/route/listener/vhost name len based on CLI opt Oct 18, 2017
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. few small things. @ggreenway can you take another look also?

information. Defaults to 900 seconds (15 minutes).

.. option:: --max-stat-name-len <uint64_t>
.. _operations_cli_max_obj_name_len:
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.

doc nit: You don't need this anchor, you can reference options directly and then they look nice inline. See how we ref other options.

bazel/README.md Outdated
can be overriden at compile-time by defining `ENVOY_DEFAULT_MAX_STATS` and `ENVOY_DEFAULT_MAX_STAT_NAME_LENGTH`,
respectively, to the desired value. For example:
The default maximum number of stats in shared memory, and the default
maximum length of a cluster/ route config/listener name, can be
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: extra space in "cluster/ "

}
)EOF";

EXPECT_THROW_WITH_MESSAGE(create(parseBootstrapFromJson(json)), Json::Exception,
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.

Isn't this test still valid? Or is it not anymore?

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.

Same comment as above. Test just moved to utility_test.cc ..

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.

Yup sounds good

}
)EOF";

EXPECT_THROW(RouteConfigProviderUtil::create(parseHttpConnectionManagerFromJson(config_json),
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 we do EXPECT_THROW_WITH_MESSAGE here?

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.

Actually, can I get rid of it? We have the same test in utility_test.cc

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.

Yup that's fine

Shriram Rajagopalan added 3 commits October 18, 2017 13:46
Signed-off-by: Shriram Rajagopalan <shriram@us.ibm.com>
Signed-off-by: Shriram Rajagopalan <shriram@us.ibm.com>
Signed-off-by: Shriram Rajagopalan <shriram@us.ibm.com>
if (hot_restart_version_option.getValue()) {
std::cerr << hot_restart_version_cb(max_stats.getValue(), max_stat_name_len.getValue());
std::cerr << hot_restart_version_cb(max_stats.getValue(),
max_obj_name_len.getValue() +
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.

It would be nicer if we could call RawStatData::configure(), then use RawStatData::maxNameLength() here, instead of doing the addition. But I think it's probably more effort than it's worth, because the options_impl doesn't have it's values yet at this point in the function, so probably fine to leave as is, and the tests should catch if this gets messed up somehow.

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. @htuch or @hennna any further comments?

@hennna
Copy link
Copy Markdown
Contributor

hennna commented Oct 19, 2017

LGTM!

@mattklein123 mattklein123 merged commit e366bcf into envoyproxy:master Oct 19, 2017
htuch added a commit to htuch/envoy-api that referenced this pull request Oct 30, 2017
In response to envoyproxy/envoy#1806 and
envoyproxy/envoy#1871.

Signed-off-by: Harvey Tuch <htuch@google.com>
htuch added a commit to envoyproxy/data-plane-api that referenced this pull request Oct 30, 2017
In response to envoyproxy/envoy#1806 and
envoyproxy/envoy#1871.

Signed-off-by: Harvey Tuch <htuch@google.com>
Elite1015 pushed a commit to Elite1015/data-plane-api that referenced this pull request Feb 23, 2025
In response to envoyproxy/envoy#1806 and
envoyproxy/envoy#1871.

Signed-off-by: Harvey Tuch <htuch@google.com>
mathetake pushed a commit that referenced this pull request Mar 3, 2026
#1871)

**Description**

This bumps envoy gateway to v1.7.0 and reverts the
`host.docker.internal` OTLP workaround in `.env.otel.otel-tui` and
`.env.otel.phoenix`.

Verified all four docker compose test profiles (chat-completion,
completion, create-embeddings, mcp) work with otel-tui receiving traces
over the restored container service name endpoints.

**Related Issues/PRs (if applicable)**

**Special notes for reviewers (if applicable)**

The `.env.otel.host` file intentionally uses `host.docker.internal` (not
a workaround), so it is unchanged.

Signed-off-by: Adrian Cole <adrian@tetrate.io>
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.

5 participants