gocardless / theatre

GoCardless' collection of Kubernetes extensions
MIT License
23 stars 17 forks source link

Dump pod logs on errored console creation #232

Closed dyson closed 3 years ago

dyson commented 3 years ago

If we have an issue attaching to a pod because it has errored or because there is a kubernetes issue then attempt to dump the pods logs. This will provide end users more visibility into the issue and prevent them from having to manually check the pods logs themselves. This is useful in automated tooling that might create a console and log the stdout for users to see such as in a web UI.

For example a console that spawns a pod that exits non-zero would previous only log the kubernetes error which depending on what went wrong might not be very descriptive.

Now the pods logs are also shown:

go run cmd/theatre-consoles/main.go --context my-context --namespace=default create --selector app=my-app --reason "Testing broken console" --noninteractive --attach -- bash -c "echo 'hi from an errored pod'; exit 1"
msg="Console has been requested" console=my-console-dxm8k namespace=default
msg="Console is ready" console=my-console-dxm8k namespace=default pod=my-console-dxm8k-console-5vfp4
msg="Attaching to pod" console=my-console-dxm8k namespace=default pod=my-console-dxm8k-console-5vfp4
hi from an errored pod
consoles: error: unexpected error: Pod in unsuccessful state Failed:
exit status 1
dyson commented 3 years ago

@benwh I fixed up the typos - can I get another quick review please 🙌🏻