Skip to content

Commit

Permalink
BUG: wait for k8s events from default local service
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanmatmati committed Jul 21, 2023
1 parent 55ffe63 commit b0331ef
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions pkg/controller/global.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package controller

import (
"fmt"
"time"

"github.com/go-test/deep"

Expand Down Expand Up @@ -204,8 +205,14 @@ func populateDefaultLocalBackendResources(k8sStore store.K8s, eventChan chan k8s
},
},
}
eventChan <- k8s.SyncDataEvent{SyncType: k8s.SERVICE, Namespace: item.Namespace, Data: item}

eventProcessed := make(chan struct{})
eventChan <- k8s.SyncDataEvent{SyncType: k8s.SERVICE, Namespace: item.Namespace, Data: item, EventProcessed: eventProcessed}
timerService := time.NewTimer(time.Second)
defer timerService.Stop()
select {
case <-timerService.C:
case <-eventProcessed:
}
endpoints := &store.Endpoints{
Namespace: podNs,
Service: store.DefaultLocalBackend,
Expand All @@ -218,7 +225,14 @@ func populateDefaultLocalBackendResources(k8sStore store.K8s, eventChan chan k8s
},
},
}
eventChan <- k8s.SyncDataEvent{SyncType: k8s.ENDPOINTS, Namespace: endpoints.Namespace, Data: endpoints}
eventProcessed = make(chan struct{})
eventChan <- k8s.SyncDataEvent{SyncType: k8s.ENDPOINTS, Namespace: endpoints.Namespace, Data: endpoints, EventProcessed: eventProcessed}
timerEndpoints := time.NewTimer(time.Second)
defer timerEndpoints.Stop()
select {
case <-timerEndpoints.C:
case <-eventProcessed:
}
} else {
defaultLocalService.Annotations = k8sStore.ConfigMaps.Main.Annotations
}
Expand Down

0 comments on commit b0331ef

Please sign in to comment.