mirror of https://github.com/k3s-io/k3s
Merge pull request #42223 from Random-Liu/dockershim-better-implement-cri
Automatic merge from submit-queue (batch tested with PRs 41980, 42192, 42223, 41822, 42048) CRI: Make dockershim better implements CRI. When thinking about CRI Validation test, I found that `PodSandboxStatus.Linux.Namespaces.Options.HostPid` and `PodSandboxStatus.Linux.Namespaces.Options.HostIpc` are not populated. Although they are not used by kuberuntime now, we should populate them to conform to CRI. /cc @yujuhong @feiskyerpull/6/head
commit
5ee6ba2f59
|
@ -298,6 +298,8 @@ func (ds *dockerService) PodSandboxStatus(podSandboxID string) (*runtimeapi.PodS
|
|||
Network: netNS,
|
||||
Options: &runtimeapi.NamespaceOption{
|
||||
HostNetwork: hostNetwork,
|
||||
HostPid: sharesHostPid(r),
|
||||
HostIpc: sharesHostIpc(r),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -490,7 +492,7 @@ func (ds *dockerService) makeSandboxDockerConfig(c *runtimeapi.PodSandboxConfig,
|
|||
return createConfig, nil
|
||||
}
|
||||
|
||||
// sharesHostNetwork true if the given container is sharing the hosts's
|
||||
// sharesHostNetwork returns true if the given container is sharing the host's
|
||||
// network namespace.
|
||||
func sharesHostNetwork(container *dockertypes.ContainerJSON) bool {
|
||||
if container != nil && container.HostConfig != nil {
|
||||
|
@ -499,6 +501,24 @@ func sharesHostNetwork(container *dockertypes.ContainerJSON) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
// sharesHostPid returns true if the given container is sharing the host's pid
|
||||
// namespace.
|
||||
func sharesHostPid(container *dockertypes.ContainerJSON) bool {
|
||||
if container != nil && container.HostConfig != nil {
|
||||
return string(container.HostConfig.PidMode) == namespaceModeHost
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// sharesHostIpc returns true if the given container is sharing the host's ipc
|
||||
// namespace.
|
||||
func sharesHostIpc(container *dockertypes.ContainerJSON) bool {
|
||||
if container != nil && container.HostConfig != nil {
|
||||
return string(container.HostConfig.IpcMode) == namespaceModeHost
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func setSandboxResources(hc *dockercontainer.HostConfig) {
|
||||
hc.Resources = dockercontainer.Resources{
|
||||
MemorySwap: dockertools.DefaultMemorySwap(),
|
||||
|
|
Loading…
Reference in New Issue