Skip to content
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

Merged

Conversation

zhuangqh
Copy link
Contributor

Signed-off-by: zhuangqh zhuangqhc@gmail.com

Ⅰ. Describe what this PR did

Ⅱ. Does this pull request fix one issue?

fixes #2749

Ⅲ. Why don't you add test cases (unit test/integration test)? (你真的觉得不需要加测试吗?)

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

  • should be compatible with legacy version PouchContainer
  • runtime dir just using /run

@codecov
Copy link

codecov bot commented Mar 18, 2019

Codecov Report

Merging #2759 into master will decrease coverage by 0.01%.
The diff coverage is 52.85%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2759      +/-   ##
==========================================
- Coverage   69.07%   69.05%   -0.02%     
==========================================
  Files         285      285              
  Lines       17758    17803      +45     
==========================================
+ Hits        12266    12294      +28     
- Misses       4092     4102      +10     
- Partials     1400     1407       +7
Flag Coverage Δ
#criv1alpha2_test 38.97% <48.57%> (-0.01%) ⬇️
#integration_test_0 36.64% <48.57%> (-0.01%) ⬇️
#integration_test_1 35.34% <48.57%> (ø) ⬆️
#integration_test_2 36.5% <48.57%> (ø) ⬆️
#integration_test_3 35.45% <48.57%> (+0.03%) ⬆️
#node_e2e_test 34.75% <48.57%> (-0.01%) ⬇️
#unittest 28.61% <20%> (-0.01%) ⬇️
Impacted Files Coverage Δ
ctrd/container.go 54.3% <100%> (-0.35%) ⬇️
daemon/mgr/container_utils.go 76.76% <45.16%> (-5.62%) ⬇️
daemon/mgr/container.go 59.52% <57.14%> (-0.04%) ⬇️
daemon/daemon_utils.go 58.82% <58.33%> (-3.68%) ⬇️
cri/v1alpha2/cri.go 68.81% <0%> (-0.26%) ⬇️
ctrd/supervisord/daemon.go 50.67% <0%> (+1.35%) ⬆️
cri/ocicni/cni_manager.go 60.37% <0%> (+1.88%) ⬆️
pkg/system/system.go 71.42% <0%> (+2.85%) ⬆️
pkg/streams/utils.go 89.28% <0%> (+7.14%) ⬆️

@fuweid fuweid self-assigned this Mar 18, 2019
@zhuangqh zhuangqh force-pushed the feature-containerd-shimv2 branch 5 times, most recently from 1be2091 to af0d9d3 Compare March 19, 2019 09:47
RuntimeRoot: ctrd.RuntimeRoot,
CriuPath: o.CriuPath,
SystemdCgroup: mgr.Config.UseSystemd(),
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

generate a brand new options according to the configuration which were passed from config file, thus, there is no data race.
we directly replace some fields here, because these fields are allowed to be configurable directly.

}

r.Options = options
Copy link
Contributor

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)

Copy link
Contributor Author

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.

Copy link
Contributor

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 ?

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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks weird to validata runtime type,

@@ -780,7 +781,7 @@ func (mgr *ContainerManager) createContainerdContainer(ctx context.Context, c *C
// set container's LogPath
mgr.SetContainerLogPath(c)

runtime, err := mgr.getRuntime(c.HostConfig.Runtime)
runtimeOptions, err := mgr.generateRuntimeOptions(c.HostConfig.Runtime)
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

@Ace-Tang
Copy link
Contributor

I think pouch should less concern the runtime type information, if it is wrong, containerd will tells.

@Ace-Tang
Copy link
Contributor

@zhuangqh , could you describe how cri reslove these options, and how we get this from cri, it will help

@zhuangqh
Copy link
Contributor Author

@zhuangqh , could you describe how cri reslove these options, and how we get this from cri, it will help

alright. On CRI side, there is only a runtime_handler option, each CRI implementation should maintain a map (runtime_handler -> config(runtime_type+runtime_options)) . Generate these two value according to the runtime_handler in CRI and pass these two value to containerd.

Signed-off-by: zhuangqh <zhuangqhc@gmail.com>
Copy link
Contributor

@fuweid fuweid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[feature request] support containerd v2 shim
4 participants