{"record":{"id":"69c27e225d41c254","repo":"cilium/cilium","slug":"bgp-router-manager-is-not-running","errorCode":null,"errorMessage":"bgp router manager is not running","messagePattern":"bgp router manager is not running","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/bgp/manager/manager.go","lineNumber":226,"sourceCode":"\n\tretryFn := func(ctx context.Context) (bool, error) {\n\t\terr := m.reconcileState(ctx)\n\t\tif err != nil {\n\t\t\tm.logger.Error(\"failed to reconcile state\", logfields.Error, err)\n\t\t\treturn false, nil\n\t\t}\n\t\treturn true, nil\n\t}\n\n\treturn wait.ExponentialBackoffWithContext(ctx, bo, retryFn)\n}\n\nfunc (m *BGPRouterManager) GetPeers(ctx context.Context, req *agent.GetPeersRequest) (*agent.GetPeersResponse, error) {\n\tm.RLock()\n\tdefer m.RUnlock()\n\n\tif !m.running {\n\t\treturn nil, fmt.Errorf(\"bgp router manager is not running\")\n\t}\n\n\tvar res agent.GetPeersResponse\n\tfor _, i := range m.BGPInstances {\n\t\tr, err := i.Router.GetPeerState(ctx, &types.GetPeerStateRequest{})\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tres.Instances = append(res.Instances, agent.InstancePeerStates{\n\t\t\tName:  i.Name,\n\t\t\tPeers: r.Peers,\n\t\t})\n\t}\n\n\treturn &res, nil\n}\n\n// GetPeersLegacy gets peering state from previously initialized bgp instances.","sourceCodeStart":208,"sourceCodeEnd":244,"githubUrl":"https://github.com/cilium/cilium/blob/ac7b90affa4baf0642e6685319d56907b3a73a6d/pkg/bgp/manager/manager.go#L208-L244","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Wait until the BGP agent/manager has fully started (check agent health/startup status) before calling GetPeers.","Verify the BGP feature is enabled and the BGPRouterManager.Start() path executed without error; check agent logs for BGP startup failures.","If the manager was stopped intentionally, restart the agent or re-run the start sequence before querying peers.","Handle the error in the caller with retry/backoff so transient startup windows do not fail monitoring."],"exampleFix":"// before\nresp, err := mgr.GetPeers(ctx, req)\n// after\nif !mgrStarted {\n    return nil, errors.New(\"bgp manager not started yet\")\n}\nresp, err := mgr.GetPeers(ctx, req)","handlingStrategy":"retry","validationCode":"if mgr == nil || !bgpManagerReady() {\n    return errors.New(\"bgp router manager not ready; defer GetPeers until after agent startup\")\n}","typeGuard":null,"tryCatchPattern":"resp, err := mgr.GetPeers(ctx, req)\nif err != nil && strings.Contains(err.Error(), \"not running\") {\n    // retry with backoff until the BGP manager has started\n}","preventionTips":["Gate BGP queries on agent startup-complete signals or health endpoints.","Wrap polling loops in retry/backoff to tolerate the startup window.","Check agent logs at boot to confirm the BGP manager start path succeeded.","Avoid calling BGP APIs during shutdown/config-reload windows."],"tags":["bgp","not-running","lifecycle","golang"],"backgroundTag":"service-not-running","analyzedSha":"ac7b90affa4baf0642e6685319d56907b3a73a6d","analyzedAt":"2026-08-31T18:27:15.868Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}