[ChannelIdleFilter] Use different error messages for idleness and max connection age

pull/37709/head
Yash Tibrewal 5 months ago
parent 1f70b34fb1
commit 4217a5b7c3
  1. 10
      src/core/ext/filters/channel_idle/legacy_channel_idle_filter.cc
  2. 2
      src/core/ext/filters/channel_idle/legacy_channel_idle_filter.h
  3. 3
      test/core/end2end/tests/max_connection_age.cc

@ -207,7 +207,7 @@ void LegacyMaxAgeFilter::PostInit() {
// OnDone -- close the connection if the promise completed // OnDone -- close the connection if the promise completed
// successfully. // successfully.
// (if it did not, it was cancelled) // (if it did not, it was cancelled)
if (status.ok()) CloseChannel(); if (status.ok()) CloseChannel("max connection age");
}, },
std::move(arena))); std::move(arena)));
} }
@ -273,16 +273,16 @@ void LegacyChannelIdleFilter::StartIdleTimer() {
activity_.Set(MakeActivity( activity_.Set(MakeActivity(
std::move(promise), ExecCtxWakeupScheduler{}, std::move(promise), ExecCtxWakeupScheduler{},
[channel_stack, this](absl::Status status) { [channel_stack, this](absl::Status status) {
if (status.ok()) CloseChannel(); if (status.ok()) CloseChannel("connection idle");
}, },
std::move(arena))); std::move(arena)));
} }
void LegacyChannelIdleFilter::CloseChannel() { void LegacyChannelIdleFilter::CloseChannel(absl::string_view reason) {
auto* op = grpc_make_transport_op(nullptr); auto* op = grpc_make_transport_op(nullptr);
op->disconnect_with_error = grpc_error_set_int( op->disconnect_with_error = grpc_error_set_int(
GRPC_ERROR_CREATE("enter idle"), GRPC_ERROR_CREATE(reason), StatusIntProperty::ChannelConnectivityState,
StatusIntProperty::ChannelConnectivityState, GRPC_CHANNEL_IDLE); GRPC_CHANNEL_IDLE);
// Pass the transport op down to the channel stack. // Pass the transport op down to the channel stack.
auto* elem = grpc_channel_stack_element(channel_stack_, 0); auto* elem = grpc_channel_stack_element(channel_stack_, 0);
elem->filter->start_transport_op(elem, op); elem->filter->start_transport_op(elem, op);

@ -69,7 +69,7 @@ class LegacyChannelIdleFilter : public ChannelFilter {
grpc_channel_stack* channel_stack() { return channel_stack_; }; grpc_channel_stack* channel_stack() { return channel_stack_; };
virtual void Shutdown(); virtual void Shutdown();
void CloseChannel(); void CloseChannel(absl::string_view reason);
void IncreaseCallCount(); void IncreaseCallCount();
void DecreaseCallCount(); void DecreaseCallCount();

@ -20,6 +20,7 @@
#include <memory> #include <memory>
#include "gmock/gmock-matchers.h"
#include "gtest/gtest.h" #include "gtest/gtest.h"
#include <grpc/impl/channel_arg_names.h> #include <grpc/impl/channel_arg_names.h>
@ -109,6 +110,8 @@ CORE_END2END_TEST(Http2Test, MaxAgeForciblyClose) {
// The connection should be closed immediately after the max age grace period, // The connection should be closed immediately after the max age grace period,
// the in-progress RPC should fail. // the in-progress RPC should fail.
EXPECT_EQ(server_status.status(), GRPC_STATUS_UNAVAILABLE); EXPECT_EQ(server_status.status(), GRPC_STATUS_UNAVAILABLE);
EXPECT_THAT(server_status.message(),
::testing::MatchesRegex("max connection age"));
} }
CORE_END2END_TEST(Http2Test, MaxAgeGracefullyClose) { CORE_END2END_TEST(Http2Test, MaxAgeGracefullyClose) {

Loading…
Cancel
Save