controller: Clean up the Longhorn node when the kube node is gone
Longhorn
@@ -198,12 +198,18 @@ func (knc *KubernetesNodeController) syncKubernetesNode(key string) (err error)
kubeNode, err := knc.ds.GetKubernetesNode(name)
if err != nil {
- if datastore.ErrorIsNotFound(err) {
+ if !datastore.ErrorIsNotFound(err) {
+ return err
+ }
logrus.Errorf("Kubernetes node %v has been deleted", key)
- return nil
}
+
+ if kubeNode == nil {
+ if err := knc.ds.DeleteNode(name); err != nil {
return err
}
+ return nil
+ }
defer func() {
// requeue if it's conflict
