From 71dc25eebdf60b532efdfccf1595db041c7310e1 Mon Sep 17 00:00:00 2001 From: Richard Marshall Date: Sun, 11 Mar 2018 16:19:12 +0000 Subject: [PATCH] subnet/kube: Handle missed node deletions If the node controller misses the deletion of a node the DeltaFIFO will insert a tombstone object with the last known view of the object. This commit adds checking to the type assertion and extraction of the previous node object when possible. Signed-off-by: Richard Marshall --- subnet/kube/kube.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/subnet/kube/kube.go b/subnet/kube/kube.go index 38375d8d03..5c08a83bf7 100644 --- a/subnet/kube/kube.go +++ b/subnet/kube/kube.go @@ -174,7 +174,19 @@ func newKubeSubnetManager(c clientset.Interface, sc *subnet.Config, nodeName str } func (ksm *kubeSubnetManager) handleAddLeaseEvent(et subnet.EventType, obj interface{}) { - n := obj.(*v1.Node) + n, ok := obj.(*v1.Node) + if !ok { + d, ok := obj.(cache.DeletedFinalStateUnknown) + if !ok { + glog.Errorf("Unexpected object type: %#v", obj) + return + } + n, ok = d.Obj.(*v1.Node) + if !ok { + glog.Errorf("Unexpected object type: %#v", obj) + return + } + } if s, ok := n.Annotations[subnetKubeManagedAnnotation]; !ok || s != "true" { return }