Merge pull request #24633 from Random-Liu/fix-downward-api-ip

Automatic merge from submit-queue

Fix downward api for pod using host network.

Fixes #24576

@yujuhong @yifan-gu 
I still can't find a cleaner way to fix this, so send this for discussion.

<!-- Reviewable:start -->
---
This change is [<img src="http://reviewable.k8s.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](http://reviewable.k8s.io/reviews/kubernetes/kubernetes/24633)
<!-- Reviewable:end -->
This commit is contained in:
k8s-merge-robot 2016-05-16 11:06:45 -07:00
commit 9fe3f47ea5

View File

@ -1750,6 +1750,10 @@ func (kl *Kubelet) syncPod(o syncPodOptions) error {
// Generate final API pod status with pod and status manager status
apiPodStatus := kl.generateAPIPodStatus(pod, podStatus)
// The pod IP may be changed in generateAPIPodStatus if the pod is using host network. (See #24576)
// TODO(random-liu): After writing pod spec into container labels, check whether pod is using host network, and
// set pod IP to hostIP directly in runtime.GetPodStatus
podStatus.IP = apiPodStatus.PodIP
// Record the time it takes for the pod to become running.
existingStatus, ok := kl.statusManager.GetPodStatus(pod.UID)