Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permit agent to run even when VPP stats are unavailable #1712

Merged
merged 4 commits into from
Aug 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions plugins/govppmux/plugin_impl_govppmux.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,10 @@ func (p *Plugin) Init() (err error) {
}
err := p.startProxy(NewVppAdapter(address, useShm), NewStatsAdapter(statsSocket))
if err != nil {
return err
p.Log.Warnf("VPP proxy failed to start: %v", err)
} else {
p.Log.Infof("VPP proxy ready")
}
p.Log.Infof("VPP proxy ready")
}

// register REST API handlers
Expand Down
3 changes: 3 additions & 0 deletions plugins/telemetry/stats_poller.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ func (s *statsPollerServer) PollStats(req *configurator.PollStatsRequest, svr co
if req.GetPeriodSec() == 0 && req.GetNumPolls() > 1 {
return status.Error(codes.InvalidArgument, "period must be > 0 if number of polls is > 1")
}
if s.handler == nil {
return status.Errorf(codes.Unavailable, "VPP telemetry handler not available")
}

ctx := svr.Context()

Expand Down
7 changes: 4 additions & 3 deletions plugins/telemetry/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,11 @@ func (p *Plugin) AfterInit() error {
func (p *Plugin) setupStatsPoller() error {
h := vppcalls.CompatibleTelemetryHandler(p.VPP)
if h == nil {
return fmt.Errorf("VPP telemetry handler unavailable")
p.Log.Warnf("VPP telemetry handler unavailable")
} else {
p.statsPollerServer.handler = h
}
p.statsPollerServer.handler = h
p.ifIndex = p.IfPlugin.GetInterfaceIndex()
p.statsPollerServer.ifIndex = p.IfPlugin.GetInterfaceIndex()

if p.GRPC != nil && p.GRPC.GetServer() != nil {
configurator.RegisterStatsPollerServiceServer(p.GRPC.GetServer(), &p.statsPollerServer)
Expand Down
12 changes: 9 additions & 3 deletions plugins/vpp/ifplugin/interface_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,13 @@ func (c *InterfaceStateUpdater) startReadingCounters(ctx context.Context) {
for {
select {
case <-tick.C:
c.doInterfaceStatsRead()
statsClient := c.vppClient.Stats()
if statsClient == nil {
c.log.Warnf("VPP stats client not available")
// TODO: use retry with backoff instead of returning here
return
}
c.doInterfaceStatsRead(statsClient)

case <-ctx.Done():
c.log.Debug("Interface state VPP periodic polling stopped")
Expand Down Expand Up @@ -276,7 +282,7 @@ func (c *InterfaceStateUpdater) doUpdatesIfStateDetails() {
}

// doInterfaceStatsRead dumps statistics using interface filter and processes them
func (c *InterfaceStateUpdater) doInterfaceStatsRead() {
func (c *InterfaceStateUpdater) doInterfaceStatsRead(statsClient govppapi.StatsProvider) {
c.access.Lock()
defer c.access.Unlock()

Expand All @@ -286,7 +292,7 @@ func (c *InterfaceStateUpdater) doInterfaceStatsRead() {
return
}

err := c.vppClient.Stats().GetInterfaceStats(&c.ifStats)
err := statsClient.GetInterfaceStats(&c.ifStats)
if err != nil {
// TODO add some counter to prevent it log forever
c.log.Errorf("failed to read statistics data: %v", err)
Expand Down