diff --git a/cache/cache.go b/cache/cache.go index c89d0156..91b82437 100644 --- a/cache/cache.go +++ b/cache/cache.go @@ -15,6 +15,7 @@ import ( type NodeInfoCache interface { Update(state.NodeInfo) + Delete(string) JSON() ([]byte, error) } @@ -37,6 +38,12 @@ func (nic *nodeInfoCacheImpl) Update(info state.NodeInfo) { nic.nodes[info.Node] = info } +func (nic *nodeInfoCacheImpl) Delete(node string) { + nic.mutex.Lock() + defer nic.mutex.Unlock() + delete(nic.nodes, node) +} + func (nic *nodeInfoCacheImpl) JSON() ([]byte, error) { // do not hand out data of the nodes map as it contains // pointers, which in turn open up for data races diff --git a/controllers/node_controller.go b/controllers/node_controller.go index ff6da7be..fd1f37c3 100644 --- a/controllers/node_controller.go +++ b/controllers/node_controller.go @@ -74,6 +74,7 @@ func (r *NodeReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl. var theNode corev1.Node err = r.Get(ctx, req.NamespacedName, &theNode) if errors.IsNotFound(err) { + r.NodeInfoCache.Delete(req.Name) r.Log.Info("Could not find node on the API server, maybe it has been deleted?", "node", req.NamespacedName) return ctrl.Result{}, nil } else if err != nil { diff --git a/static/index.html b/static/index.html index c1ec6668..d128ca9f 100644 --- a/static/index.html +++ b/static/index.html @@ -187,13 +187,13 @@