-
Notifications
You must be signed in to change notification settings - Fork 949
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: support containerd shim v2 #2759
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -400,8 +400,9 @@ func (mgr *ContainerManager) Create(ctx context.Context, name string, config *ty | |
config.HostConfig.Runtime = mgr.Config.DefaultRuntime | ||
} | ||
|
||
if _, exist := mgr.Config.Runtimes[config.HostConfig.Runtime]; !exist { | ||
return nil, errors.Wrapf(errtypes.ErrInvalidParam, "unknown runtime %s", config.HostConfig.Runtime) | ||
config.HostConfig.RuntimeType, err = mgr.getRuntimeType(config.HostConfig.Runtime) | ||
if err != nil { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks weird to validata runtime type, |
||
return nil, errors.Wrapf(errtypes.ErrInvalidParam, "unknown runtime %s: %v", config.HostConfig.Runtime, err) | ||
} | ||
|
||
snapID := id | ||
|
@@ -794,7 +795,11 @@ func (mgr *ContainerManager) createContainerdContainer(ctx context.Context, c *C | |
// set container's LogPath | ||
mgr.SetContainerLogPath(c) | ||
|
||
runtime, err := mgr.getRuntime(c.HostConfig.Runtime) | ||
if c.HostConfig.RuntimeType == "" { | ||
c.HostConfig.RuntimeType = ctrd.RuntimeTypeV1 | ||
} | ||
|
||
runtimeOptions, err := mgr.generateRuntimeOptions(c.HostConfig.Runtime) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the real entrance to create a container. Two situation to goto this method, first, normally create a container from user interface, second, PouchContainer reload containers at restart time. Inconvenient to store the runtimeOptions to the disk, containerd required a typed pointer, but we would get a map if we reload the value from disk(under restart and reload situation). Thus, we generate options every time. |
||
if err != nil { | ||
return err | ||
} | ||
|
@@ -803,7 +808,8 @@ func (mgr *ContainerManager) createContainerdContainer(ctx context.Context, c *C | |
ID: c.ID, | ||
Image: c.Config.Image, | ||
Labels: c.Config.Labels, | ||
Runtime: runtime, | ||
RuntimeType: c.HostConfig.RuntimeType, | ||
RuntimeOptions: runtimeOptions, | ||
Spec: sw.s, | ||
IO: mgr.IOs.Get(c.ID), | ||
RootFSProvided: c.RootFSProvided, | ||
|
@@ -1932,8 +1938,14 @@ func (mgr *ContainerManager) setBaseFS(ctx context.Context, c *Container) { | |
return | ||
} | ||
|
||
// io.containerd.runtime.v1.linux as a const used by runc | ||
c.BaseFS = filepath.Join(mgr.Config.HomeDir, "containerd/state", "io.containerd.runtime.v1.linux", mgr.Config.DefaultNamespace, c.ID, "rootfs") | ||
var managerID string | ||
if c.HostConfig.RuntimeType == ctrd.RuntimeTypeV1 { | ||
managerID = ctrd.RuntimeTypeV1 | ||
} else { | ||
managerID = "io.containerd.runtime.v2.task" | ||
} | ||
|
||
c.BaseFS = filepath.Join(mgr.Config.HomeDir, "containerd/state", managerID, mgr.Config.DefaultNamespace, c.ID, "rootfs") | ||
} | ||
|
||
// execProcessGC cleans unused exec processes config every 5 minutes. | ||
|
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 this is not correct, runtime type is different from runtime which we add in config. For runtime type, it can be pass by cri , we do not need to add them into config, and validate it.
As we get more runtime concept, we can remove the runtime validate, just add parameter here (it can be disscussed)
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.
What passed from CRI is also an alias name of actual runtime type and runtime options.
ContainerManager side should maintain a map (name -> runtime config), and CRI would use the name to choose the actual containerd runtime config.
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 can be decided by containerd, why use a alias name ?