clair: Add more logging on ancestry cache hit
This commit is contained in:
parent
8aae73f1c8
commit
465687fa94
@ -278,7 +278,13 @@ func IsAncestryCached(store database.Datastore, name string, layerHashes []strin
|
|||||||
}
|
}
|
||||||
|
|
||||||
if found {
|
if found {
|
||||||
|
if len(database.DiffDetectors(EnabledDetectors(), ancestry.By)) == 0 {
|
||||||
log.WithField("ancestry.Name", name).Debug("found cached ancestry")
|
log.WithField("ancestry.Name", name).Debug("found cached ancestry")
|
||||||
|
} else {
|
||||||
|
log.WithField("ancestry.Name", name).Debug("found outdated ancestry cache")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log.WithField("ancestry.Name", name).Debug("ancestry not cached")
|
||||||
}
|
}
|
||||||
|
|
||||||
return found && len(database.DiffDetectors(EnabledDetectors(), ancestry.By)) == 0, nil
|
return found && len(database.DiffDetectors(EnabledDetectors(), ancestry.By)) == 0, nil
|
||||||
|
@ -17,8 +17,6 @@ package v3
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/coreos/clair/ext/imagefmt"
|
|
||||||
|
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
"google.golang.org/grpc/codes"
|
"google.golang.org/grpc/codes"
|
||||||
"google.golang.org/grpc/status"
|
"google.golang.org/grpc/status"
|
||||||
@ -26,6 +24,7 @@ import (
|
|||||||
"github.com/coreos/clair"
|
"github.com/coreos/clair"
|
||||||
pb "github.com/coreos/clair/api/v3/clairpb"
|
pb "github.com/coreos/clair/api/v3/clairpb"
|
||||||
"github.com/coreos/clair/database"
|
"github.com/coreos/clair/database"
|
||||||
|
"github.com/coreos/clair/ext/imagefmt"
|
||||||
"github.com/coreos/clair/pkg/commonerr"
|
"github.com/coreos/clair/pkg/commonerr"
|
||||||
"github.com/coreos/clair/pkg/pagination"
|
"github.com/coreos/clair/pkg/pagination"
|
||||||
)
|
)
|
||||||
@ -61,7 +60,6 @@ func (s *StatusServer) GetStatus(ctx context.Context, req *pb.GetStatusRequest)
|
|||||||
|
|
||||||
// PostAncestry implements posting an ancestry via the Clair gRPC service.
|
// PostAncestry implements posting an ancestry via the Clair gRPC service.
|
||||||
func (s *AncestryServer) PostAncestry(ctx context.Context, req *pb.PostAncestryRequest) (*pb.PostAncestryResponse, error) {
|
func (s *AncestryServer) PostAncestry(ctx context.Context, req *pb.PostAncestryRequest) (*pb.PostAncestryResponse, error) {
|
||||||
// validate request
|
|
||||||
blobFormat := req.GetFormat()
|
blobFormat := req.GetFormat()
|
||||||
if !imagefmt.IsSupported(blobFormat) {
|
if !imagefmt.IsSupported(blobFormat) {
|
||||||
return nil, status.Error(codes.InvalidArgument, "image blob format is not supported")
|
return nil, status.Error(codes.InvalidArgument, "image blob format is not supported")
|
||||||
@ -72,7 +70,7 @@ func (s *AncestryServer) PostAncestry(ctx context.Context, req *pb.PostAncestryR
|
|||||||
return nil, status.Error(codes.Internal, err.Error())
|
return nil, status.Error(codes.Internal, err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if the ancestry is already processed, if not we build the ancestry again.
|
// check if the ancestry is already processed; if not we build the ancestry again.
|
||||||
layerHashes := make([]string, len(req.Layers))
|
layerHashes := make([]string, len(req.Layers))
|
||||||
for i, layer := range req.Layers {
|
for i, layer := range req.Layers {
|
||||||
layerHashes[i] = layer.GetHash()
|
layerHashes[i] = layer.GetHash()
|
||||||
|
Loading…
Reference in New Issue
Block a user