Skip to content

Commit

Permalink
Merge github.com:grpc/grpc into pbe2
Browse files Browse the repository at this point in the history
  • Loading branch information
ctiller committed Jan 4, 2024
2 parents a3ac687 + e535be8 commit 14de336
Show file tree
Hide file tree
Showing 29 changed files with 220 additions and 135 deletions.
2 changes: 1 addition & 1 deletion .bazelci/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
---
# TODO(yannic): Ideally, we should also enable buildifier and all platforms should test `//...`.
tasks:
ubuntu1804:
ubuntu2004:
build_targets:
- //:all
- //src/proto/...
Expand Down
10 changes: 4 additions & 6 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
# Auto-generated by the tools/mkowners/mkowners.py tool
# Uses OWNERS files in different modules throughout the
# repository as the source of truth for module ownership.
/**/OWNERS @markdroth @a11r
/bazel/** @jtattermusch @veblush @gnossen
/cmake/** @jtattermusch @apolcyn
/bazel/** @veblush @gnossen
/bazel/experiments.yaml
/cmake/** @veblush @apolcyn
/src/core/ext/filters/client_channel/** @markdroth
/src/core/ext/transport/chttp2/transport/** @ctiller
/src/core/ext/xds/** @markdroth
/src/core/lib/resolver/** @markdroth
/src/core/lib/service_config/** @markdroth
/tools/dockerfile/** @jtattermusch @apolcyn
/tools/dockerfile/** @drfloob @apolcyn @gnossen
/tools/run_tests/xds_k8s_test_driver/** @sergiitk @XuanWang-Amos @gnossen
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report_csharp.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name: Report a gRPC C# bug
about: Create a report to help us improve
labels: kind/bug, priority/P2, lang/C#
assignees: jtattermusch
assignees: apolcyn

---

Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature_request_csharp.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name: Request a gRPC C# feature
about: Suggest an idea for this project
labels: kind/enhancement, priority/P2, lang/C#
assignees: jtattermusch
assignees: apolcyn

---

Expand Down
95 changes: 46 additions & 49 deletions src/core/ext/filters/stateful_session/stateful_session_filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@
namespace grpc_core {

TraceFlag grpc_stateful_session_filter_trace(false, "stateful_session_filter");
const NoInterceptor StatefulSessionFilter::Call::OnClientToServerMessage;
const NoInterceptor StatefulSessionFilter::Call::OnServerToClientMessage;
const NoInterceptor StatefulSessionFilter::Call::OnFinalize;

UniqueTypeName XdsOverrideHostAttribute::TypeName() {
static UniqueTypeName::Factory kFactory("xds_override_host");
Expand Down Expand Up @@ -103,7 +106,7 @@ void MaybeUpdateServerInitialMetadata(
bool cluster_changed, absl::string_view actual_cluster,
absl::string_view cookie_address_list,
XdsOverrideHostAttribute* override_host_attribute,
ServerMetadata* server_initial_metadata) {
ServerMetadata& server_initial_metadata) {
// If cookie doesn't need to change, do nothing.
if (cookie_address_list == override_host_attribute->actual_address_list() &&
!cluster_changed) {
Expand All @@ -121,7 +124,7 @@ void MaybeUpdateServerInitialMetadata(
parts.emplace_back(
absl::StrCat("Max-Age=", cookie_config->ttl.as_timespec().tv_sec));
}
server_initial_metadata->Append(
server_initial_metadata.Append(
"set-cookie", Slice::FromCopiedString(absl::StrJoin(parts, "; ")),
[](absl::string_view error, const Slice&) {
Crash(absl::StrCat("ERROR ADDING set-cookie METADATA: ", error));
Expand Down Expand Up @@ -168,12 +171,11 @@ absl::string_view GetClusterToUse(
return absl::StripPrefix(arena_allocated_cluster, kClusterPrefix);
}

std::string GetCookieValue(const ClientMetadataHandle& client_initial_metadata,
std::string GetCookieValue(const ClientMetadata& client_initial_metadata,
absl::string_view cookie_name) {
// Check to see if the cookie header is present.
std::string buffer;
auto header_value =
client_initial_metadata->GetStringValue("cookie", &buffer);
auto header_value = client_initial_metadata.GetStringValue("cookie", &buffer);
if (!header_value.has_value()) return "";
// Parse cookie header.
std::vector<absl::string_view> values;
Expand All @@ -193,13 +195,14 @@ std::string GetCookieValue(const ClientMetadataHandle& client_initial_metadata,
}

bool IsConfiguredPath(absl::string_view configured_path,
const ClientMetadataHandle& client_initial_metadata) {
const ClientMetadata& client_initial_metadata) {
// No path configured meaning all paths match
if (configured_path.empty()) {
return true;
}
// Check to see if the configured path matches the request path.
Slice* path_slice = client_initial_metadata->get_pointer(HttpPathMetadata());
const Slice* path_slice =
client_initial_metadata.get_pointer(HttpPathMetadata());
GPR_ASSERT(path_slice != nullptr);
absl::string_view path = path_slice->as_string_view();
// Matching criteria from
Expand All @@ -218,9 +221,8 @@ bool IsConfiguredPath(absl::string_view configured_path,
}
} // namespace

// Construct a promise for one call.
ArenaPromise<ServerMetadataHandle> StatefulSessionFilter::MakeCallPromise(
CallArgs call_args, NextPromiseFactory next_promise_factory) {
void StatefulSessionFilter::Call::OnClientInitialMetadata(
ClientMetadata& md, StatefulSessionFilter* filter) {
// Get config.
auto* service_config_call_data = static_cast<ServiceConfigCallData*>(
GetContext<
Expand All @@ -229,62 +231,57 @@ ArenaPromise<ServerMetadataHandle> StatefulSessionFilter::MakeCallPromise(
GPR_ASSERT(service_config_call_data != nullptr);
auto* method_params = static_cast<StatefulSessionMethodParsedConfig*>(
service_config_call_data->GetMethodParsedConfig(
service_config_parser_index_));
filter->service_config_parser_index_));
GPR_ASSERT(method_params != nullptr);
auto* cookie_config = method_params->GetConfig(index_);
GPR_ASSERT(cookie_config != nullptr);
if (!cookie_config->name.has_value() ||
!IsConfiguredPath(cookie_config->path,
call_args.client_initial_metadata)) {
return next_promise_factory(std::move(call_args));
cookie_config_ = method_params->GetConfig(filter->index_);
GPR_ASSERT(cookie_config_ != nullptr);
if (!cookie_config_->name.has_value() ||
!IsConfiguredPath(cookie_config_->path, md)) {
return;
}
// Base64-decode cookie value.
std::string cookie_value =
GetCookieValue(call_args.client_initial_metadata, *cookie_config->name);
std::string cookie_value = GetCookieValue(md, *cookie_config_->name);
// Cookie format is "host;cluster"
std::pair<absl::string_view, absl::string_view> host_cluster =
absl::StrSplit(cookie_value, absl::MaxSplits(';', 1));
absl::string_view cookie_address_list;
// Allocate the string on the arena, so that it has the right lifetime.
if (!host_cluster.first.empty()) {
cookie_address_list = AllocateStringOnArena(host_cluster.first);
cookie_address_list_ = AllocateStringOnArena(host_cluster.first);
}
// Set override host attribute.
auto* override_host_attribute =
override_host_attribute_ =
GetContext<Arena>()->ManagedNew<XdsOverrideHostAttribute>(
cookie_address_list);
service_config_call_data->SetCallAttribute(override_host_attribute);
cookie_address_list_);
service_config_call_data->SetCallAttribute(override_host_attribute_);
// Check if the cluster override is valid, and apply it if necessary.
// Note that cluster_name will point to an arena-allocated string
// that will still be alive when we see the server initial metadata.
// If the cluster name is empty, that means we cannot use a
// cluster override (i.e., the route uses a cluster specifier plugin).
absl::string_view cluster_name =
cluster_name_ =
GetClusterToUse(host_cluster.second, service_config_call_data);
bool cluster_changed = cluster_name != host_cluster.second;
// Intercept server initial metadata.
call_args.server_initial_metadata->InterceptAndMap(
[cookie_config, cluster_changed, cluster_name, cookie_address_list,
override_host_attribute](ServerMetadataHandle md) {
// Add cookie to server initial metadata if needed.
MaybeUpdateServerInitialMetadata(cookie_config, cluster_changed,
cluster_name, cookie_address_list,
override_host_attribute, md.get());
return md;
});
return Map(next_promise_factory(std::move(call_args)),
[cookie_config, cluster_changed, cluster_name, cookie_address_list,
override_host_attribute](ServerMetadataHandle md) {
// If we got a Trailers-Only response, then add the
// cookie to the trailing metadata instead of the
// initial metadata.
if (md->get(GrpcTrailersOnly()).value_or(false)) {
MaybeUpdateServerInitialMetadata(
cookie_config, cluster_changed, cluster_name,
cookie_address_list, override_host_attribute, md.get());
}
return md;
});
cluster_changed_ = cluster_name_ != host_cluster.second;
perform_filtering_ = true;
}

void StatefulSessionFilter::Call::OnServerInitialMetadata(ServerMetadata& md) {
if (!perform_filtering_) return;
// Add cookie to server initial metadata if needed.
MaybeUpdateServerInitialMetadata(cookie_config_, cluster_changed_,
cluster_name_, cookie_address_list_,
override_host_attribute_, md);
}

void StatefulSessionFilter::Call::OnServerTrailingMetadata(ServerMetadata& md) {
if (!perform_filtering_) return;
// If we got a Trailers-Only response, then add the
// cookie to the trailing metadata instead of the
// initial metadata.
if (md.get(GrpcTrailersOnly()).value_or(false)) {
MaybeUpdateServerInitialMetadata(cookie_config_, cluster_changed_,
cluster_name_, cookie_address_list_,
override_host_attribute_, md);
}
}

void StatefulSessionFilterRegister(CoreConfiguration::Builder* builder) {
Expand Down
25 changes: 21 additions & 4 deletions src/core/ext/filters/stateful_session/stateful_session_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "absl/status/statusor.h"
#include "absl/strings/string_view.h"

#include "src/core/ext/filters/stateful_session/stateful_session_service_config_parser.h"
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/channel/channel_fwd.h"
#include "src/core/lib/channel/promise_based_filter.h"
Expand Down Expand Up @@ -68,16 +69,32 @@ class XdsOverrideHostAttribute
};

// A filter to provide cookie-based stateful session affinity.
class StatefulSessionFilter : public ChannelFilter {
class StatefulSessionFilter
: public ImplementChannelFilter<StatefulSessionFilter> {
public:
static const grpc_channel_filter kFilter;

static absl::StatusOr<StatefulSessionFilter> Create(
const ChannelArgs& args, ChannelFilter::Args filter_args);

// Construct a promise for one call.
ArenaPromise<ServerMetadataHandle> MakeCallPromise(
CallArgs call_args, NextPromiseFactory next_promise_factory) override;
class Call {
public:
void OnClientInitialMetadata(ClientMetadata& md,
StatefulSessionFilter* filter);
void OnServerInitialMetadata(ServerMetadata& md);
void OnServerTrailingMetadata(ServerMetadata& md);
static const NoInterceptor OnClientToServerMessage;
static const NoInterceptor OnServerToClientMessage;
static const NoInterceptor OnFinalize;

private:
const StatefulSessionMethodParsedConfig::CookieConfig* cookie_config_;
XdsOverrideHostAttribute* override_host_attribute_;
absl::string_view cluster_name_;
absl::string_view cookie_address_list_;
bool cluster_changed_;
bool perform_filtering_ = false;
};

private:
explicit StatefulSessionFilter(ChannelFilter::Args filter_args);
Expand Down
3 changes: 1 addition & 2 deletions src/core/lib/surface/call.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4072,8 +4072,7 @@ RefCountedPtr<CallSpineInterface> MakeServerCall(Server* server,
return RefCountedPtr<ServerCallSpine>(call);
}
#else
RefCountedPtr<CallSpineInterface> MakeServerCall(Server* server,
Channel* channel) {
RefCountedPtr<CallSpineInterface> MakeServerCall(Server*, Channel*) {
Crash("not implemented");
}
#endif
Expand Down
5 changes: 3 additions & 2 deletions src/core/tsi/ssl_transport_security.cc
Original file line number Diff line number Diff line change
Expand Up @@ -269,13 +269,14 @@ static tsi_result ssl_get_x509_common_name(X509* cert, unsigned char** utf8,
X509_NAME* subject_name = X509_get_subject_name(cert);
int utf8_returned_size = 0;
if (subject_name == nullptr) {
gpr_log(GPR_INFO, "Could not get subject name from certificate.");
gpr_log(GPR_DEBUG, "Could not get subject name from certificate.");
return TSI_NOT_FOUND;
}
common_name_index =
X509_NAME_get_index_by_NID(subject_name, NID_commonName, -1);
if (common_name_index == -1) {
gpr_log(GPR_INFO, "Could not get common name of subject from certificate.");
gpr_log(GPR_DEBUG,
"Could not get common name of subject from certificate.");
return TSI_NOT_FOUND;
}
common_name_entry = X509_NAME_get_entry(subject_name, common_name_index);
Expand Down
4 changes: 1 addition & 3 deletions tools/bazelify_tests/dockerimage_current_versions.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,18 @@ DOCKERIMAGE_CURRENT_VERSIONS = {
"tools/dockerfile/distribtest/python_dev_buster_x86.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/python_dev_buster_x86@sha256:179146fd5d5cc15846c6bf0284c2e261f383caf944559d2d9f7a5af0e0f7152d",
"tools/dockerfile/distribtest/python_dev_centos7_x64.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/python_dev_centos7_x64@sha256:e6e9a1b23a0a543050db91e17d621aa899bad04308adaf961c11fa88ba941a95",
"tools/dockerfile/distribtest/python_dev_fedora36_x64.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/python_dev_fedora36_x64@sha256:d10ea0c54ecaa861b67942b4adc69178585cd071c9d0c8997fa274a362beea55",
"tools/dockerfile/distribtest/python_dev_ubuntu1804_x64.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/python_dev_ubuntu1804_x64@sha256:157a89cd6d0e69b89ac1975e0314aade556a35aafbaa5fe9f9890f90321d6c89",
"tools/dockerfile/distribtest/python_dev_ubuntu2004_x64.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/python_dev_ubuntu2004_x64@sha256:91f0d88c43ec52ecd63f99acb424c88ff9a67fa046fae207a75e99bee37eef11",
"tools/dockerfile/distribtest/python_dev_ubuntu2204_x64.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/python_dev_ubuntu2204_x64@sha256:9e6c9ddc738afcd73fcf2de27b22fdc22a74f1e90e214345838373d9c65ea215",
"tools/dockerfile/distribtest/python_fedora36_x64.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/python_fedora36_x64@sha256:85b2d2fbbcfc1b995ce3916dcf8240c29dbc72f91bd47f04187c2db008570ba4",
"tools/dockerfile/distribtest/python_opensuse_x64.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/python_opensuse_x64@sha256:da52566b078d10e537aa219e59641731a57e5dc7d17d6737f5e5a7d447acf5cc",
"tools/dockerfile/distribtest/python_python38_buster_aarch64.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/python_python38_buster_aarch64@sha256:487b9af2ad1459ee2630694e61074d4ac525d4f90b2bdb026dbf6f77fb3e9878",
"tools/dockerfile/distribtest/python_ubuntu1804_x64.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/python_ubuntu1804_x64@sha256:edcd5f342d77ad9129cc0a0e6988b47b144815e7a93091d5b45e850111eefbcf",
"tools/dockerfile/distribtest/python_ubuntu2004_x64.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/python_ubuntu2004_x64@sha256:342e9dc23b674ad256b220745745be818708a1baa25a2690f0d4f777e28a22a3",
"tools/dockerfile/distribtest/python_ubuntu2204_x64.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/python_ubuntu2204_x64@sha256:b6ca497348741615406d1d571cf5042008da934c4f708877aa06a66b5dc3036c",
"tools/dockerfile/distribtest/ruby_centos7_x64.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/ruby_centos7_x64@sha256:4d529b984b78ca179086f7f9b416605e2d9a96ca0a28a71f4421bb5ffdc18f96",
"tools/dockerfile/distribtest/ruby_debian10_x64.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/ruby_debian10_x64@sha256:1298c39c950b2a48261555b6cff1ae66230a5020f100d3b381759285f0caf84e",
"tools/dockerfile/distribtest/ruby_debian10_x64_ruby_2_7.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/ruby_debian10_x64_ruby_2_7@sha256:5ee26ad3abe2683c9a8ee03987ab0ae63f50793c3d3f5e4be6e6cbacb4556fcf",
"tools/dockerfile/distribtest/ruby_debian10_x64_ruby_3_0.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/ruby_debian10_x64_ruby_3_0@sha256:9190da90a2a95eca1370cef64dcba7ddee9f59cc7487093da6711c1280a0b0f9",
"tools/dockerfile/distribtest/ruby_ubuntu1804_x64.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/ruby_ubuntu1804_x64@sha256:d38b3dd34cffc027e9a1bf82bc7ace75b8a9829c2d04d5cf7cc8323655edd27a",
"tools/dockerfile/distribtest/ruby_ubuntu2004_x64.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/ruby_ubuntu2004_x64@sha256:426cbf625df0c0e7451b9716041996dc6a35a3788c1a24d68891256f84733d8e",
"tools/dockerfile/distribtest/ruby_ubuntu2204_x64.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/ruby_ubuntu2204_x64@sha256:1c74c312f8a4ab37e629732a35daa3056e12136b90f37540cdf9fa11303c7eb8",
"tools/dockerfile/grpc_artifact_centos6_x64.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/grpc_artifact_centos6_x64@sha256:3285047265ea2b7c5d4df4c769b2d05f56288d947c75e16d27ae2dee693f791b",
"tools/dockerfile/grpc_artifact_centos6_x86.current_version": "docker://us-docker.pkg.dev/grpc-testing/testing-images-public/grpc_artifact_centos6_x86@sha256:19783239da92208f0f39cf563529cd02e889920497ef81c60d20391fa998af62",
Expand Down

This file was deleted.

22 changes: 0 additions & 22 deletions tools/dockerfile/distribtest/python_dev_ubuntu1804_x64/Dockerfile

This file was deleted.

This file was deleted.

19 changes: 0 additions & 19 deletions tools/dockerfile/distribtest/python_ubuntu1804_x64/Dockerfile

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
us-docker.pkg.dev/grpc-testing/testing-images-public/ruby_ubuntu2004_x64:41b5e3380e01ef6687e29071fedc6d9b90d96d09@sha256:426cbf625df0c0e7451b9716041996dc6a35a3788c1a24d68891256f84733d8e
Loading

0 comments on commit 14de336

Please sign in to comment.