Skip to content

helm test --logs for all containers in a pod #6902

Description

@tanenbaum

Output of helm version:

Client: &version.Version{SemVer:"v2.16.0", GitCommit:"e13bc94621d4ef666270cfbe734aaabf342a49bb", GitTreeState:"clean"}
Server: &version.Version{SemVer:"v2.16.0", GitCommit:"e13bc94621d4ef666270cfbe734aaabf342a49bb", GitTreeState:"clean"}

Output of kubectl version:

Client Version: version.Info{Major:"1", Minor:"16", GitVersion:"v1.16.2", GitCommit:"c97fe5036ef3df2967d086711e6c0c405941e14b", GitTreeState:"clean", BuildDate:"2019-10-17T17:16:09Z", GoVersion:"go1.12.10", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"16", GitVersion:"v1.16.2", GitCommit:"c97fe5036ef3df2967d086711e6c0c405941e14b", GitTreeState:"clean", BuildDate:"2019-10-15T19:09:08Z", GoVersion:"go1.12.10", Compiler:"gc", Platform:"linux/amd64"}

Cloud Provider/Platform (AKS, GKE, Minikube etc.): Minikube

It would be great if helm test --cleanup --logs printed all container logs in each test pod. Currently this works fine for 1 container in a pod.

Rather than run test images that contain all the tools I need, I often create pods with a couple of containers that orchestrate the tests (e.g. redis-cli + python script + shared volume).

helm test [release] --cleanup --logs will error with:
RUNNING: my-test
FAILED: my-test, run kubectl logs my-test --namespace default for more info
ERROR: error in opening log stream, got: a container name must be specified for pod my-test, choose one of: [container-0 container-1]

I currently use a shell script as a workaround (can't find source of this anymore) like so:

helm_release=$1

helm test $helm_release
status=$?

test_pods=$(helm status $helm_release -o json | jq -r .info.status.last_test_suite_run.results[].name)
namespace=$(helm status $helm_release -o json | jq -r .namespace)

for test_pod in $test_pods; do
  echo "Test Pod: $test_pod"
  echo "============"
  echo ""
  kubectl -n $namespace logs --all-containers $test_pod
  kubectl -n $namespace delete pod $test_pod
  echo ""
  echo "============"
done

exit $status

Notice that I'm running kubectl logs --all-containers to ensure I get all the logs from the pod.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      Sponsor
      SponsoredKunjungi sekarang
      Promo