Refactor namespace joining
Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
This commit is contained in:
parent
3e1bb97053
commit
2eafad8a36
1 changed files with 8 additions and 7 deletions
|
@ -435,19 +435,20 @@ func (s *Server) CreateContainer(ctx context.Context, req *pb.CreateContainerReq
|
||||||
sandboxConfig := req.GetSandboxConfig()
|
sandboxConfig := req.GetSandboxConfig()
|
||||||
fmt.Printf("sandboxConfig: %v\n", sandboxConfig)
|
fmt.Printf("sandboxConfig: %v\n", sandboxConfig)
|
||||||
|
|
||||||
// Get the namespace paths for the pod sandbox container.
|
// Join the namespace paths for the pod sandbox container.
|
||||||
podContainerName := podSandboxId + "-infra"
|
podContainerName := podSandboxId + "-infra"
|
||||||
podInfraContainer := s.state.containers[podContainerName]
|
podInfraContainer := s.state.containers[podContainerName]
|
||||||
podInfraState := s.runtime.ContainerStatus(podInfraContainer)
|
podInfraState := s.runtime.ContainerStatus(podInfraContainer)
|
||||||
|
|
||||||
logrus.Infof("pod container state %v", podInfraState)
|
logrus.Infof("pod container state %v", podInfraState)
|
||||||
|
|
||||||
netNsPath := fmt.Sprintf("/proc/%d/ns/%s", podInfraState.Pid, "net")
|
for nsType, nsFile := range map[string]string{
|
||||||
specgen.AddOrReplaceLinuxNamespace("network", netNsPath)
|
"ipc": "ipc",
|
||||||
|
"uts": "uts",
|
||||||
for _, ns := range []string{"ipc", "uts"} {
|
"network": "net",
|
||||||
nsPath := fmt.Sprintf("/proc/%d/ns/%s", podInfraState.Pid, ns)
|
} {
|
||||||
specgen.AddOrReplaceLinuxNamespace(ns, nsPath)
|
nsPath := fmt.Sprintf("/proc/%d/ns/%s", podInfraState.Pid, nsFile)
|
||||||
|
specgen.AddOrReplaceLinuxNamespace(nsType, nsPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := specgen.SaveToFile(filepath.Join(containerDir, "config.json")); err != nil {
|
if err := specgen.SaveToFile(filepath.Join(containerDir, "config.json")); err != nil {
|
||||||
|
|
Loading…
Add table
Reference in a new issue