MCPcopy
hub / github.com/dragonflyoss/dragonfly / StatImage

Method StatImage

scheduler/service/service_v2.go:4569–4694  ·  view source on GitHub ↗

StatImage provides detailed status for a container image's distribution in peers. This is a blocking call that first resolves the image manifest and then queries all peers to collect the image's download state across the network. The response includes both layer information and the status on each p

(ctx context.Context, req *schedulerv2.StatImageRequest)

Source from the content-addressed store, hash-verified

4567// all peers to collect the image's download state across the network.
4568// The response includes both layer information and the status on each peer.
4569func (v *V2) StatImage(ctx context.Context, req *schedulerv2.StatImageRequest) (*schedulerv2.StatImageResponse, error) {
4570 log := logger.WithStatImage(req.Url)
4571
4572 if req.ConcurrentLayerCount == nil {
4573 concurrentLayerCount := int64(managertypes.DefaultPreheatConcurrentLayerCount)
4574 req.ConcurrentLayerCount = &concurrentLayerCount
4575 }
4576
4577 if req.ConcurrentPeerCount == nil {
4578 concurrentPeerCount := int64(managertypes.DefaultPreheatConcurrentPeerCount)
4579 req.ConcurrentPeerCount = &concurrentPeerCount
4580 }
4581
4582 if len(req.FilteredQueryParams) == 0 {
4583 req.FilteredQueryParams = http.DefaultFilteredQueryParams
4584 }
4585
4586 if req.Timeout == nil {
4587 req.Timeout = durationpb.New(managertypes.DefaultJobTimeout)
4588 }
4589
4590 ctx, cancel := context.WithTimeout(ctx, req.GetTimeout().AsDuration())
4591 defer cancel()
4592
4593 certPool, err := nettls.DERToCertPool(req.CertificateChain)
4594 if err != nil {
4595 msg := fmt.Sprintf("failed to parse certificate chain: %v", err)
4596 log.Error(msg)
4597 return nil, status.Error(codes.InvalidArgument, msg)
4598 }
4599
4600 layers, err := v.internalJobImage.CreatePreheatRequestsByManifestURL(ctx, &internaljob.ManifestRequest{
4601 URL: req.GetUrl(),
4602 PieceLength: req.PieceLength,
4603 Tag: req.GetTag(),
4604 Application: req.GetApplication(),
4605 FilteredQueryParams: idgen.FormatFilteredQueryParams(req.GetFilteredQueryParams()),
4606 Headers: req.GetHeader(),
4607 Username: req.GetUsername(),
4608 Password: req.GetPassword(),
4609 Platform: req.GetPlatform(),
4610 ConcurrentPeerCount: req.GetConcurrentPeerCount(),
4611 Timeout: req.GetTimeout().AsDuration(),
4612 RootCAs: certPool,
4613 InsecureSkipVerify: req.GetInsecureSkipVerify(),
4614 })
4615 if err != nil {
4616 return nil, status.Errorf(codes.InvalidArgument, "failed to resolve manifests: %v", err)
4617 }
4618
4619 if len(layers) != 1 {
4620 return nil, status.Errorf(codes.InvalidArgument, "expected exactly one layer, got %d", len(layers))
4621 }
4622
4623 resp := &schedulerv2.StatImageResponse{
4624 Image: &schedulerv2.Image{Layers: make([]*schedulerv2.Layer, 0, len(layers[0].URLs))},
4625 Peers: make([]*schedulerv2.PeerImage, 0),
4626 }

Callers 1

TestServiceV2_StatImageFunction · 0.95

Calls 9

TaskIDV2ByURLBasedFunction · 0.92
HostIDV2Function · 0.92
GetApplicationMethod · 0.65
ErrorfMethod · 0.65
InfofMethod · 0.65
GetTaskMethod · 0.65
ErrorMethod · 0.45

Tested by 1

TestServiceV2_StatImageFunction · 0.76