-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Update storage management from root labels to leases #1176
Conversation
0816792
to
804f043
Compare
0be18c3
to
b314aa2
Compare
Finished up the migration and this should be ready now. @fuweid Can you check that the |
return nil, errors.Wrapf(err, "failed to add snapshot %s to lease", id) | ||
} | ||
|
||
if err := cm.Snapshotter.Prepare(ctx, id, parentSnapshotID); err != nil { |
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.
Is that newly created lease supposed to be used in this context?
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.
No, the id is already part of the permanent lease from the AddResource
Signed-off-by: Tonis Tiigi <[email protected]>
Signed-off-by: Tonis Tiigi <[email protected]>
Signed-off-by: Tonis Tiigi <[email protected]>
Signed-off-by: Tonis Tiigi <[email protected]>
Signed-off-by: Tonis Tiigi <[email protected]>
Signed-off-by: Tonis Tiigi <[email protected]>
Signed-off-by: Tonis Tiigi <[email protected]>
Signed-off-by: Tonis Tiigi <[email protected]>
Signed-off-by: Tonis Tiigi <[email protected]>
Signed-off-by: Tonis Tiigi <[email protected]>
Signed-off-by: Tonis Tiigi <[email protected]>
Signed-off-by: Tonis Tiigi <[email protected]>
Signed-off-by: Tonis Tiigi <[email protected]>
Signed-off-by: Tonis Tiigi <[email protected]>
Signed-off-by: Tonis Tiigi <[email protected]>
@@ -106,19 +89,31 @@ func NewWorkerOpt(root string, snFactory SnapshotterFactory, rootless bool, proc | |||
for k, v := range labels { | |||
xlabels[k] = v | |||
} | |||
snap := containerdsnapshot.NewSnapshotter(snFactory.Name, mdb.Snapshotter(snFactory.Name), "buildkit", idmap) | |||
lm := leaseutil.WithNamespace(ctdmetadata.NewLeaseManager(mdb), "buildkit") | |||
if err := cache.MigrateV2(context.TODO(), filepath.Join(root, "metadata.db"), filepath.Join(root, "metadata_v2.db"), c, snap, lm); err != nil { |
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.
Is this context going to be passed in? The calling function signature looks like it could use some attention
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.
Overall flow LGTM
Needs rebase |
467f467
to
339d4b2
Compare
Update all buildkit storage management from using root labels for containerd snapshots and blobs to using leases instead.
Every reference in
buildctl du
is now backed by non-expiring lease. Snapshots and blobs are added to the lease during the lifetime of the cache record. A record can have only a snapshot, only a blob or both. Records with only one can pick up another later (eg. after differ runs). These leases are also used for additional metadata blobs like image configs and manifests.Tracking of blob metadata is now moved directly into the cache package.
Using leases helps to avoid some races caused by the label management not being completely atomic. It also means that buildkit doesn't require full ownership of the containerd namespace anymore.
Another change is that because chainid-s are not used directly in pull, a chainid calculated by a differ can now be matched with the pulled blob.
This work depends on the flat-leases feature in containerd 1.3 . Without it metadata blobs can have back-references to layers, causing them to not get released. So containerd 1.2 and lower will not be supported after this PR.
TODO: migration from old storage metadata. Current PR only works from an empty state.