-
Notifications
You must be signed in to change notification settings - Fork 77
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
Supermiddleware #28
Supermiddleware #28
Conversation
5f266e8
to
437a73a
Compare
c41baaa
to
ade8647
Compare
flake openshift/origin#17786 |
repo *repository | ||
} | ||
|
||
func (r *repository) BlobDescriptorService(svc distribution.BlobDescriptorService) distribution.BlobDescriptorService { |
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.
Please move this function to repository.go
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'd like to move as few functions as possible in this PR.
} | ||
|
||
if r.config.pullthrough { | ||
if r.app.extraConfig.Pullthrough.Enabled { |
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.
Please use r.app.extraConfig
instead of r.enabledMetrics
as well.
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.
done
pkg/dockerregistry/server/auth.go
Outdated
@@ -89,7 +89,8 @@ var ( | |||
ErrUnsupportedResource = errors.New("unsupported resource") | |||
) | |||
|
|||
func (app *App) newAccessController(authcfg *configuration.Auth) (registryauth.AccessController, error) { | |||
func (app *App) Auth(options map[string]interface{}) (registryauth.AccessController, error) { | |||
authcfg := app.extraConfig.Auth | |||
tokenRealm, err := configuration.TokenRealm(authcfg.TokenRealm) |
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.
- authcfg := app.extraConfig.Auth
- tokenRealm, err := configuration.TokenRealm(authcfg.TokenRealm)
+ tokenRealm, err := configuration.TokenRealm(app.extraConfig.Auth.TokenRealm)
?
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.
done
@@ -68,7 +68,7 @@ func (m *manifestService) Get(ctx context.Context, dgst digest.Digest, options . | |||
ref := imageapi.DockerImageReference{ | |||
Namespace: m.repo.namespace, | |||
Name: m.repo.name, | |||
Registry: m.repo.config.registryAddr, | |||
Registry: m.repo.app.extraConfig.Server.Addr, |
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.
Can we rename extraConfig
to config
?
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 a good idea for follow ups.
@dmage can you add |
ade8647
to
f0c5361
Compare
@legionus doc.go - done |
f0c5361
to
6d29444
Compare
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.
What problem is solved by moving them into a single package?
return reg.inst.Repository(ctx, repo, false) | ||
} | ||
|
||
// HackRegistry must not be used. |
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.
so why is it here? can it be moved into a _test.go file?
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 a huge hack and should be removed, it's here to make a private variable accessible from another module. We gave too much tasks to the type *repository
. It implements distribution.Repository and it's responsible for getting data from the image stream. But, for example, pullthroughManifestService wants *repository
and uses
- m.repo.namespace
- m.repo.name
- m.repo.getImageOfImageStream
- m.repo.rememberLayersOfManifest
- m.repo.registryOSClient
- m.repo.imageStreamGetter
In other words, it wants to fill cache and to get ImageStreamImage. But right now we can't get imageStreamGetter and cache without constructing entire *repository.
Splitting will be almost mechanical changes, but it will be pretty big and I don't want to mix it with this PR.
@bparees the main problem is BlobDescriptorService (it determines whether the blob exists in the repository). We can register only one implementation, which doesn't get any parameters. image-registry/pkg/dockerregistry/server/blobdescriptorservice.go Lines 37 to 42 in c540fa0
However we need to access the image stream from this service. And we can get it from the context. image-registry/pkg/dockerregistry/server/blobdescriptorservice.go Lines 62 to 67 in c540fa0
It's pretty ugly, but I don't see any better options. But how do we put the repository into the context? Basically we have So, the problem is solved, right? No, it isn't. :( If BlobStore.Create(ctx, ...) is called with the WithMountFrom(src) option, we should be very careful with contexts, the upstream code may call Stat on the source repository with the context from the destination repository. We have a workaround for this image-registry/pkg/dockerregistry/server/pendingerrors.go Lines 56 to 59 in c540fa0
image-registry/pkg/dockerregistry/server/pendingerrors.go Lines 130 to 151 in c540fa0
But, unfortunately, it has a bug. The context isn't modified before calling Stat. Back to the PR: writing middlewares for the blob descriptor service should be less intriguing and detective, so now we have the entire implementation of the blob descriptor service middleware in the context. And that allowed me to cover it with tests. Though, this PR is just refactoring, bug fixes will be made as follow ups. |
@bparees This is a very important change that corrects the current architecture. Our code will become more maintainable. Also it will allow us to change the caching. |
@dmage thanks for the summary, that was very helpful. |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: dmage, legionus The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these OWNERS Files:
You can indicate your approval by writing |
/retest |
The intention of the changes is to move all magic for middlewares into a single package.