Skip to content

feat: Fail fast when insecure channel is not configured for .NET Core 3.1 with gRPC#2691

Merged
alanwest merged 35 commits into
open-telemetry:mainfrom
tomkerkhove:ssl-check
Dec 17, 2021
Merged

feat: Fail fast when insecure channel is not configured for .NET Core 3.1 with gRPC#2691
alanwest merged 35 commits into
open-telemetry:mainfrom
tomkerkhove:ssl-check

Conversation

@tomkerkhove

Copy link
Copy Markdown
Contributor

Signed-off-by: Tom Kerkhove kerkhove.tom@gmail.com

Fixes #2690.

Changes

Fail fast when unsecure channel is not configured for .NET Core 3.1 which is required for the OTLP exporter to work correctly.

This was not configured correctly and costed me a few hours to remind myself to configure this.

For significant contributions please make sure you have completed the following items:

  • CHANGELOG.md updated for non-trivial changes
  • [ ] Design discussion issue #
  • [ ] Changes in public API reviewed

… 3.1

Signed-off-by: Tom Kerkhove <kerkhove.tom@gmail.com>
@tomkerkhove tomkerkhove requested a review from a team November 26, 2021 08:51
Signed-off-by: Tom Kerkhove <kerkhove.tom@gmail.com>
@tomkerkhove

Copy link
Copy Markdown
Contributor Author

Finalizing running tests locally as well, but feel free to trigger the CI for this as well.

Signed-off-by: Tom Kerkhove <kerkhove.tom@gmail.com>
pellared
pellared previously approved these changes Nov 26, 2021
Signed-off-by: Tom Kerkhove <kerkhove.tom@gmail.com>
@pellared pellared dismissed their stale review November 26, 2021 13:02

I have not tested the HTTP protocol properly

@codecov

codecov Bot commented Nov 26, 2021

Copy link
Copy Markdown

Codecov Report

Merging #2691 (b7446aa) into main (fd2aa0b) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #2691   +/-   ##
=======================================
  Coverage   83.81%   83.82%           
=======================================
  Files         250      251    +1     
  Lines        8817     8828   +11     
=======================================
+ Hits         7390     7400   +10     
- Misses       1427     1428    +1     
Impacted Files Coverage Δ
...mentation/ExportClient/BaseOtlpGrpcExportClient.cs 50.00% <100.00%> (+3.33%) ⬆️
...mentation/ExportClient/ExporterClientValidation.cs 100.00% <100.00%> (ø)
...emetry.Api/Internal/OpenTelemetryApiEventSource.cs 79.41% <0.00%> (-2.95%) ⬇️

Signed-off-by: Tom Kerkhove <kerkhove.tom@gmail.com>
Signed-off-by: Tom Kerkhove <kerkhove.tom@gmail.com>
@tomkerkhove tomkerkhove requested a review from pellared November 26, 2021 14:53
Signed-off-by: Tom Kerkhove <kerkhove.tom@gmail.com>
@tomkerkhove

Copy link
Copy Markdown
Contributor Author

This has not been my best PR, sorry @pellared 🤦‍♂️

Signed-off-by: Tom Kerkhove <kerkhove.tom@gmail.com>
Signed-off-by: Tom Kerkhove <kerkhove.tom@gmail.com>
Signed-off-by: Tom Kerkhove <kerkhove.tom@gmail.com>
Signed-off-by: Tom Kerkhove <kerkhove.tom@gmail.com>
@tomkerkhove tomkerkhove changed the title feat: Fail fast when unsecure channel is not configured for .NET Core 3.1 feat: Fail fast when unsecure channel is not configured for .NET Core 3.1 with gRPC Nov 29, 2021
@tomkerkhove

Copy link
Copy Markdown
Contributor Author

@pellared As you can see the build directive is not respected in https://github.com/open-telemetry/opentelemetry-dotnet/runs/4350754547?check_suite_focus=true

As per https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/preprocessor-directives#conditional-compilation you'll notice that NETCOREAPP3_1 is no longer supported as per .NET 5+ SDK which was why I went with the not standard nor .NET 5 or above approach

@pellared

Copy link
Copy Markdown
Member

@pellared As you can see the build directive is not respected in https://github.com/open-telemetry/opentelemetry-dotnet/runs/4350754547?check_suite_focus=true

As per https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/preprocessor-directives#conditional-compilation you'll notice that NETCOREAPP3_1 is no longer supported as per .NET 5+ SDK which was why I went with the not standard nor .NET 5 or above approach

I see but now it fails on .NET Core 3.1 🤦

@tomkerkhove

Copy link
Copy Markdown
Contributor Author

Ok so I see the issue here, I think, is that while the Docker Compose file is getting the correct target framework & SDK version (https://github.com/open-telemetry/opentelemetry-dotnet/blob/main/build/docker-compose.netcoreapp3.1.yml#L7-L8), it is using a .NET 6 base image:

Step 1/12 : ARG SDK_VERSION=6.0
Step 2/12 : FROM mcr.microsoft.com/dotnet/sdk:6.0-focal AS build

Details: https://github.com/open-telemetry/opentelemetry-dotnet/blob/main/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/Dockerfile#L6

So that means that the directive that I've switched back to per #2691 (comment) is not available and thus not running the new validation. So I'd suggest going back to using this:

#if !NETSTANDARD2_1 && !NET5_0_OR_GREATER instead of #if NETCOREAPP3_1, or change the image for .NET 3.1 tests (less ideal)

Signed-off-by: Tom Kerkhove <kerkhove.tom@gmail.com>
Signed-off-by: Tom Kerkhove <kerkhove.tom@gmail.com>
@tomkerkhove

Copy link
Copy Markdown
Contributor Author

Changed it already but of course the check is now failing for .NET Framework.

Chatted with @pellared offline and he raised a valid concern - Given we use .NET 6 as a base image we might have other .NET Core 3.1 build directives that are being ignored.

What I would propose, @cijothomas, would be to:

  1. Use #if NETCOREAPP3_1 in the code
  2. Change the integration test workflow on (https://github.com/open-telemetry/opentelemetry-dotnet/blob/main/.github/workflows/integration.yml#L92) so that there is another Dockerfile being used for .NET Core 3.1 so that it's not using .NET 6 but 3.1 instead as this is required per https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/preprocessor-directives#conditional-compilation

That way we explicitly target this to only run for .NET Core 3.1, and be able to test this.

Signed-off-by: Tom Kerkhove <kerkhove.tom@gmail.com>
Signed-off-by: Tom Kerkhove <kerkhove.tom@gmail.com>
@tomkerkhove

Copy link
Copy Markdown
Contributor Author

The test is still failing and I will check tomorrow;

@alanwest

alanwest commented Dec 7, 2021

Copy link
Copy Markdown
Member

The test is still failing and I will check tomorrow;

If I were to guess it's the enabling of the switch by this test that causes a conflict with the ConstructingGrpcExporterFailsWhenHttp2UnencryptedSupportIsNotConfiguredForNetcoreapp31 test

https://github.com/open-telemetry/opentelemetry-dotnet/pull/2691/files#diff-ea318d753fea852e284d62944e2e6293f83e44cfb12628b3594685e7f13f1763L36-L44.

It's probably safe to just remove the ConstructingGrpcExporterFailsWhenHttp2UnencryptedSupportIsNotConfiguredForNetcoreapp31 test. I think the two tests that explicitly enable and disable the switch should cover us.

@tomkerkhove

Copy link
Copy Markdown
Contributor Author

This must have been my worst PR ever, but hey, it looks like we are ready :)

Thanks for the help!

@pellared pellared left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is it not worth creating an issue to remove this feature when .NET Core 3.1 is no longer supported?

Signed-off-by: Tom Kerkhove <kerkhove.tom@gmail.com>
Signed-off-by: Tom Kerkhove <kerkhove.tom@gmail.com>
@tomkerkhove

Copy link
Copy Markdown
Contributor Author

PTAL @pellared, @alanwest and @cijothomas

@tomkerkhove

Copy link
Copy Markdown
Contributor Author

@pellared are those the final remarks or do you want to do a full review?

I'm happy to keep on changing things but at some point we'll need to just complete the review.

@pellared

pellared commented Dec 9, 2021

Copy link
Copy Markdown
Member

I made a full review. That is also why I approved the PR.

@pellared pellared dismissed cijothomas’s stale review December 9, 2021 12:21

approach changed

Signed-off-by: Tom Kerkhove <kerkhove.tom@gmail.com>
@tomkerkhove

Copy link
Copy Markdown
Contributor Author

I made a full review. That is also why I approved the PR.

Thanks.

Comment thread src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md Outdated
Comment thread src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md Outdated
tomkerkhove and others added 2 commits December 10, 2021 07:49
Co-authored-by: Cijo Thomas <cithomas@microsoft.com>
Co-authored-by: Cijo Thomas <cithomas@microsoft.com>
@pellared pellared changed the title feat: Fail fast when unsecure channel is not configured for .NET Core 3.1 with gRPC feat: Fail fast when insecure channel is not configured for .NET Core 3.1 with gRPC Dec 10, 2021
@tomkerkhove

Copy link
Copy Markdown
Contributor Author

Any thoughts on this @cijothomas ?

@alanwest alanwest merged commit 1191a2a into open-telemetry:main Dec 17, 2021
@tomkerkhove tomkerkhove deleted the ssl-check branch December 17, 2021 08:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fail fast when unsecure channel is not configured correctly in .NET 3.1

4 participants