From 1e7c00e0977762a1f66a1cfce9e0ac7a65d79ba5 Mon Sep 17 00:00:00 2001 From: Frank Hamand Date: Thu, 17 May 2018 09:37:10 +0100 Subject: [PATCH] Add flag to stream pod logs in release testing --- _proto/hapi/services/tiller.proto | 2 + cmd/helm/release_testing.go | 3 + docs/helm/helm_test.md | 3 +- pkg/helm/option.go | 7 + pkg/kube/client.go | 27 +++- pkg/proto/hapi/services/tiller.pb.go | 167 +++++++++++---------- pkg/releasetesting/environment.go | 47 ++++++ pkg/releasetesting/test_suite.go | 19 +++ pkg/tiller/environment/environment.go | 19 +++ pkg/tiller/environment/environment_test.go | 8 + pkg/tiller/release_server_test.go | 8 + pkg/tiller/release_testing.go | 1 + 12 files changed, 224 insertions(+), 87 deletions(-) diff --git a/_proto/hapi/services/tiller.proto b/_proto/hapi/services/tiller.proto index 8daef0cb3..53e9c9475 100644 --- a/_proto/hapi/services/tiller.proto +++ b/_proto/hapi/services/tiller.proto @@ -329,6 +329,8 @@ message TestReleaseRequest { int64 timeout = 2; // cleanup specifies whether or not to attempt pod deletion after test completes bool cleanup = 3; + // logs specifies whether or not to stream logs from the test pods + bool logs = 4; } // TestReleaseResponse represents a message from executing a test diff --git a/cmd/helm/release_testing.go b/cmd/helm/release_testing.go index bdfa87a60..4ac3b4d36 100644 --- a/cmd/helm/release_testing.go +++ b/cmd/helm/release_testing.go @@ -39,6 +39,7 @@ type releaseTestCmd struct { client helm.Interface timeout int64 cleanup bool + logs bool } func newReleaseTestCmd(c helm.Interface, out io.Writer) *cobra.Command { @@ -66,6 +67,7 @@ func newReleaseTestCmd(c helm.Interface, out io.Writer) *cobra.Command { f := cmd.Flags() f.Int64Var(&rlsTest.timeout, "timeout", 300, "time in seconds to wait for any individual Kubernetes operation (like Jobs for hooks)") f.BoolVar(&rlsTest.cleanup, "cleanup", false, "delete test pods upon completion") + f.BoolVar(&rlsTest.logs, "logs", false, "show logs from test pods") return cmd } @@ -75,6 +77,7 @@ func (t *releaseTestCmd) run() (err error) { t.name, helm.ReleaseTestTimeout(t.timeout), helm.ReleaseTestCleanup(t.cleanup), + helm.ReleaseTestLogs(t.logs), ) testErr := &testErr{} diff --git a/docs/helm/helm_test.md b/docs/helm/helm_test.md index 062244e73..f18eaafd0 100644 --- a/docs/helm/helm_test.md +++ b/docs/helm/helm_test.md @@ -20,6 +20,7 @@ helm test [RELEASE] ``` --cleanup delete test pods upon completion + --logs show logs from test pods --timeout int time in seconds to wait for any individual Kubernetes operation (like Jobs for hooks) (default 300) --tls enable TLS for request --tls-ca-cert string path to TLS CA certificate file (default "$HELM_HOME/ca.pem") @@ -42,4 +43,4 @@ helm test [RELEASE] ### SEE ALSO * [helm](helm.md) - The Helm package manager for Kubernetes. -###### Auto generated by spf13/cobra on 8-Mar-2018 +###### Auto generated by spf13/cobra on 18-May-2018 diff --git a/pkg/helm/option.go b/pkg/helm/option.go index 602e1e3a3..11f11be16 100644 --- a/pkg/helm/option.go +++ b/pkg/helm/option.go @@ -227,6 +227,13 @@ func ReleaseTestCleanup(cleanup bool) ReleaseTestOption { } } +// ReleaseTestLogs is a boolean value representing whether to stream logs from test pods +func ReleaseTestLogs(logs bool) ReleaseTestOption { + return func(opts *options) { + opts.testReq.Logs = logs + } +} + // RollbackTimeout specifies the number of seconds before kubernetes calls timeout func RollbackTimeout(timeout int64) RollbackOption { return func(opts *options) { diff --git a/pkg/kube/client.go b/pkg/kube/client.go index 926174ef1..f1c8f9a0e 100644 --- a/pkg/kube/client.go +++ b/pkg/kube/client.go @@ -631,9 +631,19 @@ func scrubValidationError(err error) error { return err } +// WaitAndGetRunningPodPhase waits up to a timeout for a pod to enter running phase. +// Also returns on PodFailed or PodSucceeded. (As we can't go back to Running from these phases). +func (c *Client) WaitAndGetRunningPodPhase(namespace string, reader io.Reader, timeout time.Duration) (core.PodPhase, error) { + return c.waitAndGetPodPhase(namespace, reader, timeout, []core.PodPhase{core.PodRunning, core.PodFailed, core.PodSucceeded}) +} + // WaitAndGetCompletedPodPhase waits up to a timeout until a pod enters a completed phase // and returns said phase (PodSucceeded or PodFailed qualify). func (c *Client) WaitAndGetCompletedPodPhase(namespace string, reader io.Reader, timeout time.Duration) (core.PodPhase, error) { + return c.waitAndGetPodPhase(namespace, reader, timeout, []core.PodPhase{core.PodFailed, core.PodSucceeded}) +} + +func (c *Client) waitAndGetPodPhase(namespace string, reader io.Reader, timeout time.Duration, phases []core.PodPhase) (core.PodPhase, error) { infos, err := c.Build(namespace, reader) if err != nil { return core.PodUnknown, err @@ -645,7 +655,7 @@ func (c *Client) WaitAndGetCompletedPodPhase(namespace string, reader io.Reader, return core.PodUnknown, fmt.Errorf("%s is not a Pod", info.Name) } - if err := c.watchPodUntilComplete(timeout, info); err != nil { + if err := c.watchPodUntilPhase(timeout, info, phases); err != nil { return core.PodUnknown, err } @@ -657,7 +667,7 @@ func (c *Client) WaitAndGetCompletedPodPhase(namespace string, reader io.Reader, return status, nil } -func (c *Client) watchPodUntilComplete(timeout time.Duration, info *resource.Info) error { +func (c *Client) watchPodUntilPhase(timeout time.Duration, info *resource.Info, phases []core.PodPhase) error { w, err := resource.NewHelper(info.Client, info.Mapping).WatchSingle(info.Namespace, info.Name, info.ResourceVersion) if err != nil { return err @@ -665,13 +675,13 @@ func (c *Client) watchPodUntilComplete(timeout time.Duration, info *resource.Inf c.Log("Watching pod %s for completion with timeout of %v", info.Name, timeout) _, err = watch.Until(timeout, w, func(e watch.Event) (bool, error) { - return isPodComplete(e) + return isPodInPhase(e, phases) }) return err } -func isPodComplete(event watch.Event) (bool, error) { +func isPodInPhase(event watch.Event, phases []core.PodPhase) (bool, error) { o, ok := event.Object.(*core.Pod) if !ok { return true, fmt.Errorf("expected a *core.Pod, got %T", event.Object) @@ -679,10 +689,13 @@ func isPodComplete(event watch.Event) (bool, error) { if event.Type == watch.Deleted { return false, fmt.Errorf("pod not found") } - switch o.Status.Phase { - case core.PodFailed, core.PodSucceeded: - return true, nil + + for _, phase := range phases { + if phase == o.Status.Phase { + return true, nil + } } + return false, nil } diff --git a/pkg/proto/hapi/services/tiller.pb.go b/pkg/proto/hapi/services/tiller.pb.go index 4d23bcdad..f4e64a2f9 100644 --- a/pkg/proto/hapi/services/tiller.pb.go +++ b/pkg/proto/hapi/services/tiller.pb.go @@ -844,6 +844,8 @@ type TestReleaseRequest struct { Timeout int64 `protobuf:"varint,2,opt,name=timeout" json:"timeout,omitempty"` // cleanup specifies whether or not to attempt pod deletion after test completes Cleanup bool `protobuf:"varint,3,opt,name=cleanup" json:"cleanup,omitempty"` + // logs specifies whether or not to stream logs from the test pods + Logs bool `protobuf:"varint,4,opt,name=logs" json:"logs,omitempty"` } func (m *TestReleaseRequest) Reset() { *m = TestReleaseRequest{} } @@ -872,6 +874,13 @@ func (m *TestReleaseRequest) GetCleanup() bool { return false } +func (m *TestReleaseRequest) GetLogs() bool { + if m != nil { + return m.Logs + } + return false +} + // TestReleaseResponse represents a message from executing a test type TestReleaseResponse struct { Msg string `protobuf:"bytes,1,opt,name=msg" json:"msg,omitempty"` @@ -1376,83 +1385,83 @@ var _ReleaseService_serviceDesc = grpc.ServiceDesc{ func init() { proto.RegisterFile("hapi/services/tiller.proto", fileDescriptor0) } var fileDescriptor0 = []byte{ - // 1235 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x57, 0xdd, 0x6e, 0xe3, 0xc4, - 0x17, 0xaf, 0xf3, 0x9d, 0x93, 0x6e, 0xfe, 0xd9, 0x69, 0xda, 0xba, 0xfe, 0x2f, 0xa8, 0x18, 0xc1, - 0x66, 0x17, 0x36, 0x85, 0xc0, 0x0d, 0x12, 0x42, 0xea, 0x66, 0xa3, 0xb6, 0x50, 0xba, 0x92, 0xb3, - 0x5d, 0x24, 0x04, 0x44, 0x6e, 0x32, 0x69, 0xcd, 0x3a, 0x76, 0xf0, 0x8c, 0xcb, 0xf6, 0x96, 0x3b, - 0xde, 0x8a, 0x77, 0xe0, 0x92, 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94, 0x03, 0x4d, 0xf6, 0x68, - 0x62, 0x3d, 0x2b, 0xc8, 0xbd, 0x12, 0x94, 0xec, 0x4a, 0xb7, 0x04, 0xa5, 0xb7, 0xbc, 0x5b, 0x82, - 0x5a, 0x69, 0x70, 0xf6, 0x1a, 0xf2, 0xa0, 0xed, 0xc4, 0x81, 0x34, 0xcd, 0xda, 0x02, 0xca, 0x91, - 0xbe, 0xd9, 0xd5, 0xac, 0x27, 0x05, 0x38, 0xaf, 0xef, 0xf7, 0x73, 0xf8, 0xbe, 0xa1, 0x58, 0xcf, - 0x6a, 0xfc, 0xdf, 0xef, 0x67, 0xff, 0x06, 0x00, 0x00, 0xff, 0xff, 0x5d, 0xc3, 0xd5, 0x55, 0xeb, - 0x0f, 0x00, 0x00, + // 1242 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x57, 0xdd, 0x6e, 0xe3, 0x44, + 0x14, 0xae, 0xf3, 0x9f, 0x93, 0x6e, 0xc8, 0x4e, 0xd3, 0xd6, 0x35, 0x0b, 0x2a, 0x46, 0xb0, 0xd9, + 0x85, 0x4d, 0x21, 0x70, 0x83, 0x84, 0x90, 0xba, 0xd9, 0xa8, 0x2d, 0x94, 0xae, 0xe4, 0x6c, 0x17, + 0x09, 0x09, 0x22, 0x37, 0x99, 0xb4, 0x66, 0x1d, 0x3b, 0x78, 0xc6, 0x65, 0x7b, 0xcb, 0x1d, 0x6f, + 0xc5, 0x3b, 0x70, 0xc9, 0x25, 0x3c, 0x08, 0x9a, 0x3f, 0xd7, 0x93, 0xda, 0xad, 0xe9, 0x4d, 0x3c, + 0x33, 0xe7, 0xff, 0x3b, 0x67, 0xce, 0x9c, 0x80, 0x75, 0xe1, 0x2e, 0xbd, 0x3d, 0x82, 0xa3, 0x4b, + 0x6f, 0x8a, 0xc9, 0x1e, 0xf5, 0x7c, 0x1f, 0x47, 0xfd, 0x65, 0x14, 0xd2, 0x10, 0x75, 0x19, 0xad, + 0xaf, 0x68, 0x7d, 0x41, 0xb3, 0xb6, 0xb8, 0xc4, 0xf4, 0xc2, 0x8d, 0xa8, 0xf8, 0x15, 0xdc, 0xd6, + 0x76, 0xfa, 0x3c, 0x0c, 0xe6, 0xde, 0xb9, 0x24, 0x08, 0x13, 0x11, 0xf6, 0xb1, 0x4b, 0xb0, 0xfa, + 0x6a, 0x42, 0x8a, 0xe6, 0x05, 0xf3, 0x50, 0x12, 0xde, 0xd5, 0x08, 0x14, 0x13, 0x3a, 0x89, 0xe2, + 0x40, 0x12, 0x77, 0x34, 0x22, 0xa1, 0x2e, 0x8d, 0x89, 0x66, 0xec, 0x12, 0x47, 0xc4, 0x0b, 0x03, + 0xf5, 0x15, 0x34, 0xfb, 0xcf, 0x12, 0x6c, 0x1c, 0x7b, 0x84, 0x3a, 0x42, 0x90, 0x38, 0xf8, 0xd7, + 0x18, 0x13, 0x8a, 0xba, 0x50, 0xf5, 0xbd, 0x85, 0x47, 0x4d, 0x63, 0xd7, 0xe8, 0x95, 0x1d, 0xb1, + 0x41, 0x5b, 0x50, 0x0b, 0xe7, 0x73, 0x82, 0xa9, 0x59, 0xda, 0x35, 0x7a, 0x4d, 0x47, 0xee, 0xd0, + 0x37, 0x50, 0x27, 0x61, 0x44, 0x27, 0x67, 0x57, 0x66, 0x79, 0xd7, 0xe8, 0xb5, 0x07, 0x1f, 0xf5, + 0xb3, 0x70, 0xea, 0x33, 0x4b, 0xe3, 0x30, 0xa2, 0x7d, 0xf6, 0xf3, 0xfc, 0xca, 0xa9, 0x11, 0xfe, + 0x65, 0x7a, 0xe7, 0x9e, 0x4f, 0x71, 0x64, 0x56, 0x84, 0x5e, 0xb1, 0x43, 0x07, 0x00, 0x5c, 0x6f, + 0x18, 0xcd, 0x70, 0x64, 0x56, 0xb9, 0xea, 0x5e, 0x01, 0xd5, 0x2f, 0x19, 0xbf, 0xd3, 0x24, 0x6a, + 0x89, 0xbe, 0x86, 0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, 0x01, 0xe5, 0x48, 0xdf, 0xec, 0x74, 0xd6, 0x93, 0x02, 0x9c, 0xd7, 0xf7, + 0xfb, 0x39, 0xfc, 0xd8, 0x50, 0xac, 0x67, 0x35, 0xfe, 0x8f, 0xf8, 0x8b, 0xff, 0x02, 0x00, 0x00, + 0xff, 0xff, 0x78, 0xb4, 0x88, 0x6b, 0xff, 0x0f, 0x00, 0x00, } diff --git a/pkg/releasetesting/environment.go b/pkg/releasetesting/environment.go index 3b3d07933..e49c5911f 100644 --- a/pkg/releasetesting/environment.go +++ b/pkg/releasetesting/environment.go @@ -17,6 +17,7 @@ limitations under the License. package releasetesting import ( + "bufio" "bytes" "fmt" "log" @@ -35,6 +36,7 @@ type Environment struct { KubeClient environment.KubeClient Stream services.ReleaseService_RunReleaseTestServer Timeout int64 + StreamLogs bool } func (env *Environment) createTestPod(test *test) error { @@ -111,6 +113,51 @@ func (env *Environment) streamMessage(msg string, status release.TestRun_Status) return env.Stream.Send(resp) } +func (env *Environment) beginLogStream(t *test) error { + if _, err := env.KubeClient.WaitAndGetRunningPodPhase(env.Namespace, bytes.NewBufferString(t.manifest), time.Duration(env.Timeout)*time.Second); err != nil { + return err + } + + infos, err := env.KubeClient.BuildUnstructured(env.Namespace, bytes.NewBufferString(t.manifest)) + if err != nil { + return err + } + + // A test manifest is always a single pod, so we don't need to be overly + // careful here. This is checked earlier in the test run (in `newTest`) + pod := infos[0].AsInternal().(*core.Pod) + opt := &core.PodLogOptions{ + Container: pod.Spec.Containers[0].Name, + Follow: true, + Previous: false, + Timestamps: false, + } + + env.Stream.Send(&services.TestReleaseResponse{ + Msg: fmt.Sprintf("Streaming logs from container \"%s\"", opt.Container), + Status: release.TestRun_RUNNING, + }) + + req, err := env.KubeClient.LogsForObject(pod, opt, time.Duration(env.Timeout)*time.Second) + if err != nil { + return err + } + + readCloser, err := req.Stream() + if err != nil { + return err + } + defer readCloser.Close() + + scanner := bufio.NewScanner(readCloser) + for scanner.Scan() { + resp := &services.TestReleaseResponse{Msg: scanner.Text(), Status: release.TestRun_RUNNING} + env.Stream.Send(resp) + } + + return err +} + // DeleteTestPods deletes resources given in testManifests func (env *Environment) DeleteTestPods(testManifests []string) { for _, testManifest := range testManifests { diff --git a/pkg/releasetesting/test_suite.go b/pkg/releasetesting/test_suite.go index 2e42400ce..b5c0e2acb 100644 --- a/pkg/releasetesting/test_suite.go +++ b/pkg/releasetesting/test_suite.go @@ -92,7 +92,26 @@ func (ts *TestSuite) Run(env *Environment) error { resourceCleanExit := true status := core.PodUnknown if resourceCreated { + logChan := make(chan bool) + if env.StreamLogs { + go func() { + if err := env.beginLogStream(test); err != nil { + // We don't want to fail the tests if logging failed for whatever reason, + // so use UNKNOWN state not ERROR. + env.streamMessage(err.Error(), release.TestRun_UNKNOWN) + } + logChan <- true + }() + } + status, err = env.getTestPodStatus(test) + + // Wait for log streaming to finish, which should be before + // the pod finishes anyway. + if env.StreamLogs { + <-logChan + } + if err != nil { resourceCleanExit = false if streamErr := env.streamError(test.result.Info); streamErr != nil { diff --git a/pkg/tiller/environment/environment.go b/pkg/tiller/environment/environment.go index 366fdf522..75dd3ed8f 100644 --- a/pkg/tiller/environment/environment.go +++ b/pkg/tiller/environment/environment.go @@ -26,6 +26,8 @@ import ( "io" "time" + "k8s.io/apimachinery/pkg/runtime" + restclient "k8s.io/client-go/rest" "k8s.io/kubernetes/pkg/apis/core" "k8s.io/kubernetes/pkg/kubectl/resource" @@ -143,6 +145,12 @@ type KubeClient interface { // WaitAndGetCompletedPodPhase waits up to a timeout until a pod enters a completed phase // and returns said phase (PodSucceeded or PodFailed qualify). WaitAndGetCompletedPodPhase(namespace string, reader io.Reader, timeout time.Duration) (core.PodPhase, error) + + // WaitAndGetRunningPodPhase waits up to a timeout for a pod to enter running phase. + // Also returns on PodFailed or PodSucceeded (As we can't go back to Running from these phases). + WaitAndGetRunningPodPhase(namespace string, reader io.Reader, timeout time.Duration) (core.PodPhase, error) + + LogsForObject(object, options runtime.Object, timeout time.Duration) (*restclient.Request, error) } // PrintingKubeClient implements KubeClient, but simply prints the reader to @@ -199,6 +207,17 @@ func (p *PrintingKubeClient) WaitAndGetCompletedPodPhase(namespace string, reade return core.PodUnknown, err } +// WaitAndGetRunningPodPhase implements KubeClient WaitAndGetRunningPodPhase. +func (p *PrintingKubeClient) WaitAndGetRunningPodPhase(namespace string, reader io.Reader, timeout time.Duration) (core.PodPhase, error) { + _, err := io.Copy(p.Out, reader) + return core.PodRunning, err +} + +// LogsForObject implements KubeClient LogsForObject. +func (p *PrintingKubeClient) LogsForObject(object, options runtime.Object, timeout time.Duration) (*restclient.Request, error) { + return nil, nil +} + // Environment provides the context for executing a client request. // // All services in a context are concurrency safe. diff --git a/pkg/tiller/environment/environment_test.go b/pkg/tiller/environment/environment_test.go index d8c82b901..402bb8bcf 100644 --- a/pkg/tiller/environment/environment_test.go +++ b/pkg/tiller/environment/environment_test.go @@ -22,6 +22,8 @@ import ( "testing" "time" + "k8s.io/apimachinery/pkg/runtime" + restclient "k8s.io/client-go/rest" "k8s.io/kubernetes/pkg/apis/core" "k8s.io/kubernetes/pkg/kubectl/resource" @@ -64,6 +66,12 @@ func (k *mockKubeClient) BuildUnstructured(ns string, reader io.Reader) (kube.Re func (k *mockKubeClient) WaitAndGetCompletedPodPhase(namespace string, reader io.Reader, timeout time.Duration) (core.PodPhase, error) { return core.PodUnknown, nil } +func (k *mockKubeClient) WaitAndGetRunningPodPhase(namespace string, reader io.Reader, timeout time.Duration) (core.PodPhase, error) { + return core.PodRunning, nil +} +func (k *mockKubeClient) LogsForObject(object, options runtime.Object, timeout time.Duration) (*restclient.Request, error) { + return nil, nil +} func (k *mockKubeClient) WaitAndGetCompletedPodStatus(namespace string, reader io.Reader, timeout time.Duration) (core.PodPhase, error) { return "", nil diff --git a/pkg/tiller/release_server_test.go b/pkg/tiller/release_server_test.go index 96cb84a75..ccb1bef91 100644 --- a/pkg/tiller/release_server_test.go +++ b/pkg/tiller/release_server_test.go @@ -30,6 +30,8 @@ import ( "github.com/golang/protobuf/ptypes/timestamp" "golang.org/x/net/context" "google.golang.org/grpc/metadata" + "k8s.io/apimachinery/pkg/runtime" + restclient "k8s.io/client-go/rest" "k8s.io/kubernetes/pkg/apis/core" "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/fake" "k8s.io/kubernetes/pkg/kubectl/resource" @@ -559,6 +561,12 @@ func (kc *mockHooksKubeClient) BuildUnstructured(ns string, reader io.Reader) (k func (kc *mockHooksKubeClient) WaitAndGetCompletedPodPhase(namespace string, reader io.Reader, timeout time.Duration) (core.PodPhase, error) { return core.PodUnknown, nil } +func (kc *mockHooksKubeClient) WaitAndGetRunningPodPhase(namespace string, reader io.Reader, timeout time.Duration) (core.PodPhase, error) { + return core.PodRunning, nil +} +func (kc *mockHooksKubeClient) LogsForObject(object, options runtime.Object, timeout time.Duration) (*restclient.Request, error) { + return nil, nil +} func deletePolicyStub(kubeClient *mockHooksKubeClient) *ReleaseServer { e := environment.New() diff --git a/pkg/tiller/release_testing.go b/pkg/tiller/release_testing.go index a44b67e6f..70cd0b6e1 100644 --- a/pkg/tiller/release_testing.go +++ b/pkg/tiller/release_testing.go @@ -41,6 +41,7 @@ func (s *ReleaseServer) RunReleaseTest(req *services.TestReleaseRequest, stream KubeClient: s.env.KubeClient, Timeout: req.Timeout, Stream: stream, + StreamLogs: req.Logs, } s.Log("running tests for release %s", rel.Name) tSuite, err := reltesting.NewTestSuite(rel)