turbot / steampipe-plugin-kubernetes

Use SQL to instantly query Kubernetes API resources. Open source CLI. No DB required.
https://hub.steampipe.io/plugins/turbot/kubernetes
Apache License 2.0
45 stars 15 forks source link

Having runtime error when using context_name column #224

Closed burahimu closed 5 months ago

burahimu commented 5 months ago

Describe the bug Hello Team ! First, thanks a lot for this awesome plugin 🙏🏼

I encounter this kind of error with the plugin... When i try to use the context_name column (in my WHERE), I get a beautiful

Error: runtime error: invalid memory address or nil pointer dereference (SQLSTATE HV000).

Steampipe version (steampipe -v)

❯ steampipe -v
Steampipe v0.21.8

Foreign Data Wrapper version

v 1.9.3

Plugin version (steampipe plugin list)

v0.28.0

To reproduce Steps to reproduce the behavior (please include relevant code and/or commands).

Expected behavior A clear and concise description of what you expected to happen.

Additional context Add any other context about the problem here.

A dummy query with the trouble :

select context_name from kube_rtlmutu_prod.kubernetes_namespace where name = 'service-bedrock-zendesk' and context_name = 'prod5.k8s.6cloud.fr' ;

I've got the same with all tables.

details:

Database logs ``` 2024-05-24 15:20:52.242 UTC [TRACE] hub: goFdwGetPathKeys 2024-05-24 15:20:52.243 UTC [TRACE] hub: hub.GetPathKeys for connection 'kube_rtlmutu_prod`, table `kubernetes_service` 2024-05-24 15:20:52.243 UTC [TRACE] hub: hub.getConnectionPlugin for connection 'kube_rtlmutu_prod` 2024-05-24 15:20:52.243 UTC [TRACE] hub: connectionFactory getOrCreate hub.steampipe.io/plugins/turbot/kubernetes@latest kube_rtlmutu_prod 2024-05-24 15:20:52.243 UTC [TRACE] hub: connectionFactory get plugin: hub.steampipe.io/plugins/turbot/kubernetes@latest connection kube_rtlmutu_prod 2024-05-24 15:20:52.243 UTC [TRACE] hub: GetSchema for connection 'kube_rtlmutu_prod' 2024-05-24 15:20:52.244 UTC [TRACE] hub: schema response include ListCallKeyColumnList, it is using the updated protobuff interface 2024-05-24 15:20:52.244 UTC [TRACE] hub: columnPathsToPathKeys 4 column paths 39 all columns, 160 pathkeys 2024-05-24 15:20:52.244 UTC [TRACE] hub: GetPathKeys for connection 'kube_rtlmutu_prod`, table `kubernetes_service` returning 2024-05-24 15:20:52.245 UTC [INFO] hub: goFdwBeginForeignScan, connection 'kube_rtlmutu_prod', table 'kubernetes_service', explain: false 2024-05-24 15:20:52.245 UTC [TRACE] hub: RestrictionsToQuals: restriction T_OpExpr 2024-05-24 15:20:52.245 UTC [TRACE] hub: qualFromOpExpr 2024-05-24 15:20:52.245 UTC [TRACE] hub: getQualValue 2024-05-24 15:20:52.245 UTC [TRACE] hub: getQualValue T_Const qual, value 40439912 2024-05-24 15:20:52.245 UTC [TRACE] hub: qualFromOpExpr returning fieldName:"context_name" string_value:"=" value:{string_value:"prod5.k8s.6cloud.fr"} 2024-05-24 15:20:52.245 UTC [TRACE] hub: RestrictionsToQuals: converted postgres restrictions protobuf quals 2024-05-24 15:20:52.245 UTC [TRACE] hub: Column: context_name, Operator: '=', Value: 'prod5.k8s.6cloud.fr' 2024-05-24 15:20:52.245 UTC [TRACE] hub: Hub GetIterator() table 'kubernetes_service' 2024-05-24 15:20:52.245 UTC [TRACE] hub: Hub startScanForConnection 'kube_rtlmutu_prod' 2024-05-24 15:20:52.245 UTC [TRACE] hub: hub.getConnectionPlugin for connection 'kube_rtlmutu_prod` 2024-05-24 15:20:52.245 UTC [TRACE] hub: connectionFactory getOrCreate hub.steampipe.io/plugins/turbot/kubernetes@latest kube_rtlmutu_prod 2024-05-24 15:20:52.245 UTC [TRACE] hub: connectionFactory get plugin: hub.steampipe.io/plugins/turbot/kubernetes@latest connection kube_rtlmutu_prod 2024-05-24 15:20:52.246 UTC [TRACE] hub: buildConnectionLimitMap, table: 'kubernetes_service', 1 connection, limit: -1 2024-05-24 15:20:52.246 UTC [TRACE] hub: GetSchema for connection 'kube_rtlmutu_prod' 2024-05-24 15:20:52.248 UTC [TRACE] hub: shouldPushdownLimit found key column for column context_name: name:"context_name" operators:"=" operators:"<>" operators:"~~" operators:"~~*" operators:"!~~" operators:"!~~*" require:"optional" 2024-05-24 15:20:52.248 UTC [TRACE] hub: shouldPushdownLimit operator '=' is supported for column 'context_name'. 2024-05-24 15:20:52.248 UTC [INFO] hub: shouldPushdownLimit all quals are supported - pushing down limit 2024-05-24 15:20:52.248 UTC [INFO] hub: connection 'kube_rtlmutu_prod', table 'kubernetes_service', quals ---------------------------------------------------------------- Column: context_name, Operator: '=', Value: 'prod5.k8s.6cloud.fr' ---------------------------------------------------------------- 2024-05-24 15:20:52.248 UTC [TRACE] hub: startScanForConnection creating a new scan iterator 2024-05-24 15:20:52.248 UTC [TRACE] hub: Hub GetIterator() created iterator (0xc00017ad80) 2024-05-24 15:20:52.248 UTC [TRACE] hub: goFdwBeginForeignScan: save exec state &{0xc000839410 map[connection:kube_rtlmutu_prod table:kubernetes_service] 0xc00017ad80 0x26b2108} 2024-05-24 15:20:52.248 UTC [TRACE] hub: goFdwIterateForeignScan, table 'kubernetes_service' (0xc00017ad80) 2024-05-24 15:20:52.248 UTC [INFO] hub: goFdwIterateForeignScan calling pluginHub.StartScan, table 'kubernetes_service' (0xc00017ad80) 2024-05-24 15:20:52.248 UTC [INFO] hub: StartScan for table: kubernetes_service, cache enabled: false, iterator 0xc00017ad80, 1 quals (1716564052992) 2024-05-24 15:20:52.248 UTC [WARN] hub: stream receive error rpc error: code = Unknown desc = runtime error: invalid memory address or nil pointer dereference (0xc00017ad80) 2024-05-24 15:20:52.248 UTC [INFO] hub: goFdwIterateForeignScan Next returned error: rpc error: code = Unknown desc = runtime error: invalid memory address or nil pointer dereference (0xc00017ad80) 2024-05-24 15:20:52.248 UTC [947] ERROR: rpc error: code = Unknown desc = runtime error: invalid memory address or nil pointer dereference 2024-05-24 15:20:52.248 UTC [947] STATEMENT: select context_name from kube_rtlmutu_prod.kubernetes_service where context_name = 'prod5.k8s.6cloud.fr' 2024-05-24 15:20:52.248 UTC [INFO] hub: goFdwAbortCallback 2024-05-24 15:20:52.248 UTC [INFO] hub: Hub Abort ```
plugin logs ``` 2024-05-24 15:22:24.499 UTC [INFO] steampipe-plugin-kubernetes.plugin: [INFO] 1716564144421: Plugin execute table name: kubernetes_service quals: context_name &{=} string_value:"prod5.k8s.6cloud.fr", (1716564144421) 2024-05-24 15:22:24.499 UTC [INFO] steampipe-plugin-kubernetes.plugin: [INFO] 1716564144421: Setting max concurrent connections to 25 2024-05-24 15:22:24.499 UTC [INFO] steampipe-plugin-kubernetes.plugin: [INFO] 1716564144421: Plugin execute complete (1716564144421) ```
steampipe logs ``` 2024-05-24 15:22:24.485 UTC [TRACE] steampipe [4cc9]: ensureSessionSearchPath 2024-05-24 15:22:24.486 UTC [TRACE] steampipe [4cc9]: session search path is already correct - nothing to do 2024-05-24 15:22:24.486 UTC [TRACE] steampipe [4cc9]: DbClient.startQueryWithRetries start 2024-05-24 15:22:24.486 UTC [TRACE] steampipe [4cc9]: starting 1 2024-05-24 15:22:24.500 UTC [TRACE] steampipe [4cc9]: no queryError 2024-05-24 15:22:24.500 UTC [TRACE] steampipe [4cc9]: DbClient.startQueryWithRetries end ```

More obvious, i don't have any issue when i ran my query on my local steampipe instance (but got on my kubernetes deployment)

Edit: note that in 0.27.0 version everything works well

misraved commented 5 months ago

@burahimu could you please confirm if you are getting the same error on the latest Steampipe CLI(v0.23.2) and Kubernetes plugin version?

burahimu commented 5 months ago

Yes same error. Only with kubernetes@0.28.0 😞