add event log and timestamp to events api
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
parent
3dc59d565a
commit
9341a95c26
6 changed files with 191 additions and 111 deletions
|
@ -4,6 +4,7 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
|
@ -270,7 +271,7 @@ func (s *apiServer) UpdateProcess(ctx context.Context, r *types.UpdateProcessReq
|
|||
}
|
||||
|
||||
func (s *apiServer) Events(r *types.EventsRequest, stream types.API_EventsServer) error {
|
||||
events := s.sv.Events()
|
||||
events := s.sv.Events(time.Unix(int64(r.Timestamp), 0))
|
||||
defer s.sv.Unsubscribe(events)
|
||||
for e := range events {
|
||||
if err := stream.Send(&types.Event{
|
||||
|
|
|
@ -381,6 +381,7 @@ func (*UpdateContainerResponse) ProtoMessage() {}
|
|||
func (*UpdateContainerResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{23} }
|
||||
|
||||
type EventsRequest struct {
|
||||
Timestamp uint64 `protobuf:"varint,1,opt,name=timestamp" json:"timestamp,omitempty"`
|
||||
}
|
||||
|
||||
func (m *EventsRequest) Reset() { *m = EventsRequest{} }
|
||||
|
@ -1093,100 +1094,101 @@ var _API_serviceDesc = grpc.ServiceDesc{
|
|||
}
|
||||
|
||||
var fileDescriptor0 = []byte{
|
||||
// 1517 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xb4, 0x58, 0xd9, 0x6e, 0x1c, 0x45,
|
||||
0x17, 0xf6, 0xec, 0x33, 0x67, 0x16, 0xdb, 0xed, 0x6d, 0x3c, 0xf9, 0xf3, 0xc7, 0x74, 0x02, 0x89,
|
||||
0x50, 0x64, 0x05, 0x87, 0x25, 0x04, 0x09, 0x08, 0x4e, 0x44, 0x40, 0x09, 0x98, 0xd8, 0x46, 0xe2,
|
||||
0x86, 0x51, 0x4f, 0x77, 0x31, 0xd3, 0xb8, 0x37, 0xba, 0xaa, 0xbd, 0xbc, 0x42, 0xb8, 0xe7, 0x2d,
|
||||
0x90, 0xb8, 0xe2, 0x01, 0x78, 0x1c, 0x9e, 0x82, 0xd3, 0xb5, 0x4d, 0x77, 0xcf, 0x62, 0x72, 0xc1,
|
||||
0xcd, 0x48, 0x55, 0x75, 0xce, 0x77, 0xbe, 0xb3, 0x55, 0xf5, 0x19, 0x68, 0x59, 0x91, 0xbb, 0x1f,
|
||||
0xc5, 0x21, 0x0b, 0x8d, 0x1a, 0xbb, 0x8a, 0x08, 0x35, 0x47, 0xb0, 0x79, 0x1a, 0x39, 0x16, 0x23,
|
||||
0x47, 0x71, 0x68, 0x13, 0x4a, 0x5f, 0x91, 0x5f, 0x12, 0x42, 0x99, 0x01, 0x50, 0x76, 0x9d, 0x7e,
|
||||
0x69, 0xaf, 0x74, 0xaf, 0x65, 0xb4, 0xa1, 0x12, 0xe1, 0xa2, 0xcc, 0x17, 0x78, 0x62, 0x7b, 0x21,
|
||||
0x25, 0xc7, 0xcc, 0x71, 0x83, 0x7e, 0x05, 0xf7, 0x9a, 0x46, 0x17, 0x6a, 0x17, 0xae, 0xc3, 0x26,
|
||||
0xfd, 0x2a, 0x2e, 0xbb, 0x46, 0x0f, 0xea, 0x13, 0xe2, 0x8e, 0x27, 0xac, 0x5f, 0x4b, 0xd7, 0xe6,
|
||||
0x0e, 0x6c, 0x15, 0x6c, 0xd0, 0x28, 0x0c, 0x28, 0x31, 0x7f, 0x2d, 0xc1, 0xf6, 0x61, 0x4c, 0xf0,
|
||||
0xe4, 0x30, 0x0c, 0x98, 0xe5, 0x06, 0x24, 0x9e, 0x67, 0x1f, 0x17, 0xa3, 0x24, 0x70, 0x3c, 0x72,
|
||||
0x64, 0xa1, 0x8d, 0x29, 0x8d, 0x09, 0xb1, 0xcf, 0xa2, 0xd0, 0x0d, 0x18, 0xa7, 0xd1, 0x4a, 0x69,
|
||||
0x50, 0xce, 0xaa, 0xca, 0x97, 0x48, 0x03, 0x97, 0x61, 0x22, 0x68, 0xa8, 0x35, 0x89, 0xe3, 0x7e,
|
||||
0x5d, 0xad, 0x3d, 0x6b, 0x44, 0x3c, 0xda, 0x6f, 0xec, 0x55, 0xee, 0xb5, 0xcc, 0x4f, 0x61, 0x67,
|
||||
0x86, 0x8c, 0x20, 0x6a, 0xdc, 0x86, 0x96, 0xad, 0x36, 0x39, 0xa9, 0xf6, 0xc1, 0xda, 0x3e, 0x0f,
|
||||
0xe0, 0xbe, 0x16, 0x36, 0x1f, 0x41, 0xf7, 0xd8, 0x1d, 0x07, 0x96, 0x77, 0x6d, 0x0c, 0x53, 0x26,
|
||||
0x5c, 0x92, 0x13, 0xef, 0x9a, 0x6b, 0xd0, 0x53, 0x9a, 0x32, 0x32, 0x7f, 0x94, 0x60, 0xfd, 0x89,
|
||||
0xe3, 0x2c, 0x49, 0xca, 0x1a, 0x34, 0x19, 0x89, 0x7d, 0x37, 0x45, 0x29, 0xf3, 0x2c, 0xec, 0x42,
|
||||
0x35, 0xa1, 0xc8, 0xaf, 0xc2, 0xf9, 0xb5, 0x25, 0xbf, 0x53, 0xdc, 0x32, 0x3a, 0x50, 0xb5, 0xe2,
|
||||
0x31, 0xc5, 0xc0, 0x54, 0x04, 0x17, 0x12, 0x9c, 0x63, 0x54, 0xe4, 0xc2, 0xbe, 0x70, 0x64, 0x48,
|
||||
0x24, 0xcb, 0x46, 0x3e, 0x9c, 0xcd, 0x42, 0x38, 0x5b, 0x85, 0x70, 0x42, 0xba, 0x46, 0xf7, 0xab,
|
||||
0xdc, 0x16, 0x62, 0x24, 0x92, 0x65, 0x37, 0x5d, 0x8c, 0xa5, 0xdb, 0x5d, 0x63, 0x1b, 0x7a, 0x96,
|
||||
0xe3, 0xb8, 0xcc, 0x0d, 0x91, 0xf4, 0x97, 0xae, 0x43, 0x91, 0x6a, 0x05, 0xdd, 0xdf, 0x04, 0x23,
|
||||
0xeb, 0xab, 0x0c, 0xc1, 0x0b, 0x9d, 0x0e, 0x9d, 0xe7, 0x79, 0x71, 0x78, 0x3b, 0x57, 0x08, 0x65,
|
||||
0xee, 0xfb, 0xba, 0xca, 0x8d, 0x3e, 0x30, 0x07, 0xd0, 0x9f, 0x45, 0x93, 0x96, 0x1e, 0xc2, 0xce,
|
||||
0x53, 0xe2, 0x91, 0xeb, 0x2c, 0x61, 0x10, 0x03, 0xcb, 0x27, 0x22, 0x87, 0x29, 0xe0, 0xac, 0x92,
|
||||
0x04, 0xbc, 0x0d, 0x5b, 0x2f, 0x5c, 0xca, 0x96, 0xc2, 0x99, 0x3f, 0x00, 0x4c, 0x05, 0x34, 0xb8,
|
||||
0x36, 0x45, 0x2e, 0x5d, 0x26, 0x13, 0x8b, 0x41, 0x64, 0x76, 0x24, 0x7b, 0x6d, 0x03, 0xda, 0x49,
|
||||
0xe0, 0x5e, 0x1e, 0x87, 0xf6, 0x19, 0x61, 0x94, 0x97, 0x3a, 0x6f, 0x40, 0x3a, 0x21, 0x9e, 0xc7,
|
||||
0x2b, 0xbd, 0x69, 0x7e, 0x0e, 0xdb, 0x45, 0xfb, 0xb2, 0x90, 0xdf, 0x81, 0xf6, 0x34, 0x5a, 0x14,
|
||||
0xad, 0x55, 0x16, 0x85, 0xab, 0x73, 0xcc, 0x30, 0x5a, 0xf3, 0x88, 0xef, 0x41, 0x4f, 0x17, 0x3d,
|
||||
0x17, 0x12, 0xa5, 0x60, 0xb1, 0x84, 0x4a, 0x89, 0xdf, 0x4b, 0xd0, 0x90, 0xe9, 0x54, 0x25, 0xf5,
|
||||
0x1f, 0x16, 0xed, 0x3a, 0xb4, 0xe8, 0x15, 0x65, 0xc4, 0x3f, 0x92, 0xa5, 0xdb, 0x7d, 0xd3, 0xd2,
|
||||
0x7d, 0x5d, 0x82, 0x96, 0x76, 0x69, 0x71, 0xce, 0x0b, 0x17, 0x91, 0xb8, 0x74, 0xde, 0x82, 0x56,
|
||||
0x24, 0x5c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
||||
0x71, 0x5f, 0x5d, 0x0e, 0xb1, 0x48, 0xc2, 0x58, 0xb4, 0x19, 0x17, 0xc3, 0x2d, 0x27, 0x0e, 0xa3,
|
||||
0x88, 0x38, 0xc2, 0x56, 0x0a, 0x76, 0xa2, 0xc0, 0xea, 0x4a, 0x0a, 0x77, 0x22, 0x09, 0xd6, 0x50,
|
||||
0x60, 0x27, 0x1a, 0xac, 0x99, 0x11, 0x53, 0x60, 0x2d, 0x4e, 0xdc, 0x87, 0xe6, 0x61, 0x94, 0x9c,
|
||||
0x52, 0x6b, 0x4c, 0xd2, 0x46, 0x67, 0x21, 0xb3, 0xbc, 0x61, 0x92, 0x2e, 0x39, 0xf5, 0xaa, 0xb1,
|
||||
0x09, 0x9d, 0x88, 0xc4, 0x58, 0x14, 0x72, 0xb7, 0x8c, 0x49, 0xae, 0x1a, 0x37, 0x60, 0x83, 0x2f,
|
||||
0x87, 0x6e, 0x30, 0x3c, 0x23, 0x71, 0x40, 0x3c, 0x3f, 0x74, 0x88, 0xf4, 0x63, 0x17, 0xd6, 0xf5,
|
||||
0x61, 0xda, 0x6a, 0xfc, 0x88, 0xfb, 0x63, 0x9e, 0x40, 0xef, 0x64, 0x82, 0x5f, 0x03, 0xcc, 0x73,
|
||||
0x83, 0xf1, 0x53, 0x8b, 0x59, 0xc6, 0x2a, 0x34, 0x10, 0xdf, 0x0d, 0x1d, 0x2a, 0x0d, 0xa2, 0x36,
|
||||
0x13, 0x22, 0xc4, 0x19, 0xaa, 0x23, 0x11, 0x34, 0xbc, 0xce, 0xa7, 0x47, 0x69, 0x0a, 0x84, 0x41,
|
||||
0xf3, 0x47, 0xee, 0x84, 0x08, 0xbc, 0x89, 0x0f, 0xa7, 0x26, 0x2b, 0x1e, 0xce, 0x55, 0x55, 0x91,
|
||||
0xca, 0xd1, 0x7d, 0x58, 0x65, 0x9a, 0xc5, 0x10, 0xab, 0xc6, 0x92, 0x85, 0xb9, 0x25, 0x25, 0xf3,
|
||||
0x1c, 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, 0xe0, 0x54, 0x03, 0xbe,
|
||||
0x0f, 0x35, 0x31, 0x16, 0xa8, 0x8a, 0xcf, 0x4e, 0x12, 0x83, 0xcd, 0xfc, 0xa6, 0xd6, 0x7a, 0x00,
|
||||
0x75, 0xf1, 0x5d, 0xa8, 0x0b, 0x20, 0xf7, 0x99, 0x38, 0xe8, 0x64, 0x77, 0xcd, 0x95, 0x07, 0x25,
|
||||
0x65, 0x87, 0xe6, 0xec, 0xd0, 0x79, 0x76, 0x32, 0xc9, 0x19, 0xd5, 0xf9, 0xdf, 0x1f, 0x0f, 0xff,
|
||||
0x09, 0x00, 0x00, 0xff, 0xff, 0x25, 0xa3, 0x4c, 0x3f, 0x0b, 0x11, 0x00, 0x00,
|
||||
// 1522 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xb4, 0x58, 0xd9, 0x72, 0xdc, 0x44,
|
||||
0x17, 0xf6, 0xec, 0x33, 0x67, 0x16, 0xdb, 0xf2, 0x36, 0x9e, 0xfc, 0xf9, 0x63, 0x94, 0x40, 0x52,
|
||||
0x54, 0xca, 0x15, 0x1c, 0x96, 0x10, 0xaa, 0x80, 0xe0, 0xa4, 0x08, 0x54, 0x02, 0x26, 0xb6, 0xa9,
|
||||
0xe2, 0x86, 0x29, 0x8d, 0xd4, 0xcc, 0x08, 0x6b, 0x43, 0xdd, 0xf2, 0xf2, 0x0a, 0xe1, 0x9e, 0xb7,
|
||||
0xa0, 0x8a, 0x2b, 0x1e, 0x80, 0xc7, 0xe1, 0x29, 0x38, 0xea, 0x6d, 0x24, 0xcd, 0x62, 0x72, 0xc1,
|
||||
0x8d, 0xcb, 0xdd, 0x7d, 0xce, 0x77, 0xbe, 0xb3, 0x75, 0xeb, 0x0c, 0xb4, 0xac, 0xc8, 0xdd, 0x8f,
|
||||
0xe2, 0x90, 0x85, 0x46, 0x8d, 0x5d, 0x45, 0x84, 0x9a, 0x23, 0xd8, 0x3c, 0x8d, 0x1c, 0x8b, 0x91,
|
||||
0xa3, 0x38, 0xb4, 0x09, 0xa5, 0xaf, 0xc8, 0x2f, 0x09, 0xa1, 0xcc, 0x00, 0x28, 0xbb, 0x4e, 0xbf,
|
||||
0xb4, 0x57, 0xba, 0xd7, 0x32, 0xda, 0x50, 0x89, 0x70, 0x51, 0xe6, 0x0b, 0x3c, 0xb1, 0xbd, 0x90,
|
||||
0x92, 0x63, 0xe6, 0xb8, 0x41, 0xbf, 0x82, 0x7b, 0x4d, 0xa3, 0x0b, 0xb5, 0x0b, 0xd7, 0x61, 0x93,
|
||||
0x7e, 0x15, 0x97, 0x5d, 0xa3, 0x07, 0xf5, 0x09, 0x71, 0xc7, 0x13, 0xd6, 0xaf, 0xa5, 0x6b, 0x73,
|
||||
0x07, 0xb6, 0x0a, 0x36, 0x68, 0x14, 0x06, 0x94, 0x98, 0xbf, 0x96, 0x60, 0xfb, 0x30, 0x26, 0x78,
|
||||
0x72, 0x18, 0x06, 0xcc, 0x72, 0x03, 0x12, 0xcf, 0xb3, 0x8f, 0x8b, 0x51, 0x12, 0x38, 0x1e, 0x39,
|
||||
0xb2, 0xd0, 0xc6, 0x94, 0xc6, 0x84, 0xd8, 0x67, 0x51, 0xe8, 0x06, 0x8c, 0xd3, 0x68, 0xa5, 0x34,
|
||||
0x28, 0x67, 0x55, 0xe5, 0x4b, 0xa4, 0x81, 0xcb, 0x30, 0x11, 0x34, 0xd4, 0x9a, 0xc4, 0x71, 0xbf,
|
||||
0xae, 0xd6, 0x9e, 0x35, 0x22, 0x1e, 0xed, 0x37, 0xf6, 0x2a, 0xf7, 0x5a, 0xe6, 0xa7, 0xb0, 0x33,
|
||||
0x43, 0x46, 0x10, 0x35, 0x6e, 0x43, 0xcb, 0x56, 0x9b, 0x9c, 0x54, 0xfb, 0x60, 0x6d, 0x9f, 0x07,
|
||||
0x70, 0x5f, 0x0b, 0x9b, 0x8f, 0xa0, 0x7b, 0xec, 0x8e, 0x03, 0xcb, 0xbb, 0x36, 0x86, 0x29, 0x13,
|
||||
0x2e, 0xc9, 0x89, 0x77, 0xcd, 0x35, 0xe8, 0x29, 0x4d, 0x19, 0x99, 0x3f, 0x4a, 0xb0, 0xfe, 0xc4,
|
||||
0x71, 0x96, 0x24, 0x65, 0x0d, 0x9a, 0x8c, 0xc4, 0xbe, 0x9b, 0xa2, 0x94, 0x79, 0x16, 0x76, 0xa1,
|
||||
0x9a, 0x50, 0xe4, 0x57, 0xe1, 0xfc, 0xda, 0x92, 0xdf, 0x29, 0x6e, 0x19, 0x1d, 0xa8, 0x5a, 0xf1,
|
||||
0x98, 0x62, 0x60, 0x2a, 0x82, 0x0b, 0x09, 0xce, 0x31, 0x2a, 0x72, 0x61, 0x5f, 0x38, 0x32, 0x24,
|
||||
0x92, 0x65, 0x23, 0x1f, 0xce, 0x66, 0x21, 0x9c, 0xad, 0x42, 0x38, 0x21, 0x5d, 0xa3, 0xfb, 0x55,
|
||||
0x6e, 0x0b, 0x31, 0x12, 0xc9, 0xb2, 0x9b, 0x2e, 0xc6, 0xd2, 0xed, 0xae, 0xb1, 0x0d, 0x3d, 0xcb,
|
||||
0x71, 0x5c, 0xe6, 0x86, 0x48, 0xfa, 0x4b, 0xd7, 0xa1, 0x48, 0xb5, 0x82, 0xee, 0x6f, 0x82, 0x91,
|
||||
0xf5, 0x55, 0x86, 0xe0, 0x85, 0x4e, 0x87, 0xce, 0xf3, 0xbc, 0x38, 0xbc, 0x9d, 0x2b, 0x84, 0x32,
|
||||
0xf7, 0x7d, 0x5d, 0xe5, 0x46, 0x1f, 0x98, 0x03, 0xe8, 0xcf, 0xa2, 0x49, 0x4b, 0x0f, 0x61, 0xe7,
|
||||
0x29, 0xf1, 0xc8, 0x75, 0x96, 0x30, 0x88, 0x81, 0xe5, 0x13, 0x91, 0xc3, 0x14, 0x70, 0x56, 0x49,
|
||||
0x02, 0xde, 0x86, 0xad, 0x17, 0x2e, 0x65, 0x4b, 0xe1, 0x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, 0x8e, 0x64, 0x72, 0xef, 0x60, 0x2b, 0x28, 0x2f, 0x54,
|
||||
0x6e, 0x67, 0xae, 0x29, 0xe3, 0x16, 0x34, 0x7c, 0x81, 0x2f, 0xbb, 0x45, 0xd1, 0x95, 0x56, 0xcd,
|
||||
0x27, 0xb0, 0x2d, 0xae, 0xeb, 0xa5, 0x97, 0xf2, 0xcc, 0x85, 0x26, 0x3c, 0xe4, 0x41, 0x31, 0x77,
|
||||
0x61, 0x67, 0x06, 0x42, 0xf6, 0x86, 0x09, 0xdd, 0x67, 0xe7, 0x04, 0x8b, 0x4f, 0x81, 0x62, 0xfa,
|
||||
0x98, 0xeb, 0xe3, 0x7f, 0x96, 0x1f, 0x71, 0xec, 0xaa, 0xf9, 0x1d, 0xd4, 0xb8, 0x4c, 0x1a, 0x80,
|
||||
0x94, 0x9b, 0x34, 0x29, 0xcc, 0xcf, 0xb3, 0xd8, 0x55, 0x74, 0xaa, 0xaa, 0x22, 0xa6, 0x90, 0x35,
|
||||
0x0e, 0xf9, 0x67, 0x09, 0x3a, 0xdf, 0x10, 0x76, 0x11, 0xc6, 0x67, 0x69, 0xd0, 0x68, 0xa1, 0xe1,
|
||||
0xb0, 0x30, 0xe3, 0xcb, 0xe1, 0xe8, 0x8a, 0x61, 0x12, 0x79, 0x74, 0xd3, 0x5c, 0xe3, 0xce, 0x91,
|
||||
0x25, 0xda, 0xac, 0xc2, 0xf7, 0x10, 0xf7, 0xd5, 0xe5, 0x10, 0xeb, 0x26, 0x8c, 0x45, 0xe7, 0x71,
|
||||
0x31, 0xdc, 0x72, 0xe2, 0x30, 0x8a, 0x88, 0x23, 0x6c, 0xa5, 0x60, 0x27, 0x0a, 0xac, 0xae, 0xa4,
|
||||
0x70, 0x27, 0x92, 0x60, 0x0d, 0x05, 0x76, 0xa2, 0xc1, 0x9a, 0x19, 0x31, 0x05, 0xd6, 0xe2, 0xc4,
|
||||
0x7d, 0x68, 0x1e, 0x46, 0xc9, 0x29, 0xb5, 0xc6, 0x24, 0xed, 0x7d, 0x16, 0x32, 0xcb, 0x1b, 0x26,
|
||||
0xe9, 0x52, 0x04, 0xcb, 0xd8, 0x84, 0x4e, 0x44, 0x62, 0xac, 0x13, 0xb9, 0x5b, 0xc6, 0xbc, 0x57,
|
||||
0x8d, 0x1b, 0xb0, 0xc1, 0x97, 0x43, 0x37, 0x18, 0x9e, 0x91, 0x38, 0x20, 0x9e, 0x1f, 0x3a, 0x44,
|
||||
0xfa, 0xb1, 0x0b, 0xeb, 0xfa, 0x30, 0xed, 0x3e, 0x7e, 0xc4, 0xfd, 0x31, 0x4f, 0xa0, 0x77, 0x32,
|
||||
0xc1, 0x0f, 0x04, 0xe6, 0xb9, 0xc1, 0xf8, 0xa9, 0xc5, 0x2c, 0x63, 0x15, 0x1a, 0x88, 0xef, 0x86,
|
||||
0x0e, 0x95, 0x06, 0x51, 0x9b, 0x09, 0x11, 0xe2, 0x0c, 0xd5, 0x91, 0x08, 0x1a, 0xde, 0xf0, 0xd3,
|
||||
0xa3, 0x34, 0x05, 0xc2, 0xa0, 0xf9, 0x23, 0x77, 0x42, 0x04, 0xde, 0xc4, 0xb7, 0x54, 0x93, 0x15,
|
||||
0x6f, 0xe9, 0xaa, 0x2a, 0x52, 0xe5, 0xe8, 0x3e, 0xac, 0x32, 0xcd, 0x62, 0x88, 0x85, 0x64, 0xc9,
|
||||
0x5a, 0xdd, 0x92, 0x92, 0x79, 0x8e, 0xe6, 0x67, 0x00, 0x2f, 0x79, 0x6b, 0x70, 0xc6, 0xd8, 0xfd,
|
||||
0xd9, 0x00, 0x61, 0xa0, 0x7d, 0xeb, 0x52, 0x47, 0x27, 0xdd, 0x42, 0x9f, 0x7e, 0xb2, 0x5c, 0xcf,
|
||||
0x96, 0x9f, 0x0e, 0x55, 0xf3, 0xef, 0x12, 0xb4, 0x05, 0x82, 0x20, 0x89, 0x10, 0x36, 0xb6, 0x83,
|
||||
0x82, 0xd8, 0x53, 0x88, 0xf9, 0xf7, 0x25,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
0xf9, 0x2f, 0x22, 0x0f, 0xff, 0x09, 0x00, 0x00, 0xff, 0xff, 0x33, 0xc7, 0x1c, 0xe2, 0x1e, 0x11,
|
||||
0x00, 0x00,
|
||||
}
|
||||
|
|
|
@ -157,6 +157,7 @@ message UpdateContainerResponse {
|
|||
}
|
||||
|
||||
message EventsRequest {
|
||||
uint64 timestamp = 1;
|
||||
}
|
||||
|
||||
message Event {
|
||||
|
|
|
@ -101,7 +101,7 @@ func checkLimits() error {
|
|||
logrus.WithFields(logrus.Fields{
|
||||
"current": l.Cur,
|
||||
"max": l.Max,
|
||||
}).Warn("low RLIMIT_NOFILE changing to max")
|
||||
}).Warn("containerd: low RLIMIT_NOFILE changing to max")
|
||||
l.Cur = l.Max
|
||||
return syscall.Setrlimit(syscall.RLIMIT_NOFILE, &l)
|
||||
}
|
||||
|
@ -120,7 +120,6 @@ func debugMetrics(interval time.Duration, graphiteAddr string) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
logrus.Debugf("Sending metrics to Graphite server on %s", graphiteAddr)
|
||||
go graphite.Graphite(metrics.DefaultRegistry, 10e9, "metrics", addr)
|
||||
} else {
|
||||
l := log.New(os.Stdout, "[containerd] ", log.LstdFlags)
|
||||
|
@ -144,13 +143,13 @@ func processMetrics() {
|
|||
// collect the number of open fds
|
||||
fds, err := util.GetOpenFds(os.Getpid())
|
||||
if err != nil {
|
||||
logrus.WithField("error", err).Error("get open fd count")
|
||||
logrus.WithField("error", err).Error("containerd: get open fd count")
|
||||
}
|
||||
fg.Update(int64(fds))
|
||||
// get the memory used
|
||||
m := sigar.ProcMem{}
|
||||
if err := m.Get(os.Getpid()); err != nil {
|
||||
logrus.WithField("error", err).Error("get pid memory information")
|
||||
logrus.WithField("error", err).Error("containerd: get pid memory information")
|
||||
}
|
||||
memg.Update(int64(m.Size))
|
||||
}
|
||||
|
@ -188,7 +187,7 @@ func daemon(address, stateDir string, concurrency int, oom bool) error {
|
|||
}
|
||||
s := grpc.NewServer()
|
||||
types.RegisterAPIServer(s, server.NewServer(sv))
|
||||
logrus.Debugf("GRPC API listen on %s", address)
|
||||
logrus.Debugf("containerd: grpc api on %s", address)
|
||||
return s.Serve(l)
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"fmt"
|
||||
"os"
|
||||
"text/tabwriter"
|
||||
"time"
|
||||
|
||||
"github.com/codegangsta/cli"
|
||||
"github.com/docker/containerd/api/grpc/types"
|
||||
|
@ -13,21 +14,39 @@ import (
|
|||
var eventsCommand = cli.Command{
|
||||
Name: "events",
|
||||
Usage: "receive events from the containerd daemon",
|
||||
Flags: []cli.Flag{
|
||||
cli.StringFlag{
|
||||
Name: "timestamp,t",
|
||||
Usage: "get events from a specific time stamp in RFC3339Nano format",
|
||||
},
|
||||
},
|
||||
Action: func(context *cli.Context) {
|
||||
c := getClient(context)
|
||||
events, err := c.Events(netcontext.Background(), &types.EventsRequest{})
|
||||
var (
|
||||
t int64
|
||||
c = getClient(context)
|
||||
)
|
||||
if ts := context.String("timestamp"); ts != "" {
|
||||
from, err := time.Parse(time.RFC3339Nano, ts)
|
||||
if err != nil {
|
||||
fatal(err.Error(), 1)
|
||||
}
|
||||
t = from.Unix()
|
||||
}
|
||||
events, err := c.Events(netcontext.Background(), &types.EventsRequest{
|
||||
Timestamp: uint64(t),
|
||||
})
|
||||
if err != nil {
|
||||
fatal(err.Error(), 1)
|
||||
}
|
||||
w := tabwriter.NewWriter(os.Stdout, 20, 1, 3, ' ', 0)
|
||||
fmt.Fprint(w, "TYPE\tID\tPID\tSTATUS\n")
|
||||
fmt.Fprint(w, "TIME\tTYPE\tID\tPID\tSTATUS\n")
|
||||
w.Flush()
|
||||
for {
|
||||
e, err := events.Recv()
|
||||
if err != nil {
|
||||
fatal(err.Error(), 1)
|
||||
}
|
||||
fmt.Fprintf(w, "%s\t%s\t%s\t%d\n", e.Type, e.Id, e.Pid, e.Status)
|
||||
fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%d\n", time.Unix(int64(e.Timestamp), 0).Format(time.RFC3339Nano), e.Type, e.Id, e.Pid, e.Status)
|
||||
w.Flush()
|
||||
}
|
||||
},
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
package supervisor
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"sync"
|
||||
"time"
|
||||
|
@ -40,6 +43,9 @@ func New(stateDir string, oom bool) (*Supervisor, error) {
|
|||
el: eventloop.NewChanLoop(defaultBufferSize),
|
||||
monitor: monitor,
|
||||
}
|
||||
if err := setupEventLog(s); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if oom {
|
||||
s.notifier = chanotify.New()
|
||||
go func() {
|
||||
|
@ -76,6 +82,51 @@ type containerInfo struct {
|
|||
container runtime.Container
|
||||
}
|
||||
|
||||
func setupEventLog(s *Supervisor) error {
|
||||
if err := readEventLog(s); err != nil {
|
||||
return err
|
||||
}
|
||||
logrus.WithField("count", len(s.eventLog)).Debug("containerd: read past events")
|
||||
events := s.Events(time.Time{})
|
||||
f, err := os.OpenFile(filepath.Join(s.stateDir, "events.log"), os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0755)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
enc := json.NewEncoder(f)
|
||||
go func() {
|
||||
for e := range events {
|
||||
s.eventLog = append(s.eventLog, e)
|
||||
if err := enc.Encode(e); err != nil {
|
||||
logrus.WithField("error", err).Error("containerd: write event to journal")
|
||||
}
|
||||
}
|
||||
}()
|
||||
return nil
|
||||
}
|
||||
|
||||
func readEventLog(s *Supervisor) error {
|
||||
f, err := os.Open(filepath.Join(s.stateDir, "events.log"))
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
defer f.Close()
|
||||
dec := json.NewDecoder(f)
|
||||
for {
|
||||
var e Event
|
||||
if err := dec.Decode(&e); err != nil {
|
||||
if err == io.EOF {
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
s.eventLog = append(s.eventLog, e)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type Supervisor struct {
|
||||
// stateDir is the directory on the system to store container runtime state information.
|
||||
stateDir string
|
||||
|
@ -91,6 +142,7 @@ type Supervisor struct {
|
|||
notifier *chanotify.Notifier
|
||||
el eventloop.EventLoop
|
||||
monitor *Monitor
|
||||
eventLog []Event
|
||||
}
|
||||
|
||||
// Stop closes all tasks and sends a SIGTERM to each container's pid1 then waits for they to
|
||||
|
@ -117,12 +169,20 @@ type Event struct {
|
|||
|
||||
// Events returns an event channel that external consumers can use to receive updates
|
||||
// on container events
|
||||
func (s *Supervisor) Events() chan Event {
|
||||
func (s *Supervisor) Events(from time.Time) chan Event {
|
||||
s.subscriberLock.Lock()
|
||||
defer s.subscriberLock.Unlock()
|
||||
c := make(chan Event, defaultBufferSize)
|
||||
EventSubscriberCounter.Inc(1)
|
||||
s.subscribers[c] = struct{}{}
|
||||
if !from.IsZero() {
|
||||
// replay old event
|
||||
for _, e := range s.eventLog {
|
||||
if e.Timestamp.After(from) {
|
||||
c <- e
|
||||
}
|
||||
}
|
||||
}
|
||||
return c
|
||||
}
|
||||
|
||||
|
@ -145,7 +205,7 @@ func (s *Supervisor) notifySubscribers(e Event) {
|
|||
select {
|
||||
case sub <- e:
|
||||
default:
|
||||
logrus.WithField("event", e.Type).Warn("event not sent to subscriber")
|
||||
logrus.WithField("event", e.Type).Warn("containerd: event not sent to subscriber")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -157,9 +217,7 @@ func (s *Supervisor) notifySubscribers(e Event) {
|
|||
// therefore it is save to do operations in the handlers that modify state of the system or
|
||||
// state of the Supervisor
|
||||
func (s *Supervisor) Start() error {
|
||||
logrus.WithFields(logrus.Fields{
|
||||
"stateDir": s.stateDir,
|
||||
}).Debug("Supervisor started")
|
||||
logrus.WithField("stateDir", s.stateDir).Debug("containerd: supervisor running")
|
||||
return s.el.Start()
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue