You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When querying clusters using json output, where some explicit k8s resource does not exist, the kubectl mc command failes hard.
It would be cool if the command would reflect the issue with a non zero return code (possibly with a documented, dedicated error code if not all contexts could be queried successfully (endpoint down)e.g. to use this in scripts that ) but still reports the resorces found in json (so that it can be used for discovery jobs like "does ingress myingress exist in all clusters?" ).
Situation
3 contexts configured in kubeconfig
resource myingress does exist in context1 and context2 but not in context3
shell$ kubectl mc -o json -- get ingress -n mynamespace myingress
Error: couldn't parse this output. Are you sure your kubectl command allows for json output? Run command with -d to see debug output
Same is true if I target the context3 explicitly
shell$ kubectl mc -r context3 -o json -- get ingress -n mynamespace myingress
Error: couldn't parse this output. Are you sure your kubectl command allows for json output? Run command with -d to see debug output
Debug output:
# myingress does not exist on cluster3
shell$ kubectl mc -o json -r context3 -d -- get ingress -n namespace myingress
2022-06-01T13:57:44.368+0200 DEBUG mc/mc.go:153 preparing wait group {"max-processes": 5}
2022-06-01T13:57:44.372+0200 DEBUG mc/mc.go:165 start wait group
2022-06-01T13:57:44.373+0200 DEBUG mc/mc.go:178 waiting for next free spot {"context": "context3", "namespace": ""}
2022-06-01T13:57:44.373+0200 DEBUG mc/mc.go:180 executing {"context": "context3", "namespace": ""}
2022-06-01T13:57:50.982+0200 DEBUG mc/mc.go:171 wait group finished
2022-06-01T13:57:50.983+0200 DEBUG mc/mc.go:186 parsing output...
2022-06-01T13:57:50.983+0200 DEBUG mc/mc.go:189 failed to parse output {"retrieved": "map[context3:]"}
Error: couldn't parse this output. Are you sure your kubectl command allows for json output? Run command with -d to see debug output
Doing the same without a resource selector does work
# works
shell$ kubectl mc -o json -r context3 -d -- get ingress -n namespace
Doing the same with default output (non json) works too
# works
shell$ kubectl mc -o json -r context3 -d -- get ingress -n nonexistingnamespace
Doing the same without a resource and with a namespace that does not exist does not fail.
When querying clusters using json output, where some explicit k8s resource does not exist, the kubectl mc command failes hard.
It would be cool if the command would reflect the issue with a non zero return code (possibly with a documented, dedicated error code if not all contexts could be queried successfully (endpoint down)e.g. to use this in scripts that ) but still reports the resorces found in json (so that it can be used for discovery jobs like "does ingress myingress exist in all clusters?" ).
Situation
Same is true if I target the context3 explicitly
Debug output:
The text was updated successfully, but these errors were encountered: