From b4627b74c151acbd699a54154325383febdbc549 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Martins?= Date: Mon, 8 Jun 2020 11:38:15 +0200 Subject: [PATCH] pkg/k8s: wait for EndpointSlice to be ready before initializing Cilium MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Similar to the v1.Endpoints, in case Cilium is running with EndpointSlice enabled, it should wait for the k8s watchers watching those resources before it starts. Fixes: c3b5ca6fdc40 ("add support for k8s endpoint slice") Signed-off-by: André Martins --- daemon/cmd/daemon_main.go | 6 +++++- pkg/k8s/watchers/watcher.go | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/daemon/cmd/daemon_main.go b/daemon/cmd/daemon_main.go index 3dca4bed891d..9b7a122a6d73 100644 --- a/daemon/cmd/daemon_main.go +++ b/daemon/cmd/daemon_main.go @@ -1223,7 +1223,11 @@ func (d *Daemon) initKVStore() { // up etcd so we can perform the name resolution for etcd-operator // to the service IP as well perform the service -> backend IPs for // that service IP. - d.k8sWatcher.WaitForCacheSync(watchers.K8sAPIGroupServiceV1Core, watchers.K8sAPIGroupEndpointV1Core) + d.k8sWatcher.WaitForCacheSync( + watchers.K8sAPIGroupServiceV1Core, + watchers.K8sAPIGroupEndpointV1Core, + watchers.K8sAPIGroupEndpointSliceV1Beta1Discovery, + ) log := log.WithField(logfields.LogSubsys, "etcd") goopts.DialOption = []grpc.DialOption{ grpc.WithDialer(k8s.CreateCustomDialer(&d.k8sWatcher.K8sSvcCache, log)), diff --git a/pkg/k8s/watchers/watcher.go b/pkg/k8s/watchers/watcher.go index 7ec1c65b41b7..d74ea4989271 100644 --- a/pkg/k8s/watchers/watcher.go +++ b/pkg/k8s/watchers/watcher.go @@ -370,6 +370,7 @@ func (k *K8sWatcher) InitK8sSubsystem() <-chan struct{} { // To perform the service translation and have the BPF LB datapath // with the right service -> backend (k8s endpoints) translation. K8sAPIGroupEndpointV1Core, + K8sAPIGroupEndpointSliceV1Beta1Discovery, // We need all network policies in place before restoring to make sure // we are enforcing the correct policies for each endpoint before // restarting.