set cluster/route/listener/vhost name len based on CLI opt#1871
set cluster/route/listener/vhost name len based on CLI opt#1871mattklein123 merged 43 commits intoenvoyproxy:masterfrom
Conversation
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>
Signed-off-by: Shriram Rajagopalan <shriram@us.ibm.com>
|
Quick pre-review comments: Will need doc changes. Also, we should do this for RDS and LDS also. |
include/envoy/server/options.h
Outdated
| /** | ||
| * @return uint64_t the maximum name length of a cluster/route/listener. | ||
| */ | ||
| virtual uint64_t maxUserSuppliedNameLength() PURE; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Yup exactly. No more options are needed. Please rework as @ggreenway suggests.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Yup that's exactly what I would do.
|
@hennna please review this from the Google side (I will do the final pass from us). |
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>
test/server/hot_restart_impl_test.cc
Outdated
| 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()); |
There was a problem hiding this comment.
I think this should stay maxNameLength(), because it's directly creating the stat name
test/server/hot_restart_impl_test.cc
Outdated
| // 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()); |
| options_.maxStats(), options_.maxStatNameLength())); | ||
| EXPECT_EQ(hot_restart_->version(), | ||
| Envoy::Server::SharedMemory::version(options_.maxStats(), | ||
| options_.maxObjNameLength() + |
There was a problem hiding this comment.
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)?
There was a problem hiding this comment.
with the new build its 9.200.16384.127 and with master build, its 9.200.16384.127 . so it matches!
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/ |
source/common/config/json_utility.h
Outdated
| // 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); \ |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
Why does this throw now? What's the new error?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Right, please keep EXPECT_THROW_WITH_MESSAGE and switch it to the new error.
hennna
left a comment
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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. | ||
| */ |
There was a problem hiding this comment.
Should we instead have maxNameLength be derived from maxObjNameLength?
source/common/stats/stats_impl.h
Outdated
| @@ -103,6 +115,8 @@ struct RawStatData { | |||
|
|
|||
| private: | |||
| static const size_t DEFAULT_MAX_NAME_SIZE = 127; | |||
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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?
|
On Tue, Oct 17, 2017 at 11:08 PM hennna ***@***.***> wrote:
***@***.**** commented on this pull request.
Thanks! Looking forward to using this feature.
------------------------------
In source/common/stats/stats_impl.h
<#1871 (comment)>:
> @@ -103,6 +115,8 @@ struct RawStatData {
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;
Maybe document where this number comes from? It seems from #667
<#667> it was from a cluster
stats name plus some buffer.
------------------------------
In source/common/stats/stats_impl.h
<#1871 (comment)>:
> @@ -68,6 +68,18 @@ struct RawStatData {
}
/**
+ * 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.
+ */
+ static size_t maxObjNameLength() { return maxNameLength() - MAX_STAT_SUFFIX_LENGTH; }
Should we instead have maxNameLength be derived from maxObjNameLength?
We could. I was trying to avoid touching the functions that were playing
tricks with static vars, as the maxNameLen function is used everywhere! But
let me see if it’s easy to change.
------------------------------
In source/common/stats/stats_impl.h
<#1871 (comment)>:
> @@ -103,6 +115,8 @@ struct RawStatData {
private:
static const size_t DEFAULT_MAX_NAME_SIZE = 127;
Should this be DEFAULT_MAX_OBJ_NAME_SIZE? Wondering if it would be better
to have all max name size parameters be derived.
This is max length of a stat entry. I agree it’s worded in a bit confusing
manner.
------------------------------
In source/server/options_impl.cc
<#1871 (comment)>:
> #endif
-#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"
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?
@mattklein123 says we can bump it when necessary. I am surprised that 67
characters are enough to hold our current stat names.
… —
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1871 (review)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AH0qdwZDap0dY9z28VKZ1rTKU3HTS0Qlks5stWuzgaJpZM4P7TBJ>
.
|
Signed-off-by: Shriram Rajagopalan <shriram@us.ibm.com>
|
@mattklein123 / @junr03 I noticed this in the docs: 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>
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>
|
@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). |
mattklein123
left a comment
There was a problem hiding this comment.
LGTM. few small things. @ggreenway can you take another look also?
docs/operations/cli.rst
Outdated
| information. Defaults to 900 seconds (15 minutes). | ||
|
|
||
| .. option:: --max-stat-name-len <uint64_t> | ||
| .. _operations_cli_max_obj_name_len: |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
nit: extra space in "cluster/ "
| } | ||
| )EOF"; | ||
|
|
||
| EXPECT_THROW_WITH_MESSAGE(create(parseBootstrapFromJson(json)), Json::Exception, |
There was a problem hiding this comment.
Isn't this test still valid? Or is it not anymore?
There was a problem hiding this comment.
Same comment as above. Test just moved to utility_test.cc ..
test/common/router/rds_impl_test.cc
Outdated
| } | ||
| )EOF"; | ||
|
|
||
| EXPECT_THROW(RouteConfigProviderUtil::create(parseHttpConnectionManagerFromJson(config_json), |
There was a problem hiding this comment.
Can we do EXPECT_THROW_WITH_MESSAGE here?
There was a problem hiding this comment.
Actually, can I get rid of it? We have the same test in utility_test.cc
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() + |
There was a problem hiding this comment.
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.
|
LGTM! |
In response to envoyproxy/envoy#1806 and envoyproxy/envoy#1871. Signed-off-by: Harvey Tuch <htuch@google.com>
In response to envoyproxy/envoy#1806 and envoyproxy/envoy#1871. Signed-off-by: Harvey Tuch <htuch@google.com>
In response to envoyproxy/envoy#1806 and envoyproxy/envoy#1871. Signed-off-by: Harvey Tuch <htuch@google.com>
#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>
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.