{"record":{"id":"8300fb5ded2e19eb","repo":"cilium/cilium","slug":"waiting-for-endpoint-restorer-w","errorCode":null,"errorMessage":"waiting for endpoint restorer: %w","messagePattern":"waiting for endpoint restorer: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/datapath/loader/endpoint.go","lineNumber":290,"sourceCode":"\n\treturn nil\n}\n\nfunc registerRouteInitializer(p Params) {\n\t// [upsertEndpointRoute] Creates routes for endpoints that need per endpoint routes.\n\t// We need to tell the route reconciler to delay pruning of routes from the kernel until we have had a chance\n\t// to insert desired routes for all endpoints that need them.\n\t//\n\t// Use the endpoint restorer to get a signal when all existing endpoints have been restored, and thus\n\t// [loader.ReloadDatapath] has been called for all existing endpoints. After that we can finalize the route\n\t// initializer.\n\trouteInitializer := p.RouteManager.RegisterInitializer(\"per-endpoint-routes\")\n\tp.JobGroup.Add(job.OneShot(\"per-endpoint-route-initializer\", func(ctx context.Context, _ cell.Health) error {\n\t\tdefer p.RouteManager.FinalizeInitializer(routeInitializer)\n\n\t\tepRestorer, err := p.EPRestorer.Await(ctx)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"waiting for endpoint restorer: %w\", err)\n\t\t}\n\n\t\tif err := epRestorer.WaitForEndpointRestore(ctx); err != nil {\n\t\t\treturn fmt.Errorf(\"waiting for endpoint restore: %w\", err)\n\t\t}\n\n\t\treturn nil\n\t}))\n}\n\nfunc upsertEndpointRoute(db *statedb.DB, devices statedb.Table[*tables.Device], rm *routeReconciler.DesiredRouteManager, ep endpoint.Endpoint, ip netip.Prefix) error {\n\towner, err := rm.GetOrRegisterOwner(\"endpoint/\" + ep.StringID())\n\tif err != nil {\n\t\treturn fmt.Errorf(\"getting or registering owner for endpoint %s: %w\", ep.StringID(), err)\n\t}\n\n\t// This timeout is 50 times the current batch interval of the devices controller, and thus should\n\t// be sufficient.","sourceCodeStart":272,"sourceCodeEnd":308,"githubUrl":"https://github.com/cilium/cilium/blob/ac7b90affa4baf0642e6685319d56907b3a73a6d/pkg/datapath/loader/endpoint.go#L272-L308","documentation":"The per-endpoint-route-initializer job failed while waiting for the endpoint restorer to become available via p.EPRestorer.Await(ctx). The restorer dependency never resolved, most commonly because the context was cancelled during agent shutdown or the restorer's own startup failed / is not wired into the hive.","triggerScenarios":"EPRestorer.Await(ctx) returns an error: ctx cancelled (agent shutting down during startup), the EndpointRestorer cell is missing/disabled in the module graph, or the restorer's startup failed so its promise never resolves.","commonSituations":"Agent killed mid-startup (helm upgrade, OOMKill) before the restorer resolved; cell wiring changed after a Cilium version upgrade; startup dependency deadlock.","solutions":["Check agent logs for an earlier root-cause failure in the endpoint restorer's startup and fix that first.","If the agent was shutting down, this is expected — restart the agent and let startup complete.","Verify the EndpointRestorer cell is enabled (not disabled by flags/config) for your Cilium version.","If startup deadlocks repeatedly, collect a hive dependency dump and check module ordering."],"exampleFix":"// before: await without shutdown awareness\nepRestorer, err := p.EPRestorer.Await(ctx)\nif err != nil {\n    return fmt.Errorf(\"waiting for endpoint restorer: %w\", err)\n}\n// after: distinguish shutdown from real failure\nepRestorer, err := p.EPRestorer.Await(ctx)\nif err != nil {\n    if ctx.Err() != nil {\n        return nil // shutting down; not an error\n    }\n    return fmt.Errorf(\"waiting for endpoint restorer: %w\", err)\n}","handlingStrategy":"try-catch","validationCode":"if p.EPRestorer == nil {\n    return errors.New(\"EndpointRestorer cell missing from hive config\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep the EndpointRestorer cell enabled in the hive module graph.","Avoid killing the agent during startup; drain gracefully.","Check earlier logs for restorer startup failures as the root cause.","Re-verify module wiring when upgrading Cilium versions."],"tags":["cilium","startup","dependency-injection"],"backgroundTag":"dependency-await-cancelled","analyzedSha":"ac7b90affa4baf0642e6685319d56907b3a73a6d","analyzedAt":"2026-08-31T18:27:15.868Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}