Skip to content

ManifestService interface is awkward for client use #1296

Closed

Description

@aaronlehmann

registry/client/repository.go implements a client-side version of ManifestService. However, the ManifestService interface doesn't map well to the client-side functionality, and as a result there are some unintuitive aspects of this implementation:

  • Get can operate on either a digest or a tag, contrary to the documentation in ManifestService which says "Get retrieves the manifest specified by the given digest". To retrieve a tag, it's necessary to use a functional option which causes the dgst argument to be ignored.
  • Put needs to be passed a tag, otherwise it fails to build a URL with the error mux: variable "" doesn't match, expected "^[\\w][\\w.-]{0,127}|[a-zA-Z0-9-_+.]+:[a-fA-F0-9]+$". However, the interface doesn't include a tag argument, so this is passed in through a mandatory functional argument (which is specific to the client implementation).

My initial conclusion was that the client side version is sufficiently different from the generic ManifestService that it shouldn't try to satisfy the interface. Instead, it should expose its own member functions that make sense (GetDigest, GetTag, Put with a tag argument). I tried to make this change, but found that repository.Manifests must return distribution.ManifestService, otherwise *repository doesn't satisfy the distribution.Repository interface. So it's not easy to unravel the web of interfaces. I'm not sure how to proceed, but would really like to find a way clean up the awkwardness in the client-side manifest functions.

Activity

  1. stevvooe commented on Dec 29, 2015

    @stevvooe
    Collaborator

    Get can operate on either a digest or a tag, contrary to the documentation in ManifestService which says "Get retrieves the manifest specified by the given digest". To retrieve a tag, it's necessary to use a functional option which causes the dgst argument to be ignored.

    Not sure why this is. This should only take fetches on the primary index, which is the digest.

    Put needs to be passed a tag, otherwise it fails to build a URL with the error mux: variable "" doesn't match, expected "^[\w][\w.-]{0,127}|[a-zA-Z0-9-_+.]+:[a-fA-F0-9]+$". However, the interface doesn't include a tag argument, so this is passed in through a mandatory functional argument (which is specific to the client implementation).

    Sounds like a bug. The tag and digest should both be calculated from the manifest argument.

    Seems like most of this can be addressed by following the refactoring plan that was laid out some time ago.

  2. RichardScothern commented on Jan 5, 2016

    @RichardScothern

    I realize this is commenting on a closed issue, but wanted to add some color. I do agree with Aaron's concerns.

    Strictly, Get should only operate on a digest with the digest being retrieved from a tag service. There is currently no tag service which implements this (nor does the registry REST API support tag operations), so the tag is required to make that lookup within the registry.

    For Put. The manifest argument does not expose any tag information. The manifest implementations are behind an interface and schema 2 does not implicitly carry a tag. The tag comes from the UI and needs to be passed to the registry to make the tag association. Again with a discrete tag service, the name/tag association would be made there and the manifest Put by digest.

    I see a couple of options:

    1. Wait until a tag service has been created (or move for notary to be used)
    2. Add registry endpoints to support tagging operations
    3. Considered a new type as the argument to Put and Get which could hold a tag or a digest.
  3. stevvooe commented on Jan 5, 2016

    @stevvooe
    Collaborator

    I don't disagree with the assessment, but a lot of this is covered by the original refactoring plan. For example, the fact that Put takes other arguments was supposed to be a temporary measure dependent on the addition of the TagService. It is perfectly acceptable to issue one request to /v2/<name>/manifests/<digest> using the ManifestService then /v2/<name>/manifests/<tag> using the TagService. At some point, we can even add actual endpoints for tags, as has been proposed in the past.

    Another possibility is to "lift" the entire API and dispatch the operations with references. For example Put(reference, object) would validate the whole operation against the reference, figuring out if digests and tags should be involved. This is somewhat driven by the needs of the daemon but may be a better interface ultimately, as reference.Reference can represent the variation under concern.

    Go ahead and re-open this if you believe #354 really doesn't cover the goals here. If not, it is even okay to update that issue, as we are marching down that path anyways and it would be good to clarify for the current state of distribution.

  4. stevvooe commented on Jan 5, 2016

    @stevvooe
    Collaborator

    I realize this is commenting on a closed issue, but wanted to add some color. I do agree with Aaron's concerns.

    @RichardScothern You are allowed to break this rule when it makes sense. ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions