Skip to content

Commit

Permalink
restric inital pods to the configured namespaces in metadata service
Browse files Browse the repository at this point in the history
Signed-off-by: Ata Fatahi <afatahibaarzi@linkedin.com>
  • Loading branch information
MrAta committed Jun 29, 2023
1 parent 348fa7f commit 3540315
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 0 additions & 1 deletion src/vizier/services/metadata/metadata_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down

0 comments on commit 3540315

Please sign in to comment.