Add Status endpoint with Clair configuration

Implement a status endpoint providing the current lister/detector in
the current instance of Clair.
This commit is contained in:
Sida Chen 2018-08-30 15:09:24 -04:00
parent 7f9c0b1b07
commit d28f3214ce
8 changed files with 381 additions and 113 deletions

View File

@ -21,6 +21,8 @@ It has these top-level messages:
PagedVulnerableAncestries
MarkNotificationAsReadRequest
MarkNotificationAsReadResponse
GetStatusRequest
GetStatusResponse
*/
package clairpb
@ -677,6 +679,39 @@ func (m *MarkNotificationAsReadResponse) String() string { return pro
func (*MarkNotificationAsReadResponse) ProtoMessage() {}
func (*MarkNotificationAsReadResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{12} }
type GetStatusRequest struct {
Test string `protobuf:"bytes,1,opt,name=test" json:"test,omitempty"`
}
func (m *GetStatusRequest) Reset() { *m = GetStatusRequest{} }
func (m *GetStatusRequest) String() string { return proto.CompactTextString(m) }
func (*GetStatusRequest) ProtoMessage() {}
func (*GetStatusRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{13} }
func (m *GetStatusRequest) GetTest() string {
if m != nil {
return m.Test
}
return ""
}
type GetStatusResponse struct {
// The status of the current Clair instance.
Status *ClairStatus `protobuf:"bytes,1,opt,name=status" json:"status,omitempty"`
}
func (m *GetStatusResponse) Reset() { *m = GetStatusResponse{} }
func (m *GetStatusResponse) String() string { return proto.CompactTextString(m) }
func (*GetStatusResponse) ProtoMessage() {}
func (*GetStatusResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{14} }
func (m *GetStatusResponse) GetStatus() *ClairStatus {
if m != nil {
return m.Status
}
return nil
}
func init() {
proto.RegisterType((*Vulnerability)(nil), "coreos.clair.Vulnerability")
proto.RegisterType((*Feature)(nil), "coreos.clair.Feature")
@ -695,6 +730,8 @@ func init() {
proto.RegisterType((*PagedVulnerableAncestries_IndexedAncestryName)(nil), "coreos.clair.PagedVulnerableAncestries.IndexedAncestryName")
proto.RegisterType((*MarkNotificationAsReadRequest)(nil), "coreos.clair.MarkNotificationAsReadRequest")
proto.RegisterType((*MarkNotificationAsReadResponse)(nil), "coreos.clair.MarkNotificationAsReadResponse")
proto.RegisterType((*GetStatusRequest)(nil), "coreos.clair.GetStatusRequest")
proto.RegisterType((*GetStatusResponse)(nil), "coreos.clair.GetStatusResponse")
}
// Reference imports to suppress errors if they are not otherwise used.
@ -907,83 +944,152 @@ var _NotificationService_serviceDesc = grpc.ServiceDesc{
Metadata: "api/v3/clairpb/clair.proto",
}
// Client API for StatusService service
type StatusServiceClient interface {
// The RPC used to show the internal state of current Clair instance.
GetStatus(ctx context.Context, in *GetStatusRequest, opts ...grpc.CallOption) (*GetStatusResponse, error)
}
type statusServiceClient struct {
cc *grpc.ClientConn
}
func NewStatusServiceClient(cc *grpc.ClientConn) StatusServiceClient {
return &statusServiceClient{cc}
}
func (c *statusServiceClient) GetStatus(ctx context.Context, in *GetStatusRequest, opts ...grpc.CallOption) (*GetStatusResponse, error) {
out := new(GetStatusResponse)
err := grpc.Invoke(ctx, "/coreos.clair.StatusService/GetStatus", in, out, c.cc, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// Server API for StatusService service
type StatusServiceServer interface {
// The RPC used to show the internal state of current Clair instance.
GetStatus(context.Context, *GetStatusRequest) (*GetStatusResponse, error)
}
func RegisterStatusServiceServer(s *grpc.Server, srv StatusServiceServer) {
s.RegisterService(&_StatusService_serviceDesc, srv)
}
func _StatusService_GetStatus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetStatusRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(StatusServiceServer).GetStatus(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/coreos.clair.StatusService/GetStatus",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(StatusServiceServer).GetStatus(ctx, req.(*GetStatusRequest))
}
return interceptor(ctx, in, info, handler)
}
var _StatusService_serviceDesc = grpc.ServiceDesc{
ServiceName: "coreos.clair.StatusService",
HandlerType: (*StatusServiceServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "GetStatus",
Handler: _StatusService_GetStatus_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "api/v3/clairpb/clair.proto",
}
func init() { proto.RegisterFile("api/v3/clairpb/clair.proto", fileDescriptor0) }
var fileDescriptor0 = []byte{
// 1191 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x57, 0x4f, 0x73, 0xdb, 0x44,
0x14, 0x1f, 0x29, 0x71, 0xec, 0x3c, 0x3b, 0x7f, 0xba, 0x76, 0x53, 0x45, 0x69, 0x8b, 0x23, 0xe8,
0xb4, 0x93, 0x30, 0xf6, 0xc4, 0xe1, 0x50, 0xc2, 0x81, 0x49, 0xda, 0xa6, 0x74, 0xa6, 0x74, 0x3a,
0x2a, 0xe4, 0x00, 0x07, 0xcf, 0x5a, 0x7a, 0x4e, 0x34, 0x91, 0x25, 0xa3, 0x5d, 0x3b, 0xf1, 0x74,
0x7a, 0xe1, 0xca, 0x09, 0x38, 0xf0, 0x19, 0xb8, 0xf0, 0x25, 0xb8, 0x72, 0x02, 0x8e, 0x70, 0x63,
0x06, 0xbe, 0x00, 0x77, 0x66, 0x57, 0x2b, 0x45, 0x72, 0xd4, 0x24, 0xa5, 0x27, 0xeb, 0xfd, 0xde,
0x9f, 0x7d, 0x7f, 0x7e, 0x6f, 0x37, 0x01, 0x93, 0x0e, 0xbd, 0xf6, 0x78, 0xbb, 0xed, 0xf8, 0xd4,
0x8b, 0x86, 0xbd, 0xf8, 0xb7, 0x35, 0x8c, 0x42, 0x1e, 0x92, 0x9a, 0x13, 0x46, 0x18, 0xb2, 0x96,
0xc4, 0xcc, 0x77, 0x0e, 0xc3, 0xf0, 0xd0, 0xc7, 0xb6, 0xd4, 0xf5, 0x46, 0xfd, 0x36, 0xf7, 0x06,
0xc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 0x18, 0x6a,
0xd9, 0x1b, 0x89, 0xac, 0x5f, 0x7a, 0x41, 0x9a, 0xd6, 0x45, 0x26, 0xea, 0xe4, 0x86, 0x3c, 0x79,
0xd1, 0x9a, 0x4f, 0x4f, 0xde, 0xd1, 0x36, 0x3a, 0x3f, 0xea, 0x50, 0xcf, 0xb6, 0x25, 0xa9, 0xfd,
0x15, 0x2c, 0x4d, 0x2d, 0x37, 0x79, 0xef, 0x92, 0xdd, 0x8f, 0x53, 0xb9, 0x73, 0xa5, 0x1b, 0xc2,
0xba, 0x25, 0xb3, 0xb9, 0x41, 0xae, 0xb7, 0xb3, 0xb7, 0x03, 0x6b, 0xbf, 0x8c, 0x7b, 0xf0, 0x9d,
0x06, 0x2b, 0xc5, 0x13, 0x23, 0x53, 0x6f, 0xd5, 0x85, 0x64, 0x30, 0xdf, 0xbf, 0x9a, 0x71, 0x3e,
0xa9, 0x8d, 0xe2, 0xa4, 0xf6, 0x6e, 0x43, 0xdd, 0x09, 0x07, 0xf9, 0x88, 0xc3, 0xde, 0x17, 0x65,
0xf5, 0x5f, 0x49, 0x6f, 0x4e, 0xfe, 0x31, 0xb7, 0xfd, 0x5f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xe6,
0x24, 0x28, 0x46, 0xae, 0x0c, 0x00, 0x00,
// 1247 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x57, 0x4b, 0x73, 0xdb, 0xd4,
0x17, 0x1f, 0x29, 0x71, 0x6c, 0x1f, 0x3b, 0x8f, 0x5e, 0xbb, 0xa9, 0xa2, 0xf4, 0x91, 0xe8, 0xff,
0x2f, 0xed, 0xb4, 0x8c, 0x3d, 0x75, 0x59, 0x94, 0xb2, 0x60, 0xd2, 0x47, 0x4a, 0x67, 0x4a, 0xa7,
0xa3, 0x42, 0x16, 0x30, 0x8c, 0xe7, 0x5a, 0x3a, 0x4e, 0x34, 0x91, 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3, 0xdf, 0x3d, 0x9b, 0x72, 0x31, 0xa9, 0x1b, 0xf3, 0x93, 0xea, 0x44, 0xb0, 0x9c,
0xa2, 0x46, 0x37, 0xe9, 0x0b, 0xa8, 0x66, 0xe0, 0x23, 0x97, 0x8f, 0x15, 0x5e, 0x40, 0xaf, 0x7d,
0xe5, 0xb5, 0x72, 0x15, 0x7d, 0x55, 0x46, 0xaf, 0x92, 0x72, 0x3b, 0xc5, 0xe4, 0xbd, 0xcb, 0xd0,
0xf0, 0xe2, 0x41, 0xd1, 0x6c, 0xd8, 0xfb, 0xac, 0xac, 0xfe, 0xeb, 0xea, 0x2d, 0xc9, 0x3f, 0x56,
0x6f, 0xff, 0x1b, 0x00, 0x00, 0xff, 0xff, 0x25, 0xa8, 0x93, 0xc1, 0x8e, 0x0d, 0x00, 0x00,
}

View File

@ -140,6 +140,23 @@ func request_NotificationService_MarkNotificationAsRead_0(ctx context.Context, m
}
var (
filter_StatusService_GetStatus_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
)
func request_StatusService_GetStatus_0(ctx context.Context, marshaler runtime.Marshaler, client StatusServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq GetStatusRequest
var metadata runtime.ServerMetadata
if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_StatusService_GetStatus_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.GetStatus(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
// RegisterAncestryServiceHandlerFromEndpoint is same as RegisterAncestryServiceHandler but
// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
func RegisterAncestryServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
@ -361,3 +378,81 @@ var (
forward_NotificationService_MarkNotificationAsRead_0 = runtime.ForwardResponseMessage
)
// RegisterStatusServiceHandlerFromEndpoint is same as RegisterStatusServiceHandler but
// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
func RegisterStatusServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
conn, err := grpc.Dial(endpoint, opts...)
if err != nil {
return err
}
defer func() {
if err != nil {
if cerr := conn.Close(); cerr != nil {
grpclog.Printf("Failed to close conn to %s: %v", endpoint, cerr)
}
return
}
go func() {
<-ctx.Done()
if cerr := conn.Close(); cerr != nil {
grpclog.Printf("Failed to close conn to %s: %v", endpoint, cerr)
}
}()
}()
return RegisterStatusServiceHandler(ctx, mux, conn)
}
// RegisterStatusServiceHandler registers the http handlers for service StatusService to "mux".
// The handlers forward requests to the grpc endpoint over "conn".
func RegisterStatusServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
return RegisterStatusServiceHandlerClient(ctx, mux, NewStatusServiceClient(conn))
}
// RegisterStatusServiceHandler registers the http handlers for service StatusService to "mux".
// The handlers forward requests to the grpc endpoint over the given implementation of "StatusServiceClient".
// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "StatusServiceClient"
// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
// "StatusServiceClient" to call the correct interceptors.
func RegisterStatusServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client StatusServiceClient) error {
mux.Handle("GET", pattern_StatusService_GetStatus_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
if cn, ok := w.(http.CloseNotifier); ok {
go func(done <-chan struct{}, closed <-chan bool) {
select {
case <-done:
case <-closed:
cancel()
}
}(ctx.Done(), cn.CloseNotify())
}
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_StatusService_GetStatus_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_StatusService_GetStatus_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
}
var (
pattern_StatusService_GetStatus_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"status"}, ""))
)
var (
forward_StatusService_GetStatus_0 = runtime.ForwardResponseMessage
)

View File

@ -207,3 +207,17 @@ message MarkNotificationAsReadRequest {
}
message MarkNotificationAsReadResponse {}
message GetStatusRequest {}
message GetStatusResponse {
// The status of the current Clair instance.
ClairStatus status = 1;
}
service StatusService {
// The RPC used to show the internal state of current Clair instance.
rpc GetStatus(GetStatusRequest) returns (GetStatusResponse) {
option (google.api.http) = { get: "/status" };
}
}

View File

@ -152,6 +152,31 @@
"NotificationService"
]
}
},
"/status": {
"get": {
"summary": "The RPC used to show the internal state of current Clair instance.",
"operationId": "GetStatus",
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/clairGetStatusResponse"
}
}
},
"parameters": [
{
"name": "test",
"in": "query",
"required": false,
"type": "string"
}
],
"tags": [
"StatusService"
]
}
}
},
"definitions": {
@ -329,6 +354,15 @@
}
}
},
"clairGetStatusResponse": {
"type": "object",
"properties": {
"status": {
"$ref": "#/definitions/clairClairStatus",
"description": "The status of the current Clair instance."
}
}
},
"clairLayer": {
"type": "object",
"properties": {

View File

@ -22,17 +22,7 @@ protoc -I/usr/include -I. \
-I"${GOPATH}/src" \
-I"${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis" \
--go_out=plugins=grpc:. \
./api/v3/clairpb/clair.proto
protoc -I/usr/include -I. \
-I"${GOPATH}/src" \
-I"${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis" \
--grpc-gateway_out=logtostderr=true:. \
./api/v3/clairpb/clair.proto
protoc -I/usr/include -I. \
-I"${GOPATH}/src" \
-I"${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis" \
--swagger_out=logtostderr=true:. \
./api/v3/clairpb/clair.proto

View File

@ -17,7 +17,6 @@ package v3
import (
"fmt"
"github.com/golang/protobuf/ptypes"
"golang.org/x/net/context"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
@ -38,6 +37,20 @@ type AncestryServer struct {
Store database.Datastore
}
// StatusServer implements StatusService interface for serving RPC.
type StatusServer struct {
Store database.Datastore
}
// GetStatus implements getting the current status of Clair via the Clair service.
func (s *StatusServer) GetStatus(ctx context.Context, req *pb.GetStatusRequest) (*pb.GetStatusResponse, error) {
if clairStatus, err := GetClairStatus(s.Store); err != nil {
return nil, status.Error(codes.Internal, err.Error())
} else {
return &pb.GetStatusResponse{Status: clairStatus}, nil
}
}
// PostAncestry implements posting an ancestry via the Clair gRPC service.
func (s *AncestryServer) PostAncestry(ctx context.Context, req *pb.PostAncestryRequest) (*pb.PostAncestryResponse, error) {
ancestryName := req.GetAncestryName()
@ -82,7 +95,7 @@ func (s *AncestryServer) PostAncestry(ctx context.Context, req *pb.PostAncestryR
return nil, status.Error(codes.Internal, "ancestry is failed to be processed: "+err.Error())
}
clairStatus, err := s.getClairStatus()
clairStatus, err := GetClairStatus(s.Store)
if err != nil {
return nil, status.Error(codes.Internal, err.Error())
}
@ -90,27 +103,6 @@ func (s *AncestryServer) PostAncestry(ctx context.Context, req *pb.PostAncestryR
return &pb.PostAncestryResponse{Status: clairStatus}, nil
}
func (s *AncestryServer) getClairStatus() (*pb.ClairStatus, error) {
status := &pb.ClairStatus{
Listers: clair.Processors.Listers,
Detectors: clair.Processors.Detectors,
}
t, firstUpdate, err := clair.GetLastUpdateTime(s.Store)
if err != nil {
return nil, err
}
if firstUpdate {
return status, nil
}
status.LastUpdateTime, err = ptypes.TimestampProto(t)
if err != nil {
return nil, err
}
return status, nil
}
// GetAncestry implements retrieving an ancestry via the Clair gRPC service.
func (s *AncestryServer) GetAncestry(ctx context.Context, req *pb.GetAncestryRequest) (*pb.GetAncestryResponse, error) {
if req.GetAncestryName() == "" {
@ -173,7 +165,7 @@ func (s *AncestryServer) GetAncestry(ctx context.Context, req *pb.GetAncestryReq
}
}
clairStatus, err := s.getClairStatus()
clairStatus, err := GetClairStatus(s.Store)
if err != nil {
return nil, status.Error(codes.Internal, err.Error())
}

View File

@ -69,16 +69,17 @@ func newGrpcServer(store database.Datastore, tlsConfig *tls.Config) *grpc.Server
grpcServer := grpc.NewServer(grpcOpts...)
pb.RegisterAncestryServiceServer(grpcServer, &AncestryServer{Store: store})
pb.RegisterNotificationServiceServer(grpcServer, &NotificationServer{Store: store})
pb.RegisterStatusServiceServer(grpcServer, &StatusServer{Store: store})
return grpcServer
}
type httpStatusWritter struct {
type httpStatusWriter struct {
http.ResponseWriter
StatusCode int
}
func (w *httpStatusWritter) WriteHeader(code int) {
func (w *httpStatusWriter) WriteHeader(code int) {
w.StatusCode = code
w.ResponseWriter.WriteHeader(code)
}
@ -87,7 +88,7 @@ func (w *httpStatusWritter) WriteHeader(code int) {
func logHandler(handler http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
start := time.Now()
lrw := &httpStatusWritter{ResponseWriter: w, StatusCode: http.StatusOK}
lrw := &httpStatusWriter{ResponseWriter: w, StatusCode: http.StatusOK}
handler.ServeHTTP(lrw, r)
@ -139,6 +140,11 @@ func newGrpcGatewayServer(ctx context.Context, listenerAddr string, tlsConfig *t
log.WithError(err).Fatal("could not initialize notification grpc gateway")
}
err = pb.RegisterStatusServiceHandler(ctx, gwmux, conn)
if err != nil {
log.WithError(err).Fatal("could not initialize status grpc gateway")
}
return logHandler(gwmux)
}

31
api/v3/util.go Normal file
View File

@ -0,0 +1,31 @@
package v3
import (
"github.com/coreos/clair"
pb "github.com/coreos/clair/api/v3/clairpb"
"github.com/coreos/clair/database"
"github.com/golang/protobuf/ptypes"
)
// GetClairStatus retrieves the current status of Clair and wrap it inside
// protobuf struct.
func GetClairStatus(store database.Datastore) (*pb.ClairStatus, error) {
status := &pb.ClairStatus{
Listers: clair.Processors.Listers,
Detectors: clair.Processors.Detectors,
}
t, firstUpdate, err := clair.GetLastUpdateTime(store)
if err != nil {
return nil, err
}
if firstUpdate {
return status, nil
}
status.LastUpdateTime, err = ptypes.TimestampProto(t)
if err != nil {
return nil, err
}
return status, nil
}