From 9d0415f7e29b5266c28af676a1aedd3e8da4b877 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Martins?= Date: Mon, 21 Nov 2022 21:12:19 +0100 Subject: [PATCH] pkg/k8s: fallback on retrieving CiliumNode from kube-apiserver MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Retrieving objects from caches can be useful to prevent doing useless requests to kube-apiserver. In the unlikely event that the object doesn't exist in the local cache Cilium can try to retrieve it from kube-apiserver directly. For this particular case, with CiliumNode, it is causing Cilium to fatal as it is unable to retrieve CiliumNode from the cache, due subsystem initialization issues, thus we will fallback on retrieving the object directly from kube-apiserver. In this case, the subsystem initialization issue happened due to the fact that CiliumNode watcher is blocked on its event handler by the egressGatewayManager [1] which is blocked by the initialization of the identity allocator [2]. Unfortunately, the identity allocator is only initialized at a later stage causing the CiliumNode cache from being populated with all of its nodes. [1] https://github.com/cilium/cilium/blob/933bdcbec9319b0148b12688f720fbaaf55e0dba/pkg/k8s/watchers/cilium_node.go#L56 [2] https://github.com/cilium/cilium/blob/933bdcbec9319b0148b12688f720fbaaf55e0dba/pkg/egressgateway/manager.go#L83 Fixes: 69e4c6974891 ("k8s: optimize API calls made to kube-apiserver") Signed-off-by: André Martins --- pkg/k8s/watchers/cilium_node.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/k8s/watchers/cilium_node.go b/pkg/k8s/watchers/cilium_node.go index 049d1aadbb398..6e6299f734f3a 100644 --- a/pkg/k8s/watchers/cilium_node.go +++ b/pkg/k8s/watchers/cilium_node.go @@ -168,7 +168,7 @@ func (k *K8sWatcher) GetCiliumNode(ctx context.Context, nodeName string) (*ciliu } k.ciliumNodeStoreMU.RUnlock() - if getFromAPIServer { + if !exists || getFromAPIServer { // fallback to using the kube-apiserver return k.clientset.CiliumV2().CiliumNodes().Get(ctx, nodeName, v1.GetOptions{}) }