-
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
feature: add pouch history functionality #2066
feature: add pouch history functionality #2066
Conversation
70a3e41
to
4649598
Compare
Codecov Report
@@ Coverage Diff @@
## master #2066 +/- ##
==========================================
- Coverage 65.35% 65.12% -0.23%
==========================================
Files 207 207
Lines 16226 16283 +57
==========================================
Hits 10605 10605
- Misses 4311 4362 +51
- Partials 1310 1316 +6
|
c3398c5
to
b66bbee
Compare
I tried to use this pull request:
I found that except the top layer, the others are all size 0? Does it make sense? @xiechengsheng @fuweid |
apis/server/router.go
Outdated
@@ -64,6 +64,7 @@ func initRoute(s *Server) http.Handler { | |||
s.addRoute(r, http.MethodPost, "/images/{name:.*}/tag", s.postImageTag) | |||
s.addRoute(r, http.MethodPost, "/images/load", withCancelHandler(s.loadImage)) | |||
s.addRoute(r, http.MethodGet, "/images/save", withCancelHandler(s.saveImage)) | |||
s.addRoute(r, http.MethodGet, "/images/{name:.*}/history", s.imageHistory) |
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/imageHistory/getImageHistory to keep the naming consistent?
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.
ok, will fix this.
apis/swagger.yml
Outdated
schema: | ||
type: "array" | ||
items: | ||
type: "object" |
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.
Could you encapsulate the whole object into an ImageHistoryRespone
or HistoryResultItem
?
Maybe this would be much nicer and this will be a separate file in apis/types.
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.
ok~
@allencloud , According to @fuweid , the whole image layers exist in pouch root direction |
b66bbee
to
75d0d75
Compare
hi @xiechengsheng, I checked the definition of config in image and found that the history information is for each layer. It means that the layer blob data represents the diff size. I wrote a demo about this.
However, we still missing ID because we don't have build the thing. How do you think? 😄 |
Agree. I think the diffID couldn't represent the lower image layer's ID. |
5946f11
to
d99f47e
Compare
@fuweid @allencloud Please re-check, thanks a lot~ |
apis/swagger.yml
Outdated
/images/{imageid}/history: | ||
get: | ||
summary: "Get an image's history" | ||
description: "Return the parent layers about image" |
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.
return the history of each layer of image
cli/history.go
Outdated
) | ||
|
||
// historyDescription is used to describe history command in detail and auto generate command doc. | ||
var historyDescription = "Return the history information on Pouch image" |
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.
Return the history information on Pouch image
I think we use Return the history information about image
, how do you think?
daemon/mgr/image.go
Outdated
|
||
// layers info | ||
cs := img.ContentStore() | ||
manifest, err := ctrdmetaimages.Manifest(ctx, cs, img.Target(), platforms.Default()) |
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.
could we extract the function for this part? call the getLayer
, how do you think?
daemon/mgr/image.go
Outdated
|
||
// Note: ociImage History layers info and manifest layers info are all in order from bottom-most to top-most, but the | ||
// user-interactive history is in order from top-most to top-bottom, so we need to reverse ociImage History traverse order. | ||
for i := range ociImageHistory { |
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.
could we combine this with the following part which is about to get the size of blobs?
|
||
ociImageHistory := ociImage.History | ||
lenOciImageHistory := len(ociImageHistory) | ||
history := make([]types.HistoryResultItem, lenOciImageHistory) |
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 think we need to check the size of history is valid.
I think this pull request is really close to make it. While there is still something to finish:
|
ok, will finish this asap. |
d99f47e
to
09acabb
Compare
daemon/mgr/image.go
Outdated
} | ||
} | ||
|
||
if countNonEmptyLayer != len(manifest.Layers) { |
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.
@fuweid if you think this check is useless, then we can merge these two for
loop into one.
09acabb
to
b88b2d2
Compare
daemon/mgr/image.go
Outdated
|
||
// Note: number of manifest layers should be less than ociImage History messages due to the existence of empty layers. | ||
// The size of these empty layers should be set to 0. | ||
if !history[i].EmptyLayer { |
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.
we can do the valid check here, like
if j < 0 {
return nil, fmt.Errorf("the layer data don't match the layers")
}
Out of the loop, we need to check the j
is -1 or not. I think we can make the logic clean. How do you think?
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 think you are right.
b88b2d2
to
6717b7b
Compare
Signed-off-by: xiechengsheng <[email protected]>
6717b7b
to
86c6cd2
Compare
LGTM |
Signed-off-by: xiechengsheng [email protected]
Ⅰ. Describe what this PR did
feature: add pouch history functionality
Ⅱ. Does this pull request fix one issue?
Fix #1578
Ⅲ. Describe how you did it
containerdImageToOciImage
, I just get this info and send to client side.Ⅳ. Describe how to verify it
Ⅴ. Special notes for reviews
Here we just set imageID of top image layer, we do nothing with the lower image ID, after pouch enables build/commit functionality, we should get local lower image(parent image) layer ID. 😆