microsoft / mindaro

Bridge to Kubernetes - for Visual Studio and Visual Studio Code
MIT License
307 stars 106 forks source link

Debug fails with 'A CA must be set when SkipTlsVerify === false' error #120

Open LesterThomas opened 3 years ago

LesterThomas commented 3 years ago

Describe the bug

Trying to debug a single nodejs microservice against a remote cluster. Initially, it selects the right kubernetes service (and so the kube config is set correctly and it is able to interact with the kubernetes API), but then the debugger fails with:

Error: Oops... An unexpected error has occurred.
For diagnostic information, see logs at 'C:\Users\leste\AppData\Local\Temp\Bridge To Kubernetes'.

The terminal process terminated with exit code: 1.

Fix

You can fix this by adding insecure-skip-tls-verify: true to the kubernetes config

- cluster:
    server: https://host/k8s/clusters/c-45kdh
    insecure-skip-tls-verify: true

I suggest this should be caught as a 'known error' with a helpful hint to fix.

Logs

The log file shows a failureReason: A CA must be set when SkipTlsVerify === false

2021-02-15T11:17:37.1463720Z | MindaroCli | ERROR | Logging handled exception: k8s.Exceptions.KubeConfigException: {"StackTrace":"   at k8s.Kubernetes.InitializeFromConfig(KubernetesClientConfiguration config)\r\n   at k8s.Kubernetes..ctor(KubernetesClientConfiguration config, DelegatingHandler[] handlers)\r\n   at Microsoft.DevSpaces.Common.Kubernetes.K8sClientFactory.CreateFromKubeConfig(K8SConfiguration kubeConfig)\r\n   at Microsoft.DevSpaces.Common.Kubernetes.KubernetesClient.<>c__DisplayClass6_0.<.ctor>b__0()\r\n   at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)\r\n   at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)\r\n   at System.Lazy`1.CreateValue()\r\n   at System.Lazy`1.get_Value()\r\n   at Microsoft.DevSpaces.Common.Kubernetes.KubernetesClient.get_RestClient()\r\n   at Microsoft.DevSpaces.Common.Kubernetes.KubernetesClient.<>c__DisplayClass35_0.<<ListServicesInNamespaceAsync>b__0>d.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at Microsoft.DevSpaces.Common.Kubernetes.KubernetesClient.<>c__DisplayClass63_0`1.<<ClientInvokeWrapperAsync>b__0>d.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at Microsoft.DevSpaces.Common.Utilities.WebUtilities.RetryUntilTimeAsync(Func`2 action, TimeSpan maxWaitTime, CancellationToken cancellationToken)\r\n   at Microsoft.DevSpaces.Common.Kubernetes.KubernetesClient.ClientInvokeWrapperAsync[T](Func`1 handler, String operation, CancellationToken cancellationToken)\r\n   at Microsoft.DevSpaces.Common.Kubernetes.KubernetesClient.ListServicesInNamespaceAsync(String namespaceName, IEnumerable`1 labels, CancellationToken cancellationToken)\r\n   at Microsoft.DevSpaces.Library.Connect.KubernetesRemoteEnvironmentManager.GetReachableServicesAsync(RemoteContainerConnectionDetails remoteContainerConnectionDetails, ILocalProcessConfig localProcessConfig, IProgress`1 progress, CancellationToken cancellationToken)\r\n   at Microsoft.DevSpaces.Library.ManagementClients.ConnectManagementClient.<>c__DisplayClass16_0.<<GetElevationRequestsAsync>b__0>d.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at Microsoft.DevSpaces.Library.ManagementClients.DevSpacesManagementClientExceptionStrategy.RunWithHandlingAsync[T](Func`1 func, FailureConfig failureConfig)\r\n   at Microsoft.DevSpaces.Library.ManagementClients.ConnectManagementClient.GetElevationRequestsAsync(IProgress`1 progress, CancellationToken cancellationToken)\r\n   at Microsoft.DevSpaces.Exe.Commands.Connect.PrepConnectCommand.ExecuteAsync()\r\n   at Microsoft.DevSpaces.Exe.DevSpacesCliApp.RunCommandAsync(String[] args, CancellationToken cancellationToken)\r\n   at Microsoft.DevSpaces.Exe.DevSpacesCliApp.ExecuteAsync(String[] args, CancellationToken cancellationToken)","Message":"A CA must be set when SkipTlsVerify === false","Data":{},"InnerException":null,"HelpLink":null,"Source":"KubernetesClient","HResult":-2146233088}
2021-02-15T11:17:37.1485228Z | MindaroCli | TRACE | Event: Command.End <json>{"properties":{"arguments":"prep-connect --output json","result":"Failed","failureReason":"A CA must be set when SkipTlsVerify === false"},"metrics":{"duration":1427.0}}</json>
amsoedal commented 3 years ago

Hi @LesterThomas, thanks so much for catching this issue & pointing it out. Will log a bug for us to improve the error message here. Thanks!