New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
c8d: implement GetRepository (split GetRepository from ImageService) #45285
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
daemon/containerd/service.go
Outdated
type RegistryConfigProvider interface { | ||
type RegistryService interface { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
daemon/containerd/image_pull.go
Outdated
func (i *ImageService) GetRepository(ctx context.Context, ref reference.Named, authConfig *registry.AuthConfig) (distribution.Repository, error) { | ||
return nil, errdefs.NotImplemented(errors.New("not implemented")) | ||
func (i *ImageService) GetRepository(ctx context.Context, ref reference.Named, authConfig *registry.AuthConfig) (dist.Repository, error) { | ||
return distribution.GetRepository(ctx, ref, &distribution.ImagePullConfig{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess one question is; could we implement such services with the containerd distribution code? (should we?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I think maybe the reverse would be better - why does it need to be dependent on ImageService?
Could we move it to RegistryService instead?
EDIT: Ah, now I read why it needs to be in ImageService
😅
However, currently this method must be implemented on the ImageService to satisfy the "executor.ImageBackend" interface as used by Swarm;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we could at least move it to executor.Backend
(implemented by Daemon)? Or does swarmkit/other packages depend on this interface?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we could at least move it to executor.Backend (implemented by Daemon)? Or does swarmkit/other packages depend on this interface?
Hm.. good one. I should have a look what exactly is passed on to the cluster executor (I do think that interface also expects "push" and "pull", for which we do need the ImageService, so maybe it's not an option currently)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Swarmkit needs some struct which implements executor.ImageBackend
, but it does not follow that GetRepository
needs to be implemented in ImageService
. The daemon struct already has ImageService()
and RegistryService()
accessor methods so it should be trivial to write an adapter struct which implements the interface without having to pollute the daemon or either ImageService implementation.
4e0e04a
to
dd0807f
Compare
The GetRepository method interacts directly with the registry, and does not depend on the snapshotter, but is used for two purposes; For the GET /distribution/{name:.*}/json route; https://github.com/moby/moby/blob/dd3b71d17c614f837c4bba18baed9fa2cb31f1a4/api/server/router/distribution/backend.go#L11-L15 And to satisfy the "executor.ImageBackend" interface as used by Swarm; https://github.com/moby/moby/blob/58c027ac8ba19a3fa339c65274ea6704ccbec977/daemon/cluster/executor/backend.go#L77 This patch removes the method from the ImageService interface, and instead implements it through an composite struct that satisfies both interfaces, and an ImageBackend() method is added to the daemon. Signed-off-by: Sebastiaan van Stijn <github@gone.nl> remove GetRepository from ImageService Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
dd0807f
to
a5d46a1
Compare
@corhere @vvoland @laurazard I rewrote it to move it to the daemon, using an intermediate struct / type. PTAL |
@@ -1466,6 +1471,14 @@ func (daemon *Daemon) ImageService() ImageService { | |||
return daemon.imageService | |||
} | |||
|
|||
// ImageBackend returns an image-backend for Swarm and the distribution router. | |||
func (daemon *Daemon) ImageBackend() executorpkg.ImageBackend { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's rather unfortunate that we have this public method just so that we can create a router and a cluster on startup. The daemon here acts like an options object that carries around things used by other unrelated things
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I agree. I think we should make a pass at looking what's there, and if all of these are needed. I feel there's a lot of "ad-hoc" (oh, we need a new backend, just add something).
I'll bring this one in (hope it doesn't conflict with any of the other ones 🤞) |
The GetRepository method interacts directly with the registry, and does
not depend on the snapshotter, but is used for two purposes;
For the GET /distribution/{name:.*}/json route;
moby/api/server/router/distribution/backend.go
Lines 11 to 15 in dd3b71d
And to satisfy the "executor.ImageBackend" interface as used by Swarm;
moby/daemon/cluster/executor/backend.go
Line 77 in 58c027a
This patch removes the method from the ImageService interface, and instead
implements it through an composite struct that satisfies both interfaces,
and an ImageBackend() method is added to the daemon.
- What I did
- How I did it
- How to verify it
- Description for the changelog
- A picture of a cute animal (not mandatory but encouraged)