-
Notifications
You must be signed in to change notification settings - Fork 950
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
refactor: image manager #1267
refactor: image manager #1267
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1267 +/- ##
==========================================
+ Coverage 15.21% 15.59% +0.38%
==========================================
Files 172 173 +1
Lines 10735 10819 +84
==========================================
+ Hits 1633 1687 +54
- Misses 8981 9013 +32
+ Partials 121 119 -2
|
daemon/mgr/image.go
Outdated
GetImage(ctx context.Context, idOrRef string) (*types.ImageInfo, error) | ||
|
||
// RemoveImage deletes an image by reference. | ||
RemoveImage(ctx context.Context, image *types.ImageInfo, name string, option *ImageRemoveOption) error | ||
RemoveImage(ctx context.Context, idOrref string, force bool) error |
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.
s/idOrref/idOrRef ?
A minor wish of update.
daemon/mgr/image.go
Outdated
@@ -13,377 +12,361 @@ import ( | |||
"github.com/alibaba/pouch/pkg/errtypes" | |||
"github.com/alibaba/pouch/pkg/jsonstream" | |||
"github.com/alibaba/pouch/pkg/reference" | |||
"github.com/alibaba/pouch/registry" | |||
"github.com/alibaba/pouch/pkg/utils" | |||
"github.com/sirupsen/logrus" |
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 add a blank line of "github.com/sirupsen/logrus" and remove the blank line of it.
Is busybox:1.26 the only primary reference for the corresponding image? @fuweid And if we execute |
HI, @allencloud sorry to reply late.
No. Both
In order to make the primary reference simple, the image, which comes from one registry service, has two primary references in pouchd:
BTW, the primary reference means that you use it to pull the image. :)
If we execute Does it make senses to you? |
if oldP.String() == trimRef.String() { | ||
if oldP.String() != trimPrimaryRef.String() { | ||
|
||
return pkgerrors.Wrap(errtypes.ErrInvalidType, "invalid reference: cannot replace primary reference") |
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.
The following command
pouch pull registry.hub.docker.com/library/busybox@sha256:552644f12d0cb92449213f701c88fabf8e5a7acfae3fcefd144b592293ded713
pouch pull busybox:1-uclibc
will make the pouchd report error like:
ERRO[2018-05-07T16:22:07.055029807+08:00] failed to pull image busybox:1-uclibc:1-uclibc: invalid reference: cannot replace primary reference: invalid type
From my point of view, if a Ref has already been a PrimaryRef, we may not need to maintain its relationship with other PrimaryRefs.
So maybe it is more reasonable that just return nil
other then error here.
@fuweid WDYT?
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.
@YaoZengzeng , I think we should maintain the relationship.
If not, the searchable reference can override the primary relationship. In this case, we cannot clean the image in the containerd side. It maybe cause the dirty data in the host. WDYT?
I have updated my code. In this case, we should check the reference before we add it. Please take a look.
Thanks for the suggestion.
Redesign the imageStore in image mgr and make it stable. In the imageStore, we design primary reference and searchable reference. The primary reference is used for pull in containerd and searchable references are the alias the primary reference. We can use different references to find the same image so that it provides the better UEX command line. Signed-off-by: Wei Fu <[email protected]>
LGTM |
Thanks for your review, @YaoZengzeng |
Ⅰ. Describe what this PR did
Refactor image manager and make it stable.
Before this PR, we always meet the "not found" during
pouch image inspect
,pouch rmi
. We have several PR to fix the problem. But it always show up. In order to make the pouch stable, I decides to refactor.Ⅱ. Does this pull request fix one issue?
NONE
Ⅲ. Describe how you did it
I redesign the
imageStore
in ImageMgr. The design is here:Ⅳ. Describe how to verify it
First, pull the
reg.docker.alibaba-inc.com/base/busybox:latest
About inspect
The following commands have the same result.
About rmi
The following commands have the same result.
However, the
reg.docker.alibaba-inc.com/base/busybox@sha256:68effe31a4ae8312e47f54bec52d1fc925908009ce7e6f734e1b54a4169081c5
is the searchable reference. If we remove this, the image is still here because the primary reference is still here.About pull
User can use
Name:Tag@Digest
to pull image. However, the register doesn't care the tag information if the reference has the digest. In order to avoid the wrong tag information, we remove tag information in digest before pull.Therefore, the following commands has the same result
Ⅴ. Special notes for reviews