mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 05:57:25 +00:00
Merge pull request #18017 from mesosphere/sur-k8sm-656-panic
Auto commit by PR queue bot
This commit is contained in:
commit
cd76ca9527
@ -30,6 +30,7 @@ import (
|
|||||||
client "k8s.io/kubernetes/pkg/client/unversioned"
|
client "k8s.io/kubernetes/pkg/client/unversioned"
|
||||||
"k8s.io/kubernetes/pkg/cloudprovider/providers/mesos"
|
"k8s.io/kubernetes/pkg/cloudprovider/providers/mesos"
|
||||||
"k8s.io/kubernetes/pkg/fields"
|
"k8s.io/kubernetes/pkg/fields"
|
||||||
|
"k8s.io/kubernetes/pkg/util/sets"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -61,43 +62,36 @@ func (u *StatusUpdater) Run(terminate <-chan struct{}) error {
|
|||||||
cache.NewReflector(nodeLW, &api.Node{}, nodeStore, u.relistPeriod).Run()
|
cache.NewReflector(nodeLW, &api.Node{}, nodeStore, u.relistPeriod).Run()
|
||||||
|
|
||||||
monitor := func() {
|
monitor := func() {
|
||||||
// build up a slave set of nodes without kubelet
|
// build up a set of listed slave nodes without a kubelet
|
||||||
slavesWithoutKubeletList, err := mesos.CloudProvider.ListWithoutKubelet()
|
slaves, err := mesos.CloudProvider.ListWithoutKubelet()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("Error while updating slave nodes: %v", err)
|
log.Errorf("Error listing slaves without kubelet: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
slavesWithoutKubelet := make(map[string]struct{}, len(slavesWithoutKubeletList))
|
slavesWithoutKubelet := sets.NewString(slaves...)
|
||||||
for _, s := range slavesWithoutKubeletList {
|
|
||||||
slavesWithoutKubelet[s] = struct{}{}
|
|
||||||
}
|
|
||||||
|
|
||||||
// update status for nodes which do not have a kubelet running and
|
// update status for nodes which do not have a kubelet running and
|
||||||
// which are still existing as slave. This status update must be done
|
// which are still existing as slave. This status update must be done
|
||||||
// before the node controller counts down the NodeMonitorGracePeriod
|
// before the node controller counts down the NodeMonitorGracePeriod
|
||||||
obj, err := nodeLW.List()
|
nodes := nodeStore.List()
|
||||||
if err != nil {
|
|
||||||
log.Errorf("Error listing the nodes for status updates: %v", err)
|
|
||||||
}
|
|
||||||
nl, _ := obj.(*api.NodeList)
|
|
||||||
nodes := nl.Items
|
|
||||||
|
|
||||||
for i := range nodes {
|
for _, n := range nodes {
|
||||||
if _, ok := slavesWithoutKubelet[nodes[i].Spec.ExternalID]; !ok {
|
node := n.(*api.Node)
|
||||||
|
if !slavesWithoutKubelet.Has(node.Spec.ExternalID) {
|
||||||
// let the kubelet do its job updating the status, or the
|
// let the kubelet do its job updating the status, or the
|
||||||
// node controller will remove this node if the node does not even
|
// node controller will remove this node if the node does not even
|
||||||
// exist anymore
|
// exist anymore
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
err := u.updateStatus(&nodes[i])
|
err := u.updateStatus(node)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("Error updating node status: %v", err)
|
log.Errorf("Error updating node status: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
go runtime.Until(monitor, u.heartBeatPeriod, terminate)
|
|
||||||
|
|
||||||
|
go runtime.Until(monitor, u.heartBeatPeriod, terminate)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user