Allow update node resources if kubernetes node is already gone
Previously, if the kubernetes node is gone, the node validating webhook did
not allow the modification of the node resource. It hindered the remove of the
finalizers and resulted in the deletion failure of the node resource.
Longhorn 4213
@@ -85,8 +85,13 @@ func (n *nodeValidator) Update(request *admission.Request, oldObj runtime.Object
if newNode.Spec.EngineManagerCPURequest != 0 || newNode.Spec.ReplicaManagerCPURequest != 0 {
kubeNode, err := n.ds.GetKubernetesNode(oldNode.Name)
if err != nil {
+ if !datastore.ErrorIsNotFound(err) {
return werror.NewInvalidError(err.Error(), "")
}
+ logrus.Warnf("Kubernetes node %v has been deleted", oldNode.Name)
+ }
+
+ if err == nil {
allocatableCPU := float64(kubeNode.Status.Allocatable.Cpu().MilliValue())
engineManagerCPUSetting, err := n.ds.GetSetting(types.SettingNameGuaranteedEngineManagerCPU)
if err != nil {
@@ -108,6 +113,7 @@ func (n *nodeValidator) Update(request *admission.Request, oldObj runtime.Object
return werror.NewInvalidError(err.Error(), "")
}
}
+ }
// Only scheduling disabled disk can be evicted
// Can not enable scheduling on an evicting disk
