Skip to content

Commit

Permalink
kubelet: send all recevied pods in one update
Browse files Browse the repository at this point in the history
The kubelet sync loop relies on getting one update as the signal that the
specific source is ready. This change ensures that we don't send multiple
updates (ADD, UPDATE) for the first batch of pods. This is required to prevent
the cleanup routine from killing pods prematurely.
  • Loading branch information
yujuhong committed Mar 17, 2016
1 parent 1427a7c commit deafa44
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 13 deletions.
11 changes: 1 addition & 10 deletions pkg/kubelet/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,16 +238,7 @@ func (s *podStorage) merge(source string, change interface{}) (adds, updates, de
}
recordFirstSeenTime(ref)
pods[name] = ref
// If a pod is not found in the cache, and it's also not in the
// pending phase, it implies that kubelet may have restarted.
// Treat this pod as update so that kubelet wouldn't reject the
// pod in the admission process.
if ref.Status.Phase != api.PodPending {
updatePods = append(updatePods, ref)
} else {
// this is an add
addPods = append(addPods, ref)
}
addPods = append(addPods, ref)
}
}

Expand Down
3 changes: 0 additions & 3 deletions pkg/kubelet/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,6 @@ func CreateValidPod(name, namespace string) *api.Pod {
},
},
},
Status: api.PodStatus{
Phase: api.PodPending,
},
}
}

Expand Down
4 changes: 4 additions & 0 deletions pkg/kubelet/kubelet.go
Original file line number Diff line number Diff line change
Expand Up @@ -2386,6 +2386,10 @@ func (kl *Kubelet) syncLoopIteration(updates <-chan kubetypes.PodUpdate, handler
switch u.Op {
case kubetypes.ADD:
glog.V(2).Infof("SyncLoop (ADD, %q): %q", u.Source, format.Pods(u.Pods))
// After restarting, kubelet will get all existing pods through
// ADD as if they are new pods. These pods will then go through the
// admission process and *may* be rejcted. This can be resolved
// once we have checkpointing.
handler.HandlePodAdditions(u.Pods)
case kubetypes.UPDATE:
glog.V(2).Infof("SyncLoop (UPDATE, %q): %q", u.Source, format.Pods(u.Pods))
Expand Down

1 comment on commit deafa44

@k8s-teamcity-mesosphere

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TeamCity OSS :: Kubernetes Mesos :: 4 - Smoke Tests Build 19399 outcome was SUCCESS
Summary: Tests passed: 1, ignored: 265 Build time: 00:05:22

Please sign in to comment.