diff --git a/api/controller/services.pb.go b/api/controller/services.pb.go index c5e7f6b4..75729680 100644 --- a/api/controller/services.pb.go +++ b/api/controller/services.pb.go @@ -601,7 +601,7 @@ type ProviderServiceClient interface { Kubectl(ctx context.Context, in *KubectlReq, opts ...grpc.CallOption) (*CmdResponse, error) // Process api ProcessRun(ctx context.Context, in *ProcessRunReq, opts ...grpc.CallOption) (*CmdResponse, error) - LogStream(ctx context.Context, in *LogStreamReq, opts ...grpc.CallOption) (*LogStreamResponse, error) + LogStream(ctx context.Context, in *LogStreamReq, opts ...grpc.CallOption) (ProviderService_LogStreamClient, error) } type providerServiceClient struct { @@ -853,13 +853,36 @@ func (c *providerServiceClient) ProcessRun(ctx context.Context, in *ProcessRunRe return out, nil } -func (c *providerServiceClient) LogStream(ctx context.Context, in *LogStreamReq, opts ...grpc.CallOption) (*LogStreamResponse, error) { - out := new(LogStreamResponse) - err := grpc.Invoke(ctx, "/controller.ProviderService/LogStream", in, out, c.cc, opts...) +func (c *providerServiceClient) LogStream(ctx context.Context, in *LogStreamReq, opts ...grpc.CallOption) (ProviderService_LogStreamClient, error) { + stream, err := grpc.NewClientStream(ctx, &_ProviderService_serviceDesc.Streams[1], c.cc, "/controller.ProviderService/LogStream", opts...) if err != nil { return nil, err } - return out, nil + x := &providerServiceLogStreamClient{stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil +} + +type ProviderService_LogStreamClient interface { + Recv() (*LogStreamResponse, error) + grpc.ClientStream +} + +type providerServiceLogStreamClient struct { + grpc.ClientStream +} + +func (x *providerServiceLogStreamClient) Recv() (*LogStreamResponse, error) { + m := new(LogStreamResponse) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil } // Server API for ProviderService service @@ -895,7 +918,7 @@ type ProviderServiceServer interface { Kubectl(context.Context, *KubectlReq) (*CmdResponse, error) // Process api ProcessRun(context.Context, *ProcessRunReq) (*CmdResponse, error) - LogStream(context.Context, *LogStreamReq) (*LogStreamResponse, error) + LogStream(*LogStreamReq, ProviderService_LogStreamServer) error } func RegisterProviderServiceServer(s *grpc.Server, srv ProviderServiceServer) { @@ -1342,22 +1365,25 @@ func _ProviderService_ProcessRun_Handler(srv interface{}, ctx context.Context, d return interceptor(ctx, in, info, handler) } -func _ProviderService_LogStream_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(LogStreamReq) - if err := dec(in); err != nil { - return nil, err +func _ProviderService_LogStream_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(LogStreamReq) + if err := stream.RecvMsg(m); err != nil { + return err } - if interceptor == nil { - return srv.(ProviderServiceServer).LogStream(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/controller.ProviderService/LogStream", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ProviderServiceServer).LogStream(ctx, req.(*LogStreamReq)) - } - return interceptor(ctx, in, info, handler) + return srv.(ProviderServiceServer).LogStream(m, &providerServiceLogStreamServer{stream}) +} + +type ProviderService_LogStreamServer interface { + Send(*LogStreamResponse) error + grpc.ServerStream +} + +type providerServiceLogStreamServer struct { + grpc.ServerStream +} + +func (x *providerServiceLogStreamServer) Send(m *LogStreamResponse) error { + return x.ServerStream.SendMsg(m) } var _ProviderService_serviceDesc = grpc.ServiceDesc{ @@ -1456,10 +1482,6 @@ var _ProviderService_serviceDesc = grpc.ServiceDesc{ MethodName: "ProcessRun", Handler: _ProviderService_ProcessRun_Handler, }, - { - MethodName: "LogStream", - Handler: _ProviderService_LogStream_Handler, - }, }, Streams: []grpc.StreamDesc{ { @@ -1467,6 +1489,11 @@ var _ProviderService_serviceDesc = grpc.ServiceDesc{ Handler: _ProviderService_BuildCreate_Handler, ClientStreams: true, }, + { + StreamName: "LogStream", + Handler: _ProviderService_LogStream_Handler, + ServerStreams: true, + }, }, Metadata: "services.proto", } @@ -1474,92 +1501,92 @@ var _ProviderService_serviceDesc = grpc.ServiceDesc{ func init() { proto.RegisterFile("services.proto", fileDescriptor0) } var fileDescriptor0 = []byte{ - // 1382 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x57, 0xdf, 0x6f, 0x1b, 0xc5, - 0x13, 0xff, 0xda, 0x71, 0x93, 0x78, 0xec, 0x38, 0xc9, 0x26, 0x75, 0x1c, 0xa7, 0xdf, 0x24, 0x5d, - 0x84, 0x9a, 0x06, 0xd5, 0x57, 0x8a, 0xc4, 0x8f, 0x20, 0x1e, 0x9c, 0xd4, 0x45, 0x15, 0x11, 0x0d, - 0x17, 0x2a, 0x21, 0xa0, 0xd0, 0x8b, 0x6f, 0xe3, 0x1c, 0x3e, 0xdf, 0x2e, 0x7b, 0x7b, 0x2e, 0x51, - 0xd5, 0x17, 0xfe, 0x05, 0xfe, 0x22, 0xde, 0xfa, 0x88, 0x84, 0x78, 0x45, 0xa8, 0xe2, 0x0f, 0x41, - 0xfb, 0xeb, 0x7c, 0xe7, 0x1f, 0xa1, 0xf4, 0x6d, 0x67, 0x6f, 0xe6, 0x33, 0x9f, 0x9d, 0x99, 0x9d, - 0x9d, 0x83, 0x5a, 0x4c, 0xf8, 0x30, 0xe8, 0x92, 0xb8, 0xc5, 0x38, 0x15, 0x14, 0x41, 0x97, 0x46, - 0x82, 0xd3, 0x30, 0x24, 0xbc, 0x79, 0xa3, 0x47, 0x69, 0x2f, 0x24, 0x8e, 0xc7, 0x02, 0xc7, 0x8b, - 0x22, 0x2a, 0x3c, 0x11, 0xd0, 0xc8, 0x68, 0x36, 0xb7, 0xcc, 0x57, 0x25, 0x9d, 0x25, 0xe7, 0x0e, - 0x19, 0x30, 0x71, 0x69, 0x3e, 0x6e, 0x8f, 0x7f, 0xf4, 0x13, 0xae, 0xac, 0xcd, 0xf7, 0x3b, 0xbd, - 0x40, 0x5c, 0x24, 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, 0x18, 0x05, 0xa3, 0x63, 0x3c, 0x8e, 0xc2, 0xff, 0xee, 0xe8, 0xb6, 0x72, - 0xf4, 0x56, 0xf3, 0xe6, 0x54, 0x47, 0x49, 0x94, 0x71, 0xf5, 0x08, 0x16, 0xcc, 0xb8, 0x95, 0x0f, - 0xd5, 0x68, 0x06, 0x6b, 0xe6, 0x6a, 0x2b, 0x33, 0x79, 0xd9, 0x87, 0x11, 0x55, 0xa4, 0x9b, 0xbe, - 0x41, 0x79, 0x0a, 0x30, 0x9a, 0x4c, 0xf2, 0x77, 0x37, 0x37, 0xb1, 0xcc, 0x86, 0xdd, 0x56, 0xb0, - 0x0d, 0x54, 0x97, 0xb0, 0x4c, 0xdb, 0xa4, 0xef, 0x5a, 0x12, 0xc9, 0xde, 0x99, 0x0e, 0x49, 0xf9, - 0xbb, 0x95, 0x1d, 0xd4, 0xf2, 0xdd, 0x73, 0x62, 0xaa, 0xca, 0x37, 0x7d, 0xd9, 0xce, 0x8c, 0x8b, - 0xc3, 0xc6, 0xcb, 0x57, 0xdb, 0x85, 0xdf, 0x5e, 0x6d, 0x17, 0xfe, 0x7a, 0xb5, 0x5d, 0xf8, 0x3a, - 0xf3, 0x13, 0x7d, 0x36, 0xaf, 0x6a, 0xe5, 0xbd, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0xea, 0xc0, - 0xea, 0x78, 0x69, 0x0f, 0x00, 0x00, + // 1387 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x57, 0x5d, 0x6f, 0x1b, 0x45, + 0x17, 0x7e, 0xed, 0xb8, 0x49, 0x7c, 0xec, 0x38, 0xc9, 0x24, 0x75, 0x1c, 0xa7, 0x6f, 0x92, 0xce, + 0xab, 0x57, 0x4d, 0x83, 0xea, 0x2d, 0x45, 0xe2, 0x23, 0x88, 0x0b, 0x27, 0x75, 0x51, 0x45, 0x44, + 0xc3, 0x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 0xc6, 0x48, 0xd5, 0x17, 0xca, 0x1b, 0x35, 0xc7, 0x0b, 0x11, 0xaf, 0x2b, 0x94, 0x1a, 0xae, 0x4a, + 0x14, 0x5b, 0x94, 0xe8, 0x18, 0x16, 0x95, 0xbe, 0x4c, 0x4c, 0x63, 0xec, 0xb8, 0x0f, 0x67, 0x11, + 0xca, 0x25, 0x47, 0x13, 0x72, 0x5e, 0x04, 0xfe, 0x4b, 0xf4, 0x95, 0x39, 0xa7, 0x89, 0xdf, 0x6c, + 0xc0, 0x37, 0x8a, 0x60, 0x16, 0xf9, 0x09, 0x94, 0xd3, 0xd7, 0x61, 0x66, 0x5e, 0xfe, 0x9b, 0xdd, + 0x9f, 0x78, 0x4c, 0xf0, 0xa6, 0x02, 0x5f, 0x43, 0xab, 0x59, 0x70, 0x9d, 0x20, 0xdf, 0xc2, 0xd3, + 0x5e, 0x8c, 0xb6, 0x26, 0x61, 0xd2, 0x77, 0xb9, 0x79, 0x63, 0xfa, 0x47, 0xe3, 0xe2, 0x86, 0x72, + 0x51, 0x47, 0xeb, 0x63, 0xfc, 0x9d, 0x50, 0x02, 0x9f, 0x42, 0xad, 0x13, 0x0d, 0x03, 0x4e, 0xa3, + 0x01, 0x89, 0xc4, 0x55, 0x77, 0x61, 0xd5, 0x06, 0xbc, 0x13, 0x0d, 0x8f, 0x68, 0x74, 0x1e, 0xf4, + 0x70, 0x5d, 0x41, 0xaf, 0xa0, 0x9a, 0x84, 0x26, 0xd1, 0xd0, 0x52, 0xff, 0x26, 0x07, 0x7a, 0x4a, + 0x04, 0xda, 0xcc, 0x82, 0xe6, 0x1e, 0xf5, 0x99, 0x71, 0x37, 0xe0, 0x78, 0x1c, 0xbc, 0x0b, 0x95, + 0x4c, 0xdf, 0x9b, 0x49, 0x77, 0x27, 0xbb, 0x3f, 0xa5, 0x51, 0xe2, 0x2d, 0x85, 0x7f, 0x1d, 0xad, + 0x65, 0x8b, 0xcf, 0x3a, 0x39, 0x83, 0x25, 0x63, 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 0x28, 0xa7, + 0x43, 0x52, 0xfe, 0x6e, 0x65, 0x07, 0xb5, 0x7c, 0xf7, 0x9c, 0x98, 0xaa, 0xf2, 0x4d, 0x5f, 0xb6, + 0x33, 0xe3, 0xe2, 0x6e, 0xe1, 0xb0, 0xf1, 0xea, 0xf5, 0x76, 0xe1, 0xd7, 0xd7, 0xdb, 0x85, 0x3f, + 0x5f, 0x6f, 0x17, 0xbe, 0xce, 0xfc, 0x46, 0x9f, 0xcd, 0xab, 0x6a, 0x79, 0xef, 0xef, 0x00, 0x00, + 0x00, 0xff, 0xff, 0x8b, 0x82, 0x28, 0x46, 0x6b, 0x0f, 0x00, 0x00, } diff --git a/api/controller/services.pb.gw.go b/api/controller/services.pb.gw.go index c27ab549..26426245 100644 --- a/api/controller/services.pb.gw.go +++ b/api/controller/services.pb.gw.go @@ -689,7 +689,7 @@ var ( filter_ProviderService_LogStream_0 = &utilities.DoubleArray{Encoding: map[string]int{"name": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} ) -func request_ProviderService_LogStream_0(ctx context.Context, marshaler runtime.Marshaler, client ProviderServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func request_ProviderService_LogStream_0(ctx context.Context, marshaler runtime.Marshaler, client ProviderServiceClient, req *http.Request, pathParams map[string]string) (ProviderService_LogStreamClient, runtime.ServerMetadata, error) { var protoReq LogStreamReq var metadata runtime.ServerMetadata @@ -715,8 +715,16 @@ func request_ProviderService_LogStream_0(ctx context.Context, marshaler runtime. return nil, metadata, grpc.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := client.LogStream(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err + stream, err := client.LogStream(ctx, &protoReq) + if err != nil { + return nil, metadata, err + } + header, err := stream.Header() + if err != nil { + return nil, metadata, err + } + metadata.HeaderMD = header + return stream, metadata, nil } @@ -1446,7 +1454,7 @@ func RegisterProviderServiceHandler(ctx context.Context, mux *runtime.ServeMux, return } - forward_ProviderService_LogStream_0(ctx, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_ProviderService_LogStream_0(ctx, outboundMarshaler, w, req, func() (proto.Message, error) { return resp.Recv() }, mux.GetForwardResponseOptions()...) }) @@ -1554,5 +1562,5 @@ var ( forward_ProviderService_ProcessRun_0 = runtime.ForwardResponseMessage - forward_ProviderService_LogStream_0 = runtime.ForwardResponseMessage + forward_ProviderService_LogStream_0 = runtime.ForwardResponseStream ) diff --git a/api/controller/services.proto b/api/controller/services.proto index c50a84fb..6f7bea0a 100644 --- a/api/controller/services.proto +++ b/api/controller/services.proto @@ -265,7 +265,7 @@ service ProviderService { }; } - rpc LogStream(LogStreamReq) returns (LogStreamResponse) { + rpc LogStream(LogStreamReq) returns (stream LogStreamResponse) { option (google.api.http) = { get: "/v1/logs/{name}" }; diff --git a/api/controller/services.swagger.json b/api/controller/services.swagger.json index e5e05ebf..5876502d 100644 --- a/api/controller/services.swagger.json +++ b/api/controller/services.swagger.json @@ -340,7 +340,7 @@ "operationId": "LogStream", "responses": { "200": { - "description": "", + "description": "(streaming responses)", "schema": { "$ref": "#/definitions/controllerLogStreamResponse" } diff --git a/api/server.go b/api/server.go index 25034953..0ba84d13 100644 --- a/api/server.go +++ b/api/server.go @@ -1,7 +1,6 @@ package main import ( - "bytes" "cloud.google.com/go/compute/metadata" "fmt" pbs "github.com/dinesh/datacol/api/controller" @@ -298,21 +297,35 @@ func (s *Server) ResourceUnlink(ctx context.Context, req *pbs.AppResourceReq) (* return ret, nil } -func (s *Server) LogStream(ctx context.Context, req *pbs.LogStreamReq) (*pbs.LogStreamResponse, error) { - buf := new(bytes.Buffer) +func (s *Server) LogStream(req *pbs.LogStreamReq, stream pbs.ProviderService_LogStreamServer) error { since, err := ptypes.Duration(req.Since) if err != nil { - return nil, err + return err } - if err := s.Provider.LogStream(req.Name, buf, pb.LogStreamOptions{ + reader, close, err := s.Provider.LogStream(req.Name, pb.LogStreamOptions{ Follow: req.Follow, Since: since, - }); err != nil { - return nil, err + }) + + if err != nil { + return err } + defer close() + + for { + line, err := reader.ReadBytes('\n') + if err != nil { + if err == io.EOF { + return nil + } + return err + } - return &pbs.LogStreamResponse{Data: buf.Bytes()}, nil + if err := stream.Send(&pbs.LogStreamResponse{Data: line}); err != nil { + return err + } + } } func (s *Server) unaryInterceptor( diff --git a/client/apps.go b/client/apps.go index 04d49848..9ebed8a0 100644 --- a/client/apps.go +++ b/client/apps.go @@ -1,7 +1,6 @@ package client import ( - "bytes" pbs "github.com/dinesh/datacol/api/controller" pb "github.com/dinesh/datacol/api/models" "github.com/golang/protobuf/ptypes" @@ -36,7 +35,7 @@ func (c *Client) RestartApp(name string) error { } func (c *Client) StreamAppLogs(name string, follow bool, since time.Duration, out io.Writer) error { - ret, err := c.ProviderServiceClient.LogStream(ctx, &pbs.LogStreamReq{ + stream, err := c.ProviderServiceClient.LogStream(ctx, &pbs.LogStreamReq{ Name: name, Since: ptypes.DurationProto(since), Follow: follow, @@ -45,11 +44,20 @@ func (c *Client) StreamAppLogs(name string, follow bool, since time.Duration, ou return err } - if _, err = io.Copy(out, bytes.NewBuffer(ret.Data)); err != nil { - return err - } + defer stream.CloseSend() - return nil + for { + ret, err := stream.Recv() + if err != nil { + if err == io.EOF { + return nil + } + return err + } + if _, err := out.Write(ret.Data); err != nil { + return err + } + } } func (c *Client) RunProcess(name string, args []string) (*pbs.CmdResponse, error) { diff --git a/cloud/google/provider.go b/cloud/google/provider.go index 4a8dfdc3..242d0968 100644 --- a/cloud/google/provider.go +++ b/cloud/google/provider.go @@ -1,6 +1,7 @@ package google import ( + "bufio" "cloud.google.com/go/datastore" "context" "fmt" @@ -98,16 +99,16 @@ func runningPods(ns, app string, c *kubernetes.Clientset) (string, error) { return podNames[0], nil } -func (g *GCPCloud) LogStream(app string, out io.Writer, opts pb.LogStreamOptions) error { +func (g *GCPCloud) LogStream(app string, opts pb.LogStreamOptions) (*bufio.Reader, func() error, error) { ns := g.DeploymentName c, err := getKubeClientset(ns) if err != nil { - return err + return nil, nil, err } pod, err := runningPods(ns, app, c) if err != nil { - return err + return nil, nil, err } log.Debugf("Getting logs from pod %s", pod) @@ -127,12 +128,10 @@ func (g *GCPCloud) LogStream(app string, out io.Writer, opts pb.LogStreamOptions rc, err := req.Stream() if err != nil { - return err + return nil, nil, err } - defer rc.Close() - _, err = io.Copy(out, rc) - return err + return bufio.NewReader(rc), rc.Close, nil } func (g *GCPCloud) storage() *storage.Service { diff --git a/cloud/provider.go b/cloud/provider.go index a988de20..f2012de2 100644 --- a/cloud/provider.go +++ b/cloud/provider.go @@ -1,6 +1,7 @@ package cloud import ( + "bufio" pb "github.com/dinesh/datacol/api/models" "io" ) @@ -25,7 +26,7 @@ type Provider interface { ReleaseList(string, int) (pb.Releases, error) ReleaseDelete(string, string) error - LogStream(app string, w io.Writer, opts pb.LogStreamOptions) error + LogStream(app string, opts pb.LogStreamOptions) (*bufio.Reader, func() error, error) ResourceList() (pb.Resources, error) ResourceCreate(name, kind string, params map[string]string) (*pb.Resource, error) diff --git a/cmd/logs.go b/cmd/logs.go index c3d1b9a9..0849a120 100644 --- a/cmd/logs.go +++ b/cmd/logs.go @@ -14,7 +14,8 @@ func init() { Action: cmdAppLogStream, Flags: []cli.Flag{ &cli.BoolFlag{ - Name: "follow, f", + Name: "follow", + Aliases: []string{"f"}, Usage: "keep streaming new log output (default)", }, &cli.DurationFlag{