From 243de3a4720f5fa425da70af890509b3bcbcbf7c Mon Sep 17 00:00:00 2001 From: Jeff Lowdermilk Date: Fri, 27 Mar 2015 12:26:00 -0700 Subject: [PATCH] Fix kubectl log for single-container pods --- pkg/kubectl/cmd/log.go | 4 ++++ pkg/kubectl/cmd/util/helpers.go | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/kubectl/cmd/log.go b/pkg/kubectl/cmd/log.go index 6fd3a20b7ac..1c97de3caba 100644 --- a/pkg/kubectl/cmd/log.go +++ b/pkg/kubectl/cmd/log.go @@ -100,6 +100,10 @@ func RunLog(f *Factory, out io.Writer, cmd *cobra.Command, args []string) error var container string if len(args) == 1 { + if len(pod.Spec.Containers) != 1 { + return fmt.Errorf("POD %s has more than one container; please specify the container to print logs for", pod.ObjectMeta.Name) + } + container = pod.Spec.Containers[0].Name } else { container = args[1] } diff --git a/pkg/kubectl/cmd/util/helpers.go b/pkg/kubectl/cmd/util/helpers.go index 641a22356fa..158fefbf1b3 100644 --- a/pkg/kubectl/cmd/util/helpers.go +++ b/pkg/kubectl/cmd/util/helpers.go @@ -49,7 +49,7 @@ func CheckErr(err error) { if client.IsUnexpectedStatusError(err) { glog.FatalDepth(1, fmt.Sprintf("Unexpected status received from server: %s", err.Error())) } - glog.FatalDepth(1, fmt.Sprintf("Error: %s", err.Error())) + glog.FatalDepth(1, fmt.Sprintf("Client error: %s", err.Error())) } }