diff --git a/src/vizier/services/metadata/controllers/k8smeta/k8s_metadata_utils.go b/src/vizier/services/metadata/controllers/k8smeta/k8s_metadata_utils.go index e29512e2bde..6153b67529d 100644 --- a/src/vizier/services/metadata/controllers/k8smeta/k8s_metadata_utils.go +++ b/src/vizier/services/metadata/controllers/k8smeta/k8s_metadata_utils.go @@ -90,15 +90,19 @@ func podWatcher(resource string, namespaces []string, ch chan *K8sResourceMessag iw.informers = append(iw.informers, inf) } + var podList []v1.Pod // We initialize ch with the current Pods to handle cold start race conditions. - list, err := clientset.CoreV1().Pods(v1.NamespaceAll).List(context.Background(), metav1.ListOptions{}) - if err != nil { - log.WithError(err).Errorf("Failed to init %s", resource) - // Still return the informer because the rest of the system can recover from this. - return iw + for _, ns := range namespaces { + list, err := clientset.CoreV1().Pods(ns).List(context.Background(), metav1.ListOptions{}) + if err != nil { + log.WithError(err).Errorf("Failed to init %s in %s namespace.", resource, ns) + // Still return the informer because the rest of the system can recover from this. + return iw + } + podList = append(podList, list.Items...) } - for _, obj := range list.Items { + for _, obj := range podList { item := obj msg := iw.convert(&item) if msg != nil { diff --git a/src/vizier/services/metadata/metadata_server.go b/src/vizier/services/metadata/metadata_server.go index 812d74c9fea..d2d77659833 100644 --- a/src/vizier/services/metadata/metadata_server.go +++ b/src/vizier/services/metadata/metadata_server.go @@ -82,7 +82,6 @@ func init() { // So instead just map PL_ETCD_OPERATOR_ENABLED to use_etcd_operator to make it work. // TODO: We should clean this up in the future and make these flags consistent. viper.BindEnv("use_etcd_operator", "PL_ETCD_OPERATOR_ENABLED") - viper.BindEnv("metadata_namespaces") } func mustInitEtcdDatastore() (*etcd.DataStore, func()) {