cilium/cilium · error

bgp router manager is not running

Error message

bgp router manager is not running

What it means

GetPeers returns the BGP peering state of all configured BGP instances. The BGPRouterManager holds a running flag that is set true only after the manager (and its GoBGP servers) has been started; before Start() completes or after Stop()/shutdown, all query methods fail fast with this error. It signals the agent's BGP subsystem is not currently serving requests.

Source

Thrown at pkg/bgp/manager/manager.go:226

	retryFn := func(ctx context.Context) (bool, error) {
		err := m.reconcileState(ctx)
		if err != nil {
			m.logger.Error("failed to reconcile state", logfields.Error, err)
			return false, nil
		}
		return true, nil
	}

	return wait.ExponentialBackoffWithContext(ctx, bo, retryFn)
}

func (m *BGPRouterManager) GetPeers(ctx context.Context, req *agent.GetPeersRequest) (*agent.GetPeersResponse, error) {
	m.RLock()
	defer m.RUnlock()

	if !m.running {
		return nil, fmt.Errorf("bgp router manager is not running")
	}

	var res agent.GetPeersResponse
	for _, i := range m.BGPInstances {
		r, err := i.Router.GetPeerState(ctx, &types.GetPeerStateRequest{})
		if err != nil {
			return nil, err
		}
		res.Instances = append(res.Instances, agent.InstancePeerStates{
			Name:  i.Name,
			Peers: r.Peers,
		})
	}

	return &res, nil
}

// GetPeersLegacy gets peering state from previously initialized bgp instances.

View on GitHub (pinned to ac7b90affa)

Solutions

  1. Wait until the BGP agent/manager has fully started (check agent health/startup status) before calling GetPeers.
  2. Verify the BGP feature is enabled and the BGPRouterManager.Start() path executed without error; check agent logs for BGP startup failures.
  3. If the manager was stopped intentionally, restart the agent or re-run the start sequence before querying peers.
  4. Handle the error in the caller with retry/backoff so transient startup windows do not fail monitoring.

Example fix

// before
resp, err := mgr.GetPeers(ctx, req)
// after
if !mgrStarted {
    return nil, errors.New("bgp manager not started yet")
}
resp, err := mgr.GetPeers(ctx, req)
Defensive patterns

Strategy: retry

Validate before calling

if mgr == nil || !bgpManagerReady() {
    return errors.New("bgp router manager not ready; defer GetPeers until after agent startup")
}

Try / catch

resp, err := mgr.GetPeers(ctx, req)
if err != nil && strings.Contains(err.Error(), "not running") {
    // retry with backoff until the BGP manager has started
}

Prevention

When it happens

Trigger: Calling GetPeers(ctx, *agent.GetPeersRequest) while m.running is false: before the BGP agent has been started, while it is still initializing, or after the manager was stopped/shut down (e.g. agent teardown, config reload that stops the manager).

Common situations: A monitoring script or API client polls the BGP peers endpoint before the routing agent finishes startup; the agent is restarting after a config change; the BGP feature is disabled so the manager was never started; tests hitting the API before fixtures bring the manager up.

Related errors


AI-assisted analysis of cilium/cilium@ac7b90affa (2026-08-31). Data as JSON: /api/errors/69c27e225d41c254. Report an issue: GitHub.