diff --git a/integration/rpc_test.go b/integration/rpc_test.go index 65ea4188e47..1ca58b68ef1 100644 --- a/integration/rpc_test.go +++ b/integration/rpc_test.go @@ -133,73 +133,91 @@ func TestEventLogRPC(t *testing.T) { } func TestEventLogHTTP(t *testing.T) { - if testing.Short() { - t.Skip("skipping integration test") + var tests = []struct { + description string + endpoint string + }{ + { + description: "/v1/event_log", + endpoint: "/v1/event_log", + }, + { + description: "/v1/events", + endpoint: "/v1/events", + }, } if ShouldRunGCPOnlyTests() { t.Skip("skipping test that is not gcp only") } - httpAddr := randomPort() - teardown := setupSkaffoldWithArgs(t, "--rpc-http-port", httpAddr) - defer teardown() - time.Sleep(500 * time.Millisecond) // give skaffold time to process all events - - httpResponse, err := http.Get(fmt.Sprintf("http://localhost:%s/v1/events", httpAddr)) - if err != nil { - t.Fatalf("error connecting to gRPC REST API: %s", err.Error()) - } - defer httpResponse.Body.Close() + for _, test := range tests { + t.Run(test.description, func(t *testing.T) { + if testing.Short() { + t.Skip("skipping integration test") + } - numEntries := 0 - var logEntries []proto.LogEntry - for { - e := make([]byte, 1024) - l, err := httpResponse.Body.Read(e) - if err != nil { - t.Errorf("error reading body from http response: %s", err.Error()) - } - e = e[0:l] // remove empty bytes from slice + httpAddr := randomPort() + teardown := setupSkaffoldWithArgs(t, "--rpc-http-port", httpAddr) + defer teardown() + time.Sleep(500 * time.Millisecond) // give skaffold time to process all events - // sometimes reads can encompass multiple log entries, since Read() doesn't count newlines as EOF. - readEntries := strings.Split(string(e), "\n") - for _, entryStr := range readEntries { - if entryStr == "" { - continue + httpResponse, err := http.Get(fmt.Sprintf("http://localhost:%s%s", httpAddr, test.endpoint)) + if err != nil { + t.Fatalf("error connecting to gRPC REST API: %s", err.Error()) } - var entry proto.LogEntry - // the HTTP wrapper sticks the proto messages into a map of "result" -> message. - // attempting to JSON unmarshal drops necessary proto information, so we just manually - // strip the string off the response and unmarshal directly to the proto message - entryStr = strings.Replace(entryStr, "{\"result\":", "", 1) - entryStr = entryStr[:len(entryStr)-1] - if err := jsonpb.UnmarshalString(entryStr, &entry); err != nil { - t.Errorf("error converting http response to proto: %s", err.Error()) + defer httpResponse.Body.Close() + + numEntries := 0 + var logEntries []proto.LogEntry + for { + e := make([]byte, 1024) + l, err := httpResponse.Body.Read(e) + if err != nil { + t.Errorf("error reading body from http response: %s", err.Error()) + } + e = e[0:l] // remove empty bytes from slice + + // sometimes reads can encompass multiple log entries, since Read() doesn't count newlines as EOF. + readEntries := strings.Split(string(e), "\n") + for _, entryStr := range readEntries { + if entryStr == "" { + continue + } + var entry proto.LogEntry + // the HTTP wrapper sticks the proto messages into a map of "result" -> message. + // attempting to JSON unmarshal drops necessary proto information, so we just manually + // strip the string off the response and unmarshal directly to the proto message + entryStr = strings.Replace(entryStr, "{\"result\":", "", 1) + entryStr = entryStr[:len(entryStr)-1] + if err := jsonpb.UnmarshalString(entryStr, &entry); err != nil { + t.Errorf("error converting http response to proto: %s", err.Error()) + } + numEntries++ + logEntries = append(logEntries, entry) + } + if numEntries >= numLogEntries { + break + } } - numEntries++ - logEntries = append(logEntries, entry) - } - if numEntries >= numLogEntries { - break - } - } - metaEntries, buildEntries, deployEntries := 0, 0, 0 - for _, entry := range logEntries { - switch entry.Event.GetEventType().(type) { - case *proto.Event_MetaEvent: - metaEntries++ - case *proto.Event_BuildEvent: - buildEntries++ - case *proto.Event_DeployEvent: - deployEntries++ - default: - } + metaEntries, buildEntries, deployEntries := 0, 0, 0 + for _, entry := range logEntries { + switch entry.Event.GetEventType().(type) { + case *proto.Event_MetaEvent: + metaEntries++ + case *proto.Event_BuildEvent: + buildEntries++ + case *proto.Event_DeployEvent: + deployEntries++ + default: + } + } + // make sure we have exactly 1 meta entry, 2 deploy entries and 2 build entries + testutil.CheckDeepEqual(t, 1, metaEntries) + testutil.CheckDeepEqual(t, 2, deployEntries) + testutil.CheckDeepEqual(t, 2, buildEntries) + }) } - // make sure we have exactly 1 meta entry, 2 deploy entries and 2 build entries - testutil.CheckDeepEqual(t, 1, metaEntries) - testutil.CheckDeepEqual(t, 2, deployEntries) - testutil.CheckDeepEqual(t, 2, buildEntries) } func TestGetStateRPC(t *testing.T) { diff --git a/pkg/skaffold/server/endpoints.go b/pkg/skaffold/server/endpoints.go index 79f9f3bc73a..b908e67b9a2 100644 --- a/pkg/skaffold/server/endpoints.go +++ b/pkg/skaffold/server/endpoints.go @@ -32,6 +32,10 @@ func (s *server) EventLog(stream proto.SkaffoldService_EventLogServer) error { return event.ForEachEvent(stream.Send) } +func (s *server) Events(stream proto.SkaffoldService_EventsServer) error { + return event.ForEachEvent(stream.Send) +} + func (s *server) Handle(ctx context.Context, e *proto.Event) (*empty.Empty, error) { event.Handle(e) return &empty.Empty{}, nil diff --git a/proto/skaffold.pb.go b/proto/skaffold.pb.go index 0168b4d7aec..86f2ed788e8 100644 --- a/proto/skaffold.pb.go +++ b/proto/skaffold.pb.go @@ -701,56 +701,58 @@ func init() { func init() { proto.RegisterFile("skaffold.proto", fileDescriptor_4f2d38e344f9dbf5) } var fileDescriptor_4f2d38e344f9dbf5 = []byte{ - // 781 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x54, 0xcd, 0x6e, 0xdb, 0x46, - 0x10, 0x2e, 0x29, 0x53, 0x16, 0x47, 0xb2, 0x6c, 0x6f, 0x0d, 0x43, 0x60, 0xd5, 0xd6, 0x5d, 0xb4, - 0x85, 0xe1, 0x83, 0xe4, 0x9f, 0xa2, 0x35, 0x8c, 0xa2, 0x40, 0x1d, 0x3b, 0xf1, 0xc1, 0x0e, 0x02, - 0xca, 0xf7, 0x60, 0x2d, 0x8d, 0x14, 0xc1, 0x14, 0x97, 0x21, 0x57, 0x0a, 0x74, 0xc9, 0x21, 0xc7, - 0xe4, 0x90, 0x43, 0x9e, 0x26, 0xcf, 0x91, 0x57, 0x08, 0xf2, 0x1c, 0xc1, 0xfe, 0x89, 0xa4, 0x2d, - 0x9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61, 0x4e, 0x96, 0x3b, 0x11, 0x0b, 0x6f, 0xd5, 0xee, 0x44, 0x33, 0xc8, 0x58, 0x7e, 0x1a, 0x95, - 0xc2, 0xd3, 0x38, 0xfe, 0xec, 0xc2, 0x66, 0xcf, 0x2c, 0xf5, 0x1e, 0xa6, 0xb3, 0x71, 0x1f, 0xc9, - 0x13, 0xa8, 0x3d, 0x43, 0x61, 0xc6, 0xeb, 0x51, 0x00, 0x97, 0x72, 0x39, 0x07, 0xa5, 0xb5, 0x4b, - 0xb7, 0xdf, 0x7d, 0xf9, 0xfa, 0xc9, 0xad, 0x13, 0xbf, 0x3b, 0x3b, 0xea, 0xaa, 0x15, 0x4c, 0x2e, - 0xa0, 0xa6, 0xae, 0xbf, 0xe6, 0x23, 0xb2, 0x69, 0xc8, 0x36, 0xd3, 0xe0, 0xa1, 0x81, 0x12, 0xe5, - 0xa0, 0x41, 0x40, 0x3a, 0x50, 0xf1, 0x66, 0xfb, 0xce, 0xa1, 0x43, 0xae, 0xa1, 0x7a, 0xc5, 0xe2, - 0x41, 0x84, 0xa4, 0x94, 0x53, 0xb0, 0x22, 0x2c, 0xda, 0x56, 0x7e, 0x76, 0xe9, 0x76, 0xee, 0xa7, - 0xfb, 0x4a, 0x39, 0x38, 0x73, 0x0e, 0xc8, 0x0d, 0x78, 0x6a, 0x0e, 0x56, 0x66, 0xb5, 0xca, 0xed, - 0x8e, 0x72, 0xdb, 0xa4, 0x2a, 0x3f, 0x35, 0xf3, 0x67, 0xce, 0xc1, 0x5d, 0x55, 0xb1, 0x4e, 0xbe, - 0x07, 0x00, 0x00, 0xff, 0xff, 0x65, 0xb6, 0xba, 0xdd, 0x16, 0x07, 0x00, 0x00, + // 801 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x54, 0xcd, 0x6e, 0x23, 0x45, + 0x10, 0x66, 0xc6, 0x19, 0xc7, 0x53, 0x76, 0x9c, 0xa4, 0x09, 0x91, 0x35, 0x18, 0x08, 0x2d, 0x40, + 0x51, 0x0e, 0x76, 0x7e, 0x10, 0x44, 0x11, 0x42, 0x22, 0x10, 0x92, 0x43, 0x82, 0xd0, 0x38, 0x77, + 0xd4, 0xb1, 0xcb, 0xc6, 0xca, 0x78, 0x7a, 0x98, 0x69, 0x1b, 0xf9, 0x82, 0xd0, 0x1e, 0x77, 0x0f, + 0x7b, 0xd8, 0x47, 0xdb, 0x57, 0x58, 0xed, 0x73, 0xac, 0xfa, 0x6f, 0x7e, 0x12, 0x5b, 0xda, 0xd3, + 0x4c, 0x55, 0x7d, 0xf5, 0x75, 0xd5, 0x57, 0xdd, 0x05, 0xed, 0xec, 0x91, 0x8d, 0xc7, 0x3c, 0x1a, + 0xf5, 0x92, 0x94, 0x0b, 0x4e, 0x3c, 0xf5, 0x09, 0xba, 0x13, 0xce, 0x27, 0x11, 0xf6, 0x59, 0x32, + 0xed, 0xb3, 0x38, 0xe6, 0x82, 0x89, 0x29, 0x8f, 0x33, 0x0d, 0x0a, 0xbe, 0x32, 0x51, 0x65, 0x3d, + 0xcc, 0xc7, 0x7d, 0x31, 0x9d, 0x61, 0x26, 0xd8, 0x2c, 0x31, 0x80, 0xcf, 0x9f, 0x02, 0x70, 0x96, + 0x88, 0xa5, 0x0e, 0xd2, 0x33, 0xd8, 0x1a, 0x08, 0x26, 0x30, 0xc4, 0x2c, 0xe1, 0x71, 0x86, 0x84, + 0x82, 0x97, 0x49, 0x47, 0xc7, 0x39, 0x70, 0x0e, 0x9b, 0xa7, 0x2d, 0x8d, 0xeb, 0x69, 0x90, 0x0e, + 0xd1, 0x2e, 0x34, 0x72, 0xfc, 0x0e, 0xd4, 0x66, 0xd9, 0x44, 0xa1, 0xfd, 0x50, 0xfe, 0xd2, 0x2f, + 0x60, 0x33, 0xc4, 0x7f, 0xe6, 0x98, 0x09, 0x42, 0x60, 0x23, 0x66, 0x33, 0x34, 0x51, 0xf5, 0x4f, + 0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0xfa, 0x7f, 0x2b, 0x82, 0x0b, 0xe7, 0x88, 0xdc, 0x81, 0xa7, 0x9e, 0xd3, 0x5a, + 0x71, 0xd6, 0xd1, 0xee, 0x29, 0xda, 0x36, 0x55, 0x32, 0xa9, 0xd5, 0x71, 0xe1, 0x1c, 0x3d, 0xd4, + 0x15, 0xea, 0xec, 0x43, 0x00, 0x00, 0x00, 0xff, 0xff, 0x88, 0x38, 0x2c, 0x46, 0x5d, 0x07, 0x00, + 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -767,6 +769,7 @@ const _ = grpc.SupportPackageIsVersion4 type SkaffoldServiceClient interface { GetState(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*State, error) EventLog(ctx context.Context, opts ...grpc.CallOption) (SkaffoldService_EventLogClient, error) + Events(ctx context.Context, opts ...grpc.CallOption) (SkaffoldService_EventsClient, error) Handle(ctx context.Context, in *Event, opts ...grpc.CallOption) (*empty.Empty, error) Build(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*empty.Empty, error) } @@ -819,6 +822,37 @@ func (x *skaffoldServiceEventLogClient) Recv() (*LogEntry, error) { return m, nil } +func (c *skaffoldServiceClient) Events(ctx context.Context, opts ...grpc.CallOption) (SkaffoldService_EventsClient, error) { + stream, err := c.cc.NewStream(ctx, &_SkaffoldService_serviceDesc.Streams[1], "/proto.SkaffoldService/Events", opts...) + if err != nil { + return nil, err + } + x := &skaffoldServiceEventsClient{stream} + return x, nil +} + +type SkaffoldService_EventsClient interface { + Send(*LogEntry) error + Recv() (*LogEntry, error) + grpc.ClientStream +} + +type skaffoldServiceEventsClient struct { + grpc.ClientStream +} + +func (x *skaffoldServiceEventsClient) Send(m *LogEntry) error { + return x.ClientStream.SendMsg(m) +} + +func (x *skaffoldServiceEventsClient) Recv() (*LogEntry, error) { + m := new(LogEntry) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + func (c *skaffoldServiceClient) Handle(ctx context.Context, in *Event, opts ...grpc.CallOption) (*empty.Empty, error) { out := new(empty.Empty) err := c.cc.Invoke(ctx, "/proto.SkaffoldService/Handle", in, out, opts...) @@ -841,6 +875,7 @@ func (c *skaffoldServiceClient) Build(ctx context.Context, in *empty.Empty, opts type SkaffoldServiceServer interface { GetState(context.Context, *empty.Empty) (*State, error) EventLog(SkaffoldService_EventLogServer) error + Events(SkaffoldService_EventsServer) error Handle(context.Context, *Event) (*empty.Empty, error) Build(context.Context, *empty.Empty) (*empty.Empty, error) } @@ -855,6 +890,9 @@ func (*UnimplementedSkaffoldServiceServer) GetState(ctx context.Context, req *em func (*UnimplementedSkaffoldServiceServer) EventLog(srv SkaffoldService_EventLogServer) error { return status.Errorf(codes.Unimplemented, "method EventLog not implemented") } +func (*UnimplementedSkaffoldServiceServer) Events(srv SkaffoldService_EventsServer) error { + return status.Errorf(codes.Unimplemented, "method Events not implemented") +} func (*UnimplementedSkaffoldServiceServer) Handle(ctx context.Context, req *Event) (*empty.Empty, error) { return nil, status.Errorf(codes.Unimplemented, "method Handle not implemented") } @@ -910,6 +948,32 @@ func (x *skaffoldServiceEventLogServer) Recv() (*LogEntry, error) { return m, nil } +func _SkaffoldService_Events_Handler(srv interface{}, stream grpc.ServerStream) error { + return srv.(SkaffoldServiceServer).Events(&skaffoldServiceEventsServer{stream}) +} + +type SkaffoldService_EventsServer interface { + Send(*LogEntry) error + Recv() (*LogEntry, error) + grpc.ServerStream +} + +type skaffoldServiceEventsServer struct { + grpc.ServerStream +} + +func (x *skaffoldServiceEventsServer) Send(m *LogEntry) error { + return x.ServerStream.SendMsg(m) +} + +func (x *skaffoldServiceEventsServer) Recv() (*LogEntry, error) { + m := new(LogEntry) + if err := x.ServerStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + func _SkaffoldService_Handle_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(Event) if err := dec(in); err != nil { @@ -970,6 +1034,12 @@ var _SkaffoldService_serviceDesc = grpc.ServiceDesc{ ServerStreams: true, ClientStreams: true, }, + { + StreamName: "Events", + Handler: _SkaffoldService_Events_Handler, + ServerStreams: true, + ClientStreams: true, + }, }, Metadata: "skaffold.proto", } diff --git a/proto/skaffold.pb.gw.go b/proto/skaffold.pb.gw.go index ea0a9806d21..43e5ca1440e 100644 --- a/proto/skaffold.pb.gw.go +++ b/proto/skaffold.pb.gw.go @@ -90,6 +90,58 @@ func request_SkaffoldService_EventLog_0(ctx context.Context, marshaler runtime.M return stream, metadata, nil } +func request_SkaffoldService_Events_0(ctx context.Context, marshaler runtime.Marshaler, client SkaffoldServiceClient, req *http.Request, pathParams map[string]string) (SkaffoldService_EventsClient, runtime.ServerMetadata, error) { + var metadata runtime.ServerMetadata + stream, err := client.Events(ctx) + if err != nil { + grpclog.Infof("Failed to start streaming: %v", err) + return nil, metadata, err + } + dec := marshaler.NewDecoder(req.Body) + handleSend := func() error { + var protoReq LogEntry + err := dec.Decode(&protoReq) + if err == io.EOF { + return err + } + if err != nil { + grpclog.Infof("Failed to decode request: %v", err) + return err + } + if err := stream.Send(&protoReq); err != nil { + grpclog.Infof("Failed to send request: %v", err) + return err + } + return nil + } + if err := handleSend(); err != nil { + if cerr := stream.CloseSend(); cerr != nil { + grpclog.Infof("Failed to terminate client stream: %v", cerr) + } + if err == io.EOF { + return stream, metadata, nil + } + return nil, metadata, err + } + go func() { + for { + if err := handleSend(); err != nil { + break + } + } + if err := stream.CloseSend(); err != nil { + grpclog.Infof("Failed to terminate client stream: %v", err) + } + }() + header, err := stream.Header() + if err != nil { + grpclog.Infof("Failed to get header from client: %v", err) + return nil, metadata, err + } + metadata.HeaderMD = header + return stream, metadata, nil +} + func request_SkaffoldService_Handle_0(ctx context.Context, marshaler runtime.Marshaler, client SkaffoldServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq Event var metadata runtime.ServerMetadata @@ -202,6 +254,26 @@ func RegisterSkaffoldServiceHandlerClient(ctx context.Context, mux *runtime.Serv }) + mux.Handle("GET", pattern_SkaffoldService_Events_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_SkaffoldService_Events_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_SkaffoldService_Events_0(ctx, mux, outboundMarshaler, w, req, func() (proto.Message, error) { return resp.Recv() }, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("POST", pattern_SkaffoldService_Handle_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -248,7 +320,9 @@ func RegisterSkaffoldServiceHandlerClient(ctx context.Context, mux *runtime.Serv var ( pattern_SkaffoldService_GetState_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "state"}, "")) - pattern_SkaffoldService_EventLog_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "events"}, "")) + pattern_SkaffoldService_EventLog_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "event_log"}, "")) + + pattern_SkaffoldService_Events_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "events"}, "")) pattern_SkaffoldService_Handle_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "events", "handle"}, "")) @@ -260,6 +334,8 @@ var ( forward_SkaffoldService_EventLog_0 = runtime.ForwardResponseStream + forward_SkaffoldService_Events_0 = runtime.ForwardResponseStream + forward_SkaffoldService_Handle_0 = runtime.ForwardResponseMessage forward_SkaffoldService_Build_0 = runtime.ForwardResponseMessage diff --git a/proto/skaffold.proto b/proto/skaffold.proto index 26861098bff..06f6cbda2cd 100644 --- a/proto/skaffold.proto +++ b/proto/skaffold.proto @@ -83,6 +83,12 @@ service SkaffoldService { } rpc EventLog(stream LogEntry) returns (stream LogEntry) { + option (google.api.http) = { + get: "/v1/event_log" + }; + } + + rpc Events(stream LogEntry) returns (stream LogEntry) { option (google.api.http) = { get: "/v1/events" };