feature(nydusd): add nydusd support to introduse lazyload ability

Pulling image is the most time-consuming step in the container lifecycle. This PR
introduse nydus to kata container, it can lazily pull image when container start. So it
can speed up kata container create and start.

Fixes #2724

Signed-off-by: luodaowen.backend <luodaowen.backend@bytedance.com>
This commit is contained in:
luodaowen.backend
2021-08-20 18:41:53 +08:00
parent 88b3e9e848
commit 2d9f89aec7
31 changed files with 1520 additions and 114 deletions

View File

@@ -860,8 +860,15 @@ func (c *Container) rollbackFailingContainerCreation(ctx context.Context) {
if err := c.unmountHostMounts(ctx); err != nil {
c.Logger().WithError(err).Error("rollback failed unmountHostMounts()")
}
if err := bindUnmountContainerRootfs(ctx, getMountPath(c.sandbox.id), c.id); err != nil {
c.Logger().WithError(err).Error("rollback failed bindUnmountContainerRootfs()")
if c.rootFs.Type == NydusRootFSType {
if err := nydusContainerCleanup(ctx, getMountPath(c.sandbox.id), c); err != nil {
c.Logger().WithError(err).Error("rollback failed nydusContainerCleanup()")
}
} else {
if err := bindUnmountContainerRootfs(ctx, getMountPath(c.sandbox.id), c.id); err != nil {
c.Logger().WithError(err).Error("rollback failed bindUnmountContainerRootfs()")
}
}
}
@@ -890,7 +897,7 @@ func (c *Container) create(ctx context.Context) (err error) {
}
}()
if c.checkBlockDeviceSupport(ctx) {
if c.checkBlockDeviceSupport(ctx) && c.rootFs.Type != NydusRootFSType {
// If the rootfs is backed by a block device, go ahead and hotplug it to the guest
if err = c.hotplugDrive(ctx); err != nil {
return
@@ -1076,8 +1083,14 @@ func (c *Container) stop(ctx context.Context, force bool) error {
return err
}
if err := bindUnmountContainerRootfs(ctx, getMountPath(c.sandbox.id), c.id); err != nil && !force {
return err
if c.rootFs.Type == NydusRootFSType {
if err := nydusContainerCleanup(ctx, getMountPath(c.sandbox.id), c); err != nil && !force {
return err
}
} else {
if err := bindUnmountContainerRootfs(ctx, getMountPath(c.sandbox.id), c.id); err != nil && !force {
return err
}
}
if err := c.detachDevices(ctx); err != nil && !force {