Commit 212f6af9 authored by Kevin Di Lallo's avatar Kevin Di Lallo
Browse files

review follow-up

parent 91a7152e
Loading
Loading
Loading
Loading
+10 −10
Original line number Diff line number Diff line
@@ -61,8 +61,8 @@ func NewIpManager(name string, sandboxName string, updateCb IpAddrUpdateCb) (im
	return im, nil
}

// SetPodList - Set list of pods to monitor IP addresses for
func (im *IpManager) SetPodList(podList map[string]bool) {
// RefreshPodList - Set list of pods to monitor IP addresses for
func (im *IpManager) RefreshPodList(podList map[string]bool) {
	im.mutex.Lock()
	defer im.mutex.Unlock()

@@ -70,6 +70,8 @@ func (im *IpManager) SetPodList(podList map[string]bool) {
	for podName := range im.podIpMap {
		if _, found := podList[podName]; !found {
			delete(im.podIpMap, podName)
		} else {
			delete(podList, podName)
		}
	}

@@ -81,8 +83,8 @@ func (im *IpManager) SetPodList(podList map[string]bool) {
	}
}

// SetSvcList - Set list of services to monitor IP addresses for
func (im *IpManager) SetSvcList(svcList map[string]bool) {
// RefreshSvcList - Set list of services to monitor IP addresses for
func (im *IpManager) RefreshSvcList(svcList map[string]bool) {
	im.mutex.Lock()
	defer im.mutex.Unlock()

@@ -90,6 +92,8 @@ func (im *IpManager) SetSvcList(svcList map[string]bool) {
	for svcName := range im.svcIpMap {
		if _, found := svcList[svcName]; !found {
			delete(im.svcIpMap, svcName)
		} else {
			delete(svcList, svcName)
		}
	}

@@ -135,12 +139,8 @@ func (im *IpManager) Start() error {
	im.ticker = time.NewTicker(DEFAULT_TICKER_INTERVAL_MS * time.Millisecond)
	go func() {
		for range im.ticker.C {
			im.mutex.Lock()

			// Refresh IP addresses
			im.refreshIpAddresses()

			im.mutex.Unlock()
			im.Refresh()
		}
	}()

@@ -182,7 +182,7 @@ func (im *IpManager) refreshIpAddresses() {
	}

	// Retrieve all sandbox pods from k8s api
	podList, err := im.clientset.CoreV1().Pods(im.sandboxName).List(metav1.ListOptions{})
	podList, err := im.clientset.CoreV1().Pods(im.sandboxName).List(metav1.ListOptions{LabelSelector: "meepOrigin=scenario"})
	if err != nil {
		log.Error("Failed to retrieve pods from k8s API Server. Error: ", err)
		im.isConnected = false
+4 −4
Original line number Diff line number Diff line
@@ -376,8 +376,8 @@ func stopScenario() {
	mgSvcInfoMap = make(map[string]*MgServiceInfo)
	podInfoMap = make(map[string]*PodInfo)

	tce.ipManager.SetPodList(map[string]bool{})
	tce.ipManager.SetSvcList(map[string]bool{})
	tce.ipManager.RefreshPodList(map[string]bool{})
	tce.ipManager.RefreshSvcList(map[string]bool{})

	tce.netCharStore.rc.DBFlush(tce.netCharStore.baseKey)

@@ -506,8 +506,8 @@ func processScenario(model *mod.Model) error {
	}

	// Update Pod & Svc lists in IP Manager
	tce.ipManager.SetPodList(podNames)
	tce.ipManager.SetSvcList(svcNames)
	tce.ipManager.RefreshPodList(podNames)
	tce.ipManager.RefreshSvcList(svcNames)

	// Remove network elements that are no longer in scenario
	for procName := range netElemMap {
+1 −3
Original line number Diff line number Diff line
@@ -264,9 +264,7 @@ func initMeepSidecar() (err error) {
		log.Error("Failed to create Pinger. Error: ", err)
		return err
	}
	if pinger.PayloadSize() != uint16(opts.payloadSize) {
	pinger.SetPayloadSize(uint16(opts.payloadSize))
	}

	// Initialize filters
	err = initializeFilters()