Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid log warning for tls_context if the user didn't set it #365

Merged
merged 6 commits into from
Jun 19, 2020
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion source/client/options_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,14 @@ CommandLineOptionsPtr OptionsImpl::toCommandLineOptionsInternal() const {
request_options->mutable_request_body_size()->set_value(requestBodySize());
}
}
*(command_line_options->mutable_tls_context()) = tls_context_;

// Only set the tls context if it looks non-empty, to avoid a warning being logged about field
// deprecation. Ideally this would follow the way transport_socket uses absl::optional below.
// But as this field is about to get eliminated this minimal effort shortcut may be more suitable.
if (!Envoy::MessageUtil()(tls_context_,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we add a comment explaining how we are using Envoy::MessageUtil to verify that the tls_context_ message is non-empty?

(optional) On another note - isn't there a more direct way of checking if it is non-empty? E.g. proto2 used to have a method that could be used for that - my_proto.ByteSizeLong() == 0. However that call tends to be very inefficient on messages with many nested fields and I am unsure if it works in proto3 also.

Copy link
Member Author

Choose a reason for hiding this comment

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

I found that theres also Envoy::Protobuf::util::MessageDifferencer::Equivalent these days, which I think is easier to grok. See 6b8a088, does that look better?

envoy::extensions::transport_sockets::tls::v3::UpstreamTlsContext())) {
*(command_line_options->mutable_tls_context()) = tls_context_;
}
if (transport_socket_.has_value()) {
*(command_line_options->mutable_transport_socket()) = transport_socket_.value();
}
Expand Down