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

Conversation

oschaaf
Copy link
Member

@oschaaf oschaaf commented Jun 16, 2020

Fixes #364

Signed-off-by: Otto van der Schaaf oschaaf@we-amp.com

set it.

Fixes envoyproxy#364

Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
@oschaaf oschaaf added P1 waiting-for-review A PR waiting for a review. labels Jun 16, 2020
oschaaf added 2 commits June 16, 2020 21:37
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
@mum4k mum4k self-requested a review June 17, 2020 20:29
@mum4k mum4k self-assigned this Jun 17, 2020
// 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?

@mum4k mum4k added waiting-for-changes A PR waiting for comments to be resolved and changes to be applied. and removed waiting-for-review A PR waiting for a review. labels Jun 17, 2020
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
@oschaaf oschaaf added waiting-for-review A PR waiting for a review. and removed waiting-for-changes A PR waiting for comments to be resolved and changes to be applied. labels Jun 18, 2020
// But as this field is about to get eliminated this minimal effort shortcut may be more suitable.
if (!Envoy::MessageUtil()(tls_context_,
envoy::extensions::transport_sockets::tls::v3::UpstreamTlsContext())) {
if (!Envoy::Protobuf::util::MessageDifferencer::Equivalent(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Note - equivalent is not the same as equal. This would say that two messages are the same if one has a value set to zero and the other one has it unset where the default is zero.

Considering we are using this to determine if the message is unset, is that behavior desired?

Copy link
Member Author

Choose a reason for hiding this comment

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

That is a good catch, thanks. Thinking this through, you're right, this isn't what we need here. I switched this to use the ByteSizeLong() method you pointed out. I'm not super concerned about it not being the fastest way to pull this off, as it is going to be eliminated at some point. Plus this isn't in the hot path. Addressed in f467e86

@mum4k mum4k added waiting-for-changes A PR waiting for comments to be resolved and changes to be applied. and removed waiting-for-review A PR waiting for a review. labels Jun 18, 2020
@oschaaf oschaaf added waiting-for-review A PR waiting for a review. and removed waiting-for-changes A PR waiting for comments to be resolved and changes to be applied. labels Jun 18, 2020
@mum4k mum4k merged commit 1f1634c into envoyproxy:master Jun 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P1 waiting-for-review A PR waiting for a review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CLI: log spam with warning about deprecated tls_context being used
2 participants