From 5b78dc8b677d9303b43a42a921970702da13b964 Mon Sep 17 00:00:00 2001 From: liucimin Date: Mon, 12 Nov 2018 14:41:04 +0800 Subject: [PATCH] fix_the_checkpoint_no_hostip_bug --- pkg/kubelet/checkpointmanager/checkpoint_manager_test.go | 5 +++++ pkg/kubelet/dockershim/docker_checkpoint.go | 2 ++ pkg/kubelet/dockershim/docker_sandbox.go | 1 + pkg/kubelet/dockershim/docker_service.go | 1 + 4 files changed, 9 insertions(+) diff --git a/pkg/kubelet/checkpointmanager/checkpoint_manager_test.go b/pkg/kubelet/checkpointmanager/checkpoint_manager_test.go index 6081e90483a..ecbab14c958 100644 --- a/pkg/kubelet/checkpointmanager/checkpoint_manager_test.go +++ b/pkg/kubelet/checkpointmanager/checkpoint_manager_test.go @@ -56,6 +56,8 @@ type PortMapping struct { ContainerPort *int32 // Port number on the host. HostPort *int32 + // Host ip to expose. + HostIP string } // CheckpointData is a sample example structure to be used in test cases for checkpointing @@ -151,17 +153,20 @@ func TestCheckpointManager(t *testing.T) { port80 := int32(80) port443 := int32(443) proto := protocol("tcp") + ip1234 := "1.2.3.4" portMappings := []*PortMapping{ { &proto, &port80, &port80, + ip1234, }, { &proto, &port443, &port443, + ip1234, }, } checkpoint1 := newFakeCheckpointV1("check1", portMappings, true) diff --git a/pkg/kubelet/dockershim/docker_checkpoint.go b/pkg/kubelet/dockershim/docker_checkpoint.go index 8bfa1a77822..186ee1e1084 100644 --- a/pkg/kubelet/dockershim/docker_checkpoint.go +++ b/pkg/kubelet/dockershim/docker_checkpoint.go @@ -46,6 +46,8 @@ type PortMapping struct { ContainerPort *int32 `json:"container_port,omitempty"` // Port number on the host. HostPort *int32 `json:"host_port,omitempty"` + // Host ip to expose. + HostIP string `json:"host_ip,omitempty"` } // CheckpointData contains all types of data that can be stored in the checkpoint. diff --git a/pkg/kubelet/dockershim/docker_sandbox.go b/pkg/kubelet/dockershim/docker_sandbox.go index c0a9ecfa9e2..ae012377002 100644 --- a/pkg/kubelet/dockershim/docker_sandbox.go +++ b/pkg/kubelet/dockershim/docker_sandbox.go @@ -643,6 +643,7 @@ func constructPodSandboxCheckpoint(config *runtimeapi.PodSandboxConfig) checkpoi HostPort: &pm.HostPort, ContainerPort: &pm.ContainerPort, Protocol: &proto, + HostIP: pm.HostIp, }) } if config.GetLinux().GetSecurityContext().GetNamespaceOptions().GetNetwork() == runtimeapi.NamespaceMode_NODE { diff --git a/pkg/kubelet/dockershim/docker_service.go b/pkg/kubelet/dockershim/docker_service.go index 8201ab941f2..c4bc07ec931 100644 --- a/pkg/kubelet/dockershim/docker_service.go +++ b/pkg/kubelet/dockershim/docker_service.go @@ -394,6 +394,7 @@ func (ds *dockerService) GetPodPortMappings(podSandboxID string) ([]*hostport.Po HostPort: *pm.HostPort, ContainerPort: *pm.ContainerPort, Protocol: proto, + HostIP: pm.HostIP, }) } return portMappings, nil