rkt: handle multiple rendered images for the same imageID #1240
rkt: handle multiple rendered images for the same imageID #1240
Conversation
67c5de0
to
f715129
Compare
094e73d
to
faca338
Compare
Rebased. Do you have any thoughts on this? Thanks! |
return filepath.Join(AppsInfoPath(root), appName.String()) | ||
} | ||
|
||
// AppInfoPath returns the path to the app's appsinfo directory inside a pod. |
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.
comment copypasta
Some small comments but LGTM in general. I'm not too worried about not being able to GC old containers or run old prepared ones (@jonboulle?). After this we should definitely implement a store GC that can clean up the tree cache. |
faca338
to
b043c09
Compare
@iaguis Thanks for your review. I fixed your notes and did some other little comment fixes/changes.
Sure. I have to understand which is the better way to do this (locking or reference counting) to avoid possible races. |
c5a89f1
to
1b71902
Compare
Sorry for the delay:
I think this is fine. Let's make sure it's in a state we're happy with (and confident won't change again soon ;-) and land it in 0.9.0 @iaguis @alban could you please shepherd this through and get it merged when you're happy with it? |
Any progress on this? I would like to merge this PR but I'm hesitant to do it without a store GC because it would mean that the CAS could grow indefinitely unless the user removes manually the images from the tree store. |
1b71902
to
2032e4d
Compare
err = os.Chmod(filepath.Join(rootfs, "a"), 0600) | ||
if err != nil { | ||
t.Fatalf("unexpected error: %v", err) | ||
} | ||
|
||
// Verify image Hash. Should be different | ||
err = s.CheckTreeStore(key) | ||
err = s.CheckTreeStore(id) | ||
if err == nil { | ||
t.Fatalf("unexpected error: %v", err) |
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.
This should be "expected error but got no error" or something like that
A couple of unrelated nits I didn't notice before but LGTM. Please fix those and let's merge this PR and make sure we get #1487 too before the release :) |
If an image has dependencies, and they have changed, for the same imageID we can have multiple different rendered images. Until now this wasn't handled and rkt and the treestore used the imageID to reference the rendered image. This patch, does multiple things: * the treestore now returns a treeStoreID on store.RenderTreeStore. The treeStoreID is computed as an hash of the flattened dependency tree image keys. In this way if some dependencies have changed a new ID will be generated and a new image rendering will be done. * rkt has to use this treeStoreID instead of the imageID. * for doing this, at prepare phase, the stage1 tree store ID and every app treeStoreID is saved in the pod. Additionally in this patch the prepare phase will create a pod with all the needed data for the run phase without the need to keep the needed images in the store (excluding the need of the treestore rendered images for overlayfs) (previously store.GetImageManifest was called in the run phase). Now `rkt image rm` just removes the image from the blob store. All the rendered images in the tree store aren't touched by `rkt image rm`. They will need a future patch for cleaning the unused one (a store gc). This will probably add a reference count mechanism to the treestore, since just retrieving the treeStoreIDs from the pods is quite racy (due to pods getting created between getting the lists and removing the tree store rendered image). This means that now we can remove any image in the store at any time after the prepare phase.
2032e4d
to
906105a
Compare
@iaguis Thanks! Updated. Looks like semaphore failed only in |
Weird, let's rebuild. |
I passed now ^^ |
…ncies rkt: handle multiple rendered images for the same imageID
@iaguis Thanks! Since |
A mention in the release notes of 0.9.0 should be enough. We did something similar in 0.6.1 |
NOTE:
This is going to change the on disk format for pods, see #1132. This means that actually, after applying it,
rkt run-prepared
,rkt gc
and other commands working on pods will fail to find the stage1 path for exitstent pods and possibly other problems.If an image has dependencies, and they have changed, for the same imageID we
can have multiple different rendered images (#1198).
Until now this wasn't handled and rkt and the treestore used the imageID to
reference the rendered image.
This patch, does multiple things:
treeStoreID is computed as an hash of the flattened dependency tree image keys.
In this way if some dependencies have changed a new ID will be generated and a
new image rendering will be done.
treeStoreID is saved in the pod.
Additionally in this patch the prepare phase will create a pod with all the
needed data for the run phase without the need to keep the needed images in the
store (excluding the need of the treestore rendered images for overlayfs)
(previously store.GetImageManifest was called in the run phase).
Now
rkt image rm
just removes the image from the blob store.All the rendered images in the tree store aren't touched by
rkt image rm
.They will need a future patch for cleaning the unused one (a store gc). This
will probably add a reference count mechanism to the treestore, since just
retrieving the treeStoreIDs from the pods is quite racy (due to pods getting
created between getting the lists and removing the tree store rendered image).
This means that now we can remove any image in the store at any time after the
prepare phase.