dotnet-kube-client: Watch request fails with InvalidOperationException
There is a log call introduced in https://github.com/tintoy/dotnet-kube-client/commit/8cda77d93971eba77c3817c5a12f169442652f87 that uses PathAndQuery property of created request.
https://github.com/tintoy/dotnet-kube-client/blob/1e08492a6da6ce484ae4b9e5e2ec66a38fe802da/src/KubeClient/ResourceClients/KubeResourceClient.cs#L596-L598
But HttpRequest created by factory is relative URI, so on attempts to call ObserveLines I’m getting exception in Observable OnError:
Unexpected error while streaming from the Kubernetes API to \"watch v1/Endpoints 'some-service' in namespace dev\".","exceptions":["System.InvalidOperationException: This operation is not supported for a relative URI."," at System.Uri.get_PathAndQuery()"," at KubeClient.ResourceClients.KubeResourceClient.<>c__DisplayClass30_0.<<ObserveLines>b__0>d.MoveNext()
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 18 (12 by maintainers)
Commits related to this issue
- Fix InvalidOperationException when logging relative Uris. #163 — committed to tintoy/dotnet-kube-client by tintoy 2 years ago
- When using UriBuilder, pass uri.OriginalString The BCL’s handling of relative URIs is pretty broken. #163 — committed to tintoy/dotnet-kube-client by tintoy 2 years ago
- Simplify logic for SafeGetPathAndQuery by converting relative URIs into absolute ones #163 — committed to tintoy/dotnet-kube-client by tintoy 2 years ago
- Tidy up logging code for Watch streams #163 — committed to tintoy/dotnet-kube-client by tintoy 2 years ago
- Add test for logging from custom request action #163 — committed to tintoy/dotnet-kube-client by tintoy 2 years ago
Good catch! Done 🙂
Publishing v2.5.12…
BTW, I will probably remove that log statement (eventually) as KubeClient’s existing request/response logging will already include that populated URI.
Cool, thank you for quick fix!
Definitely agree; will leave that for later, but can at least make the logging conditional on the configured log level. Will publish a release version tomorrow morning.
It’s your choice, but as far as I understand this bug impacts all watch requests in your library, so this enhancement could be part of separate PR if it need time.
Tested in k8s new version, watch request works as expected. Log entry:
Start streaming \"GET\" request for \"/api/v1/watch/namespaces/%7BNamespace%7D/endpoints/%7BServiceName%7D\It has no route params, but probably it’s ok for debug log)Good catch! Thanks, I’ll get that fixed tomorrow 🙂