-
Notifications
You must be signed in to change notification settings - Fork 773
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
Validate Windows version when using WinHttpHandler #2229
Validate Windows version when using WinHttpHandler #2229
Conversation
Would still love to see a way of interrogating whether I can expect full gRPC feature support, but this is definitely a good start. |
There isn't one. WinHTTP doesn't have APIs to say whether the required features are available. The only test is the Windows version. If OS build version is greater or equal to WinServer 2022 then there is partial support. It's not perfect, but testing the build version isn't difficult. |
Sorry, I should have been clearer. That makes sense - but it makes less sense to me for each developer to have to find the details of precise OS/build versions, when that logic can be centralized - and when we're already fetching the build version for this feature. |
(If it's only Google that needs to do this, then I'm happy to put it in our code. I'd just be sad to see basically the same code in 100 different codebases around the world.) |
@@ -184,6 +184,18 @@ internal GrpcChannel(Uri address, GrpcChannelOptions channelOptions) : base(addr | |||
{ | |||
Log.AddressPathUnused(Logger, Address.OriginalString); | |||
} | |||
|
|||
// Validate the Windows version can support WinHttpHandler. | |||
const int WinServer2022BuildVersion = 20348; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the comment needs to elaborate on why this particular build version was chosen.
Basically, as you said
- If OS build version is greater or equal to WinServer 2022 then there is partial support.
- If OS build version is greater or equal to Win 11 then there is full support.
The also need to be a note that this will allow creating GrpcChannel on WinServer 2022 with "partial support" (and explain what that is).
@@ -41,5 +45,7 @@ private OperatingSystem() | |||
#else | |||
IsAndroid = false; | |||
#endif | |||
IsWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows); | |||
OSVersion = Environment.OSVersion.Version; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
excerpt from offline discussion:
I experimented with Environment.OSVersion and one issue I found is that when called from .NET Framework, it seems to return garbage on newer windows versions (e.g. I tried on Microsoft Windows Server 2019 Datacenter, 10.0.17763 Build 17763 and it returned "Microsoft Windows NT 6.2.9200.0"). Looks like the value returned is the latest windows version the .NET Framework knows about (Which is way too old now and not useful to us).
So some better way of detecting OS Version will be needed.
Can you confirm that this has been taken into account and that we really rely on Environment.OSVersion.Version providing the right info when on .NET Framework (which is actually where we care about it the most)?
This would also deserve a test that actually targets net462 (not sure if we currently have one).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw, if Environment.OSVersion.Version gives outdated info about build number, in practice this would mean that a high-enough build number would never be detected and creating the GrpcChannel would always throw on .NET Framework?
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [Google.Protobuf](https://togithub.com/protocolbuffers/protobuf) | nuget | patch | `3.24.2` -> `3.24.3` | | [Grpc.Net.Client](https://togithub.com/grpc/grpc-dotnet) | nuget | minor | `2.56.0` -> `2.57.0` | | [Testcontainers](https://dotnet.testcontainers.org/) ([source](https://togithub.com/testcontainers/testcontainers-dotnet)) | nuget | minor | `3.4.0` -> `3.5.0` | --- ### Release Notes <details> <summary>protocolbuffers/protobuf (Google.Protobuf)</summary> ### [`v3.24.3`](https://togithub.com/protocolbuffers/protobuf/compare/v3.24.2...v3.24.3) </details> <details> <summary>grpc/grpc-dotnet (Grpc.Net.Client)</summary> ### [`v2.57.0`](https://togithub.com/grpc/grpc-dotnet/releases/tag/v2.57.0) #### What's Changed - Start 2.57.x development cycle by [@​jtattermusch](https://togithub.com/jtattermusch) in [https://github.com/grpc/grpc-dotnet/pull/2227](https://togithub.com/grpc/grpc-dotnet/pull/2227) - Validate Windows version when using WinHttpHandler by [@​JamesNK](https://togithub.com/JamesNK) in [https://github.com/grpc/grpc-dotnet/pull/2229](https://togithub.com/grpc/grpc-dotnet/pull/2229) - Support infinite idle connection timeout values by [@​JamesNK](https://togithub.com/JamesNK) in [https://github.com/grpc/grpc-dotnet/pull/2231](https://togithub.com/grpc/grpc-dotnet/pull/2231) - Improve BalancerAttributes debugging by [@​JamesNK](https://togithub.com/JamesNK) in [https://github.com/grpc/grpc-dotnet/pull/2235](https://togithub.com/grpc/grpc-dotnet/pull/2235) - Update Grpc.Net.Client to remove ValueTask usage by [@​JamesNK](https://togithub.com/JamesNK) in [https://github.com/grpc/grpc-dotnet/pull/2222](https://togithub.com/grpc/grpc-dotnet/pull/2222) - Update Newtonsoft.Json to 13.0.3 by [@​JamesNK](https://togithub.com/JamesNK) in [https://github.com/grpc/grpc-dotnet/pull/2219](https://togithub.com/grpc/grpc-dotnet/pull/2219) - Consistently don't log message errors on cancellation by [@​JamesNK](https://togithub.com/JamesNK) in [https://github.com/grpc/grpc-dotnet/pull/2221](https://togithub.com/grpc/grpc-dotnet/pull/2221) - Fix load balancing flaky test by [@​JamesNK](https://togithub.com/JamesNK) in [https://github.com/grpc/grpc-dotnet/pull/2223](https://togithub.com/grpc/grpc-dotnet/pull/2223) - Improve comment in GrpcChannel for WinHttpHandler + OS validation by [@​JamesNK](https://togithub.com/JamesNK) in [https://github.com/grpc/grpc-dotnet/pull/2237](https://togithub.com/grpc/grpc-dotnet/pull/2237) - Update OS version detection to get version directly from Windows by [@​JamesNK](https://togithub.com/JamesNK) in [https://github.com/grpc/grpc-dotnet/pull/2239](https://togithub.com/grpc/grpc-dotnet/pull/2239) - Update implementation_comparison.md by [@​JamesNK](https://togithub.com/JamesNK) in [https://github.com/grpc/grpc-dotnet/pull/2240](https://togithub.com/grpc/grpc-dotnet/pull/2240) - Update to use .NET 8 by [@​JamesNK](https://togithub.com/JamesNK) in [https://github.com/grpc/grpc-dotnet/pull/2021](https://togithub.com/grpc/grpc-dotnet/pull/2021) - Bump semver from 6.3.0 to 6.3.1 in /testassets/InteropTestsGrpcWebWebsite/Tests by [@​dependabot](https://togithub.com/dependabot) in [https://github.com/grpc/grpc-dotnet/pull/2243](https://togithub.com/grpc/grpc-dotnet/pull/2243) - Force yielding after awaiting CallTask to avoid holding onto locks by [@​JamesNK](https://togithub.com/JamesNK) in [https://github.com/grpc/grpc-dotnet/pull/2245](https://togithub.com/grpc/grpc-dotnet/pull/2245) - Update Grpc.Net.Client to use ActivitySource by [@​JamesNK](https://togithub.com/JamesNK) in [https://github.com/grpc/grpc-dotnet/pull/2244](https://togithub.com/grpc/grpc-dotnet/pull/2244) - Clear IAsyncStreamReader<T>.Current value before reading next value by [@​JamesNK](https://togithub.com/JamesNK) in [https://github.com/grpc/grpc-dotnet/pull/2248](https://togithub.com/grpc/grpc-dotnet/pull/2248) - Upgrade QpsWorker to net8 by [@​jtattermusch](https://togithub.com/jtattermusch) in [https://github.com/grpc/grpc-dotnet/pull/2250](https://togithub.com/grpc/grpc-dotnet/pull/2250) - Change subchannel ID to include a channel ID by [@​JamesNK](https://togithub.com/JamesNK) in [https://github.com/grpc/grpc-dotnet/pull/2253](https://togithub.com/grpc/grpc-dotnet/pull/2253) - Update Grpc.Tools dependency to 2.57.0 by [@​jtattermusch](https://togithub.com/jtattermusch) in [https://github.com/grpc/grpc-dotnet/pull/2257](https://togithub.com/grpc/grpc-dotnet/pull/2257) - Add transport status to subchannel picked log by [@​JamesNK](https://togithub.com/JamesNK) in [https://github.com/grpc/grpc-dotnet/pull/2261](https://togithub.com/grpc/grpc-dotnet/pull/2261) - Reduce logger allocations by not using generic CreateLogger by [@​JamesNK](https://togithub.com/JamesNK) in [https://github.com/grpc/grpc-dotnet/pull/2256](https://togithub.com/grpc/grpc-dotnet/pull/2256) - Update call debugger display to show status code by [@​JamesNK](https://togithub.com/JamesNK) in [https://github.com/grpc/grpc-dotnet/pull/2259](https://togithub.com/grpc/grpc-dotnet/pull/2259) - Log socket lifetime when closing unusable sockets by [@​JamesNK](https://togithub.com/JamesNK) in [https://github.com/grpc/grpc-dotnet/pull/2258](https://togithub.com/grpc/grpc-dotnet/pull/2258) - Fix unobserved exceptions with retries by [@​JamesNK](https://togithub.com/JamesNK) in [https://github.com/grpc/grpc-dotnet/pull/2255](https://togithub.com/grpc/grpc-dotnet/pull/2255) - Change subchannel BalancerAddress when attributes change by [@​JamesNK](https://togithub.com/JamesNK) in [https://github.com/grpc/grpc-dotnet/pull/2228](https://togithub.com/grpc/grpc-dotnet/pull/2228) - Fix connection bugs from BalancerAddress changes by [@​JamesNK](https://togithub.com/JamesNK) in [https://github.com/grpc/grpc-dotnet/pull/2265](https://togithub.com/grpc/grpc-dotnet/pull/2265) - \[v2.57.x] Update version to 2.57.0-pre1 by [@​jtattermusch](https://togithub.com/jtattermusch) in [https://github.com/grpc/grpc-dotnet/pull/2266](https://togithub.com/grpc/grpc-dotnet/pull/2266) - \[2.57.x] Update version to 2.57.0 by [@​jtattermusch](https://togithub.com/jtattermusch) in [https://github.com/grpc/grpc-dotnet/pull/2272](https://togithub.com/grpc/grpc-dotnet/pull/2272) **Full Changelog**: grpc/grpc-dotnet@v2.56.0...v2.57.0 </details> <details> <summary>testcontainers/testcontainers-dotnet (Testcontainers)</summary> ### [`v3.5.0`](https://togithub.com/testcontainers/testcontainers-dotnet/releases/tag/3.5.0) [Compare Source](https://togithub.com/testcontainers/testcontainers-dotnet/compare/3.4.0...3.5.0) ### What's Changed #### 🚀 Features - feat: Allow MongoDb module configuration without credentials ([#​983](https://togithub.com/testcontainers/testcontainers-dotnet/issues/983)) [@​the-avid-engineer](https://togithub.com/the-avid-engineer) - feat: Add support for RSA private key (RsaPrivateCrtKeyParameters) TLS authentication with protected Docker daemon sockets ([#​978](https://togithub.com/testcontainers/testcontainers-dotnet/issues/978)) [@​zuntio](https://togithub.com/zuntio) - feat: Add InfluxDb module ([#​975](https://togithub.com/testcontainers/testcontainers-dotnet/issues/975)) [@​MelomanG](https://togithub.com/MelomanG) #### 🐛 Bug Fixes - fix: Do not pre pull Dockerfile build stages that do not correspond to base images ([#​979](https://togithub.com/testcontainers/testcontainers-dotnet/issues/979)) [@​HofmeisterAn](https://togithub.com/HofmeisterAn) #### 📖 Documentation - docs: Add documentation on enabling debug log messages for the default logger ([#​991](https://togithub.com/testcontainers/testcontainers-dotnet/issues/991)) [@​HofmeisterAn](https://togithub.com/HofmeisterAn) - docs: Add global Testcontainers header ([#​967](https://togithub.com/testcontainers/testcontainers-dotnet/issues/967)) [@​leocross](https://togithub.com/leocross) #### 🧹 Housekeeping - chore: Improve error message when Docker is not running ([#​987](https://togithub.com/testcontainers/testcontainers-dotnet/issues/987)) [@​0xced](https://togithub.com/0xced) - chore: Update BouncyCastle.Cryptography to 2.2.1 (previous Portable.BouncyCastle) ([#​985](https://togithub.com/testcontainers/testcontainers-dotnet/issues/985)) [@​jcmrva](https://togithub.com/jcmrva) - chore: Add User-Agent HTTP header to Docker.DotNet client ([#​970](https://togithub.com/testcontainers/testcontainers-dotnet/issues/970)) [@​eddumelendez](https://togithub.com/eddumelendez) - chore: Remove `CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT` env var ([#​971](https://togithub.com/testcontainers/testcontainers-dotnet/issues/971)) [@​eddumelendez](https://togithub.com/eddumelendez) </details> --- ### Configuration 📅 **Schedule**: Branch creation - "before 4am on Monday" (UTC), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 👻 **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://togithub.com/renovatebot/renovate/discussions) if that's undesired. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/cerbos/cerbos-sdk-net). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi44My4wIiwidXBkYXRlZEluVmVyIjoiMzYuODMuMCIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==--> Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Signed-off-by: Oğuzhan Durgun <[email protected]> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Fixes #2226
cc @jtattermusch @jskeet