mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
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 @feiskyer
This commit is contained in:
commit
5ee6ba2f59
@ -298,6 +298,8 @@ func (ds *dockerService) PodSandboxStatus(podSandboxID string) (*runtimeapi.PodS
|
|||||||
Network: netNS,
|
Network: netNS,
|
||||||
Options: &runtimeapi.NamespaceOption{
|
Options: &runtimeapi.NamespaceOption{
|
||||||
HostNetwork: hostNetwork,
|
HostNetwork: hostNetwork,
|
||||||
|
HostPid: sharesHostPid(r),
|
||||||
|
HostIpc: sharesHostIpc(r),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -490,7 +492,7 @@ func (ds *dockerService) makeSandboxDockerConfig(c *runtimeapi.PodSandboxConfig,
|
|||||||
return createConfig, nil
|
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.
|
// network namespace.
|
||||||
func sharesHostNetwork(container *dockertypes.ContainerJSON) bool {
|
func sharesHostNetwork(container *dockertypes.ContainerJSON) bool {
|
||||||
if container != nil && container.HostConfig != nil {
|
if container != nil && container.HostConfig != nil {
|
||||||
@ -499,6 +501,24 @@ func sharesHostNetwork(container *dockertypes.ContainerJSON) bool {
|
|||||||
return false
|
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) {
|
func setSandboxResources(hc *dockercontainer.HostConfig) {
|
||||||
hc.Resources = dockercontainer.Resources{
|
hc.Resources = dockercontainer.Resources{
|
||||||
MemorySwap: dockertools.DefaultMemorySwap(),
|
MemorySwap: dockertools.DefaultMemorySwap(),
|
||||||
|
Loading…
Reference in New Issue
Block a user