Skip to content

Commit

Permalink
Merge pull request kubernetes#18017 from mesosphere/sur-k8sm-656-panic
Browse files Browse the repository at this point in the history
Auto commit by PR queue bot
  • Loading branch information
k8s-merge-robot committed Dec 2, 2015
2 parents 689586c + 91cbd5f commit cd76ca9
Showing 1 changed file with 11 additions and 17 deletions.
28 changes: 11 additions & 17 deletions contrib/mesos/pkg/node/statusupdater.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
client "k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/cloudprovider/providers/mesos"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/util/sets"
)

const (
Expand Down Expand Up @@ -61,43 +62,36 @@ func (u *StatusUpdater) Run(terminate <-chan struct{}) error {
cache.NewReflector(nodeLW, &api.Node{}, nodeStore, u.relistPeriod).Run()

monitor := func() {
// build up a slave set of nodes without kubelet
slavesWithoutKubeletList, err := mesos.CloudProvider.ListWithoutKubelet()
// build up a set of listed slave nodes without a kubelet
slaves, err := mesos.CloudProvider.ListWithoutKubelet()
if err != nil {
log.Errorf("Error while updating slave nodes: %v", err)
log.Errorf("Error listing slaves without kubelet: %v", err)
return
}
slavesWithoutKubelet := make(map[string]struct{}, len(slavesWithoutKubeletList))
for _, s := range slavesWithoutKubeletList {
slavesWithoutKubelet[s] = struct{}{}
}
slavesWithoutKubelet := sets.NewString(slaves...)

// update status for nodes which do not have a kubelet running and
// which are still existing as slave. This status update must be done
// before the node controller counts down the NodeMonitorGracePeriod
obj, err := nodeLW.List()
if err != nil {
log.Errorf("Error listing the nodes for status updates: %v", err)
}
nl, _ := obj.(*api.NodeList)
nodes := nl.Items
nodes := nodeStore.List()

for i := range nodes {
if _, ok := slavesWithoutKubelet[nodes[i].Spec.ExternalID]; !ok {
for _, n := range nodes {
node := n.(*api.Node)
if !slavesWithoutKubelet.Has(node.Spec.ExternalID) {
// let the kubelet do its job updating the status, or the
// node controller will remove this node if the node does not even
// exist anymore
continue
}

err := u.updateStatus(&nodes[i])
err := u.updateStatus(node)
if err != nil {
log.Errorf("Error updating node status: %v", err)
}
}
}
go runtime.Until(monitor, u.heartBeatPeriod, terminate)

go runtime.Until(monitor, u.heartBeatPeriod, terminate)
return nil
}

Expand Down

0 comments on commit cd76ca9

Please sign in to comment.