From 4ccc5bbe7c56f34242c4bf816e30fc4e5ca65150 Mon Sep 17 00:00:00 2001 From: Mrunal Patel Date: Wed, 29 Mar 2017 16:11:57 -0700 Subject: [PATCH] Set the container hostnames same as pod hostname Signed-off-by: Mrunal Patel --- server/container_create.go | 4 ++++ server/sandbox.go | 1 + server/sandbox_run.go | 2 ++ 3 files changed, 7 insertions(+) diff --git a/server/container_create.go b/server/container_create.go index dd39a4de..9f2681ba 100644 --- a/server/container_create.go +++ b/server/container_create.go @@ -394,6 +394,10 @@ func (s *Server) createSandboxContainer(ctx context.Context, containerID string, specgen.AddBindMount(sb.resolvPath, "/etc/resolv.conf", []string{"ro"}) } + if sb.hostname != "" { + specgen.SetHostname(sb.hostname) + } + specgen.AddAnnotation("ocid/name", containerName) specgen.AddAnnotation("ocid/sandbox_id", sb.id) specgen.AddAnnotation("ocid/sandbox_name", sb.infraContainer.Name()) diff --git a/server/sandbox.go b/server/sandbox.go index b1c9eede..747c4dad 100644 --- a/server/sandbox.go +++ b/server/sandbox.go @@ -141,6 +141,7 @@ type sandbox struct { cgroupParent string privileged bool resolvPath string + hostname string } const ( diff --git a/server/sandbox_run.go b/server/sandbox_run.go index 00063984..410365f5 100644 --- a/server/sandbox_run.go +++ b/server/sandbox_run.go @@ -259,6 +259,7 @@ func (s *Server) RunPodSandbox(ctx context.Context, req *pb.RunPodSandboxRequest g.AddAnnotation("ocid/shm_path", shmPath) g.AddAnnotation("ocid/privileged_runtime", fmt.Sprintf("%v", privileged)) g.AddAnnotation("ocid/resolv_path", resolvPath) + g.AddAnnotation("ocid/hostname", hostname) sb := &sandbox{ id: id, @@ -273,6 +274,7 @@ func (s *Server) RunPodSandbox(ctx context.Context, req *pb.RunPodSandboxRequest shmPath: shmPath, privileged: privileged, resolvPath: resolvPath, + hostname: hostname, } s.addSandbox(sb)