diff --git a/src/core/ext/filters/channel_idle/legacy_channel_idle_filter.cc b/src/core/ext/filters/channel_idle/legacy_channel_idle_filter.cc index b560b92f59c..6b0582afc0c 100644 --- a/src/core/ext/filters/channel_idle/legacy_channel_idle_filter.cc +++ b/src/core/ext/filters/channel_idle/legacy_channel_idle_filter.cc @@ -207,7 +207,7 @@ void LegacyMaxAgeFilter::PostInit() { // OnDone -- close the connection if the promise completed // successfully. // (if it did not, it was cancelled) - if (status.ok()) CloseChannel(); + if (status.ok()) CloseChannel("max connection age"); }, std::move(arena))); } @@ -273,16 +273,16 @@ void LegacyChannelIdleFilter::StartIdleTimer() { activity_.Set(MakeActivity( std::move(promise), ExecCtxWakeupScheduler{}, [channel_stack, this](absl::Status status) { - if (status.ok()) CloseChannel(); + if (status.ok()) CloseChannel("connection idle"); }, std::move(arena))); } -void LegacyChannelIdleFilter::CloseChannel() { +void LegacyChannelIdleFilter::CloseChannel(absl::string_view reason) { auto* op = grpc_make_transport_op(nullptr); op->disconnect_with_error = grpc_error_set_int( - GRPC_ERROR_CREATE("enter idle"), - StatusIntProperty::ChannelConnectivityState, GRPC_CHANNEL_IDLE); + GRPC_ERROR_CREATE(reason), StatusIntProperty::ChannelConnectivityState, + GRPC_CHANNEL_IDLE); // Pass the transport op down to the channel stack. auto* elem = grpc_channel_stack_element(channel_stack_, 0); elem->filter->start_transport_op(elem, op); diff --git a/src/core/ext/filters/channel_idle/legacy_channel_idle_filter.h b/src/core/ext/filters/channel_idle/legacy_channel_idle_filter.h index 9ee7981b2f5..74bf3a2f09b 100644 --- a/src/core/ext/filters/channel_idle/legacy_channel_idle_filter.h +++ b/src/core/ext/filters/channel_idle/legacy_channel_idle_filter.h @@ -69,7 +69,7 @@ class LegacyChannelIdleFilter : public ChannelFilter { grpc_channel_stack* channel_stack() { return channel_stack_; }; virtual void Shutdown(); - void CloseChannel(); + void CloseChannel(absl::string_view reason); void IncreaseCallCount(); void DecreaseCallCount(); diff --git a/test/core/end2end/tests/max_connection_age.cc b/test/core/end2end/tests/max_connection_age.cc index 03252855cf1..3b13e36458e 100644 --- a/test/core/end2end/tests/max_connection_age.cc +++ b/test/core/end2end/tests/max_connection_age.cc @@ -20,6 +20,7 @@ #include +#include "gmock/gmock.h" #include "gtest/gtest.h" #include @@ -109,6 +110,8 @@ CORE_END2END_TEST(Http2Test, MaxAgeForciblyClose) { // The connection should be closed immediately after the max age grace period, // the in-progress RPC should fail. EXPECT_EQ(server_status.status(), GRPC_STATUS_UNAVAILABLE); + EXPECT_THAT(server_status.message(), + ::testing::MatchesRegex("max connection age")); } CORE_END2END_TEST(Http2Test, MaxAgeGracefullyClose) {