Skip to content

Spegel does not advertise content loaded using ctr image import #1096

@brandond

Description

@brandond

Spegel version

All since #888

Kubernetes distribution

k3s, rke2

Kubernetes version

n/a

CNI

n/a

Describe the bug

  • When spegel gets a ContentCreate event from containerd, it does not advertise the layer content if the event lacks a Digest:
    // Just advertise the image if it is a tag reference.
    if img.Digest == "" {
    return []OCIEvent{{Type: CreateEvent, Reference: img.Reference}}, nil
    }

    This is a problem, as the ImageCreate events generated by containerd when an image is imported from tarball only contain the tag, not the digest. There is no event generated for the image digest, so the image digest and layer content digests are never advertised.
  • When containerd imports an image instead of pulling it, it does not add containerd.io/distribution.source.<registry>=<name> labels to the content. These labels are only added by the docker remote. This prevents the content from being properly tracked by spegel, as it applies label-based filters to image content:
    func contentLabelsToReferences(l map[string]string, dgst digest.Digest) ([]Reference, error) {
    refs := []Reference{}
    for k, v := range l {
    if !strings.HasPrefix(k, labels.LabelDistributionSource) {
    continue
    }
    ref := Reference{
    Registry: strings.TrimPrefix(k, labels.LabelDistributionSource+"."),
    Repository: v,
    Digest: dgst,
    }
    refs = append(refs, ref)
    }
    if len(refs) == 0 {
    return nil, fmt.Errorf("no distribution source labels found for %s", dgst)
    }
    return refs, nil
    }

Combined, these two issues make it so that spegel fails to advertise everything except the tag when content is imported instead of pulled.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions