func (p *IfPlugin) resyncIfStateEvents(keys []string) error {
	p.publishLock.Lock()
	defer p.publishLock.Unlock()
	p.Log.Debugf("resync interface state events with %d keys", len(keys))
	for _, key := range keys {
		ifaceName := strings.TrimPrefix(key, interfaces.StatePrefix)
		if ifaceName == key {
			continue
		}
		_, found := p.intfIndex.LookupByName(ifaceName)
		if !found {
			err := p.PublishStatistics.Put(key, nil  )
			if err != nil {
				return errors.WithMessagef(err, "publish statistic for key %s failed", key)
			}
			p.Log.Debugf("Obsolete interface status for %v deleted", key)
		} else {
			p.Log.WithField("ifaceName", ifaceName).Debug("interface status is needed")
		}
	}
	return nil
}
resyncIfStateEvents deletes obsolete operation status of network interfaces in DB.
package ifplugin
import (
	"strings"
	"github.com/pkg/errors"
	"go.ligato.io/cn-infra/v2/datasync"
	"go.ligato.io/cn-infra/v2/health/statuscheck"
	"go.ligato.io/cn-infra/v2/health/statuscheck/model/status"
	"go.ligato.io/vpp-agent/v3/proto/ligato/vpp"
	interfaces "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/interfaces"
)
func (p *IfPlugin) watchStatusEvents() {
	defer p.wg.Done()
	p.Log.Debug("Start watching interface state events")
	for {
		select {
		case e := <-p.resyncStatusChan:
			p.onStatusResyncEvent(e)
		case <-p.ctx.Done():
			p.Log.Debug("Stop watching interface state events")
			return
		}
	}
}
func (p *IfPlugin) onStatusResyncEvent(e datasync.ResyncEvent) {
	p.Log.Debugf("received status resync event (%d prefixes)", len(e.GetValues()))
	var wasError error
	for prefix, vals := range e.GetValues() {
		var keys []string
		for {
			x, stop := vals.GetNext()
			if stop {
				break
			}
			keys = append(keys, x.GetKey())
		}
		if len(keys) > 0 {
			p.Log.Debugf("- %q (%v items)", prefix, len(keys))
			err := p.resyncIfStateEvents(keys)
			if err != nil {
				wasError = err
			}
		} else {
			p.Log.Debugf("- %q (no items)", prefix)
		}
	}
	e.Done(wasError)
}