mondoohq / cnquery

open source, cloud-native, graph-based asset inventory
https://cnquery.io
Other
311 stars 20 forks source link

k8s output is confusing #837

Open vjeffrey opened 1 year ago

vjeffrey commented 1 year ago

Describe the bug if i try to run a query that's targeted to, for example, a single pod on the k8s transport, i get a bunch of errors

cnquery run k8s -c "k8s.pod { podSpec['volumes'] == null || podSpec['volumes'].all(_['hostPath']['path'] != '/var/run/docker.sock') }
… dquote ❯ "
→ discover related assets for 1 asset(s)
→ use cluster name from kube config cluster-name=minikube
→ discovery option auto is used. This will detect the assets: cluster, jobs, cronjobs, pods, statefulsets, deployments, replicasets, daemonsets
→ resolved assets resolved-assets=26
Query encountered errors:
failed to create resource 'k8s.pod': cannot use resource without specifying id or name/namespace
k8s.pod: no data available
Query encountered errors:
failed to create resource 'k8s.pod': could not find resource
k8s.pod: no data available
Query encountered errors:
failed to create resource 'k8s.pod': could not find resource
k8s.pod: no data available
Query encountered errors:
failed to create resource 'k8s.pod': could not find resource
k8s.pod: no data available
k8s.pod: {
  podSpec[volumes] == null || <ref>: true
}
k8s.pod: {
  podSpec[volumes] == null || <ref>: true
}
}
k8s.pod: {
  podSpec[volumes] == null || <ref>: true
}
k8s.pod: {
  podSpec[volumes] == null || <ref>: true
}
k8s.pod: {
  podSpec[volumes] == null || <ref>: true
}
Query encountered errors:
failed to create resource 'k8s.pod': could not find resource
k8s.pod: no data available
Query encountered errors:
failed to create resource 'k8s.pod': could not find resource

this is confusing and ugly!

it seems to be because we are trying to run a query intended for pod, on the main k8s transport

vjeffrey commented 1 year ago

doing something like this could help, there might be a simpler way: https://github.com/mondoohq/cnquery/compare/vj/no-run-wrong-asset?expand=1

vjeffrey commented 1 year ago

this will be fixed eventually with the asset ctx work