microsoft / mindaro

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

Bridge to kubernetes failure on `Object reference not set to an instance of an object.` #336

Open gshaibi opened 2 years ago

gshaibi commented 2 years ago

Describe the bug Bridge to kubernetes fails with the error Object reference not set to an instance of an object.

To Reproduce Try to run bridge to kubernetes

Logs

2022-07-10T06:34:30.3101020Z | MindaroCli | TRACE | Event: Command.Start <json>{"properties":{"arguments":"prep-connect --output json --service runai-backend-service --namespace runai-backend","isRoutingEnabled":"false"},"metrics":null}</json>\nOperation context: <json>{"clientRequestId":null,"correlationId":"4af7f240-cfa8-4d66-9140-a7bb8c8ddabf1656840946006:d883aded194c","requestId":null,"userSubscriptionId":null,"startTime":"2022-07-10T06:34:30.1199190Z","userAgent":"VSCode/1.0.120220125","requestHttpMethod":null,"requestUri":null,"version":"1.0.20220125.5","requestHeaders":{},"loggingProperties":{"applicationName":"MindaroCli","deviceOperatingSystem":"Darwin 21.5.0 Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:22 PDT 2022; root:xnu-8020.121.3~4/RELEASE_X86_64","framework":".NET Core 3.1.9","macAddressHash":"04b9b4a4d9cff1203d3268dce5883fabb09abb61b87d67218c51c715208089e5","processId":5167,"targetEnvironment":"Production","commandId":"d883aded194c"}}</json>
2022-07-10T06:34:30.3673860Z | MindaroCli | TRACE | Running Microsoft.BridgeToKubernetes.Exe.Commands.Connect.PrepConnectCommand...\nOperation context: <json>{"clientRequestId":null,"correlationId":"4af7f240-cfa8-4d66-9140-a7bb8c8ddabf1656840946006:d883aded194c","requestId":null,"userSubscriptionId":null,"startTime":"2022-07-10T06:34:30.1199190Z","userAgent":"VSCode/1.0.120220125","requestHttpMethod":null,"requestUri":null,"version":"1.0.20220125.5","requestHeaders":{},"loggingProperties":{"applicationName":"MindaroCli","deviceOperatingSystem":"Darwin 21.5.0 Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:22 PDT 2022; root:xnu-8020.121.3~4/RELEASE_X86_64","framework":".NET Core 3.1.9","macAddressHash":"04b9b4a4d9cff1203d3268dce5883fabb09abb61b87d67218c51c715208089e5","processId":5167,"targetEnvironment":"Production","commandId":"d883aded194c","targetServiceName":"runai-backend-service"}}</json>
2022-07-10T06:34:35.8742530Z | MindaroCli | ERROR | Dependency: Prep Connect <json>{"target":null,"success":false,"duration":null,"properties":{"requestId":"null","clientRequestId":"null","correlationRequestId":"null"}}</json>
2022-07-10T06:34:36.3586000Z | MindaroCli | ERROR | An unexpected error occurred: 'Object reference not set to an instance of an object.'\n
2022-07-10T06:34:36.3593440Z | MindaroCli | ERROR | To see our active issues or file a bug report, please visit https://aka.ms/bridge-to-k8s-report.\n
2022-07-10T06:34:36.3600240Z | MindaroCli | ERROR | For diagnostic information, see logs at '/var/folders/fm/09kjthy12j5_ngdnxqgw7jsr0000gn/T/Bridge To Kubernetes'.\n
2022-07-10T06:34:36.3634950Z | MindaroCli | ERROR | Logging handled exception: System.NullReferenceException: {"ClassName":"System.NullReferenceException","Message":"Object reference not set to an instance of an object.","Data":null,"InnerException":null,"HelpURL":null,"StackTraceString":"   at Microsoft.BridgeToKubernetes.Library.Connect.WorkloadInformationProvider._CollectServicesToRouteAsync(String workloadNamespace, IEnumerable`1 services, CancellationToken cancellationToken)\n   at Microsoft.BridgeToKubernetes.Library.Connect.WorkloadInformationProvider.GetReachableEndpointsAsync(String namespaceName, ILocalProcessConfig localProcessConfig, Boolean includeSameNamespaceServices, CancellationToken cancellationToken)\n   at Microsoft.BridgeToKubernetes.Library.ManagementClients.ConnectManagementClient.<>c__DisplayClass18_0.<<GetElevationRequestsAsync>b__0>d.MoveNext()\n--- End of stack trace from previous location where exception was thrown ---\n   at Microsoft.BridgeToKubernetes.Library.ManagementClients.ManagementClientExceptionStrategy.RunWithHandlingAsync[T](Func`1 func, FailureConfig failureConfig)\n   at Microsoft.BridgeToKubernetes.Library.ManagementClients.ConnectManagementClient.GetElevationRequestsAsync(CancellationToken cancellationToken)\n   at Microsoft.BridgeToKubernetes.Exe.Commands.Connect.PrepConnectCommand.ExecuteAsync()\n   at Microsoft.BridgeToKubernetes.Exe.CliApp.RunCommandAsync(String[] args, CancellationToken cancellationToken)\n   at Microsoft.BridgeToKubernetes.Exe.CliApp.ExecuteAsync(String[] args, CancellationToken cancellationToken)","RemoteStackTraceString":null,"RemoteStackIndex":0,"ExceptionMethod":null,"HResult":-2147467261,"Source":"Microsoft.BridgeToKubernetes.Library","WatsonBuckets":null}
2022-07-10T06:34:36.3647610Z | MindaroCli | TRACE | Event: Command.End <json>{"properties":{"arguments":"prep-connect --output json --service runai-backend-service --namespace runai-backend","result":"Failed","failureReason":"Object reference not set to an instance of an object."},"metrics":{"duration":6115.0}}</json>

Environment Details Client used (VS Code/Visual Studio):

Client's version: mindaro.mindaro@1.0.120220125 Operating System: MacOS 12.4 **Additional context** Add any other outputs from the clients or context you would like to share.
williamohara commented 2 years ago

@gshaibi I had the same problem I found that there was mal formed endpoint for one of my services (one that I was not trying to debug).

run kubectl get endpoints to make sure all of your services have an endpoint defined. I had a port missing in the deployment spec of it

gshaibi commented 2 years ago

I'll check it out and update. Thanks @williamohara!

williamohara commented 2 years ago

@gshaibi check this out... https://github.com/microsoft/mindaro/issues/288 this feels like a bug with bridge to kubernetes - they should consider that some services will not have endpoints defined. my solution is more of a workaround.