{"record":{"id":"9a8f8680f2a3c284","repo":"cilium/cilium","slug":"delete-endpoint-d-v","errorCode":null,"errorMessage":"delete endpoint %d: %v","messagePattern":"delete endpoint (.+?): (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/endpointmanager/script_cmds.go","lineNumber":96,"sourceCode":"\t\t\tscript.CmdUsage{\n\t\t\t\tSummary: \"Delete an Endpoint\",\n\t\t\t\tArgs:    \"id\",\n\t\t\t},\n\t\t\tfunc(s *script.State, args ...string) (script.WaitFunc, error) {\n\t\t\t\tif len(args) != 1 {\n\t\t\t\t\treturn nil, fmt.Errorf(\"expected one arg but got %v, see usage details\", len(args))\n\t\t\t\t}\n\t\t\t\tid, err := strconv.ParseUint(args[0], 10, 16)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, fmt.Errorf(\"parse id: %w\", err)\n\t\t\t\t}\n\t\t\t\tep := epm.LookupCiliumID(uint16(id))\n\t\t\t\tif ep == nil {\n\t\t\t\t\treturn nil, fmt.Errorf(\"endpoint %d not found\", id)\n\t\t\t\t}\n\t\t\t\treturn func(s *script.State) (stdout string, stderr string, err error) {\n\t\t\t\t\tif errs := epm.RemoveEndpoint(ep, endpoint.DeleteConfig{}); len(errs) > 0 {\n\t\t\t\t\t\treturn \"\", \"\", fmt.Errorf(\"delete endpoint %d: %v\", id, errs)\n\t\t\t\t\t}\n\t\t\t\t\treturn \"\", \"\", nil\n\t\t\t\t}, nil\n\t\t\t},\n\t\t),\n\t\t\"endpoint/list\": script.Command(\n\t\t\tscript.CmdUsage{\n\t\t\t\tSummary: \"List all Endpoints\",\n\t\t\t},\n\t\t\tfunc(s *script.State, args ...string) (script.WaitFunc, error) {\n\t\t\t\treturn func(s *script.State) (stdout string, stderr string, err error) {\n\t\t\t\t\tvar sb strings.Builder\n\t\t\t\t\tsb.WriteRune('[')\n\t\t\t\t\tfor _, ep := range epm.GetEndpointList(endpointapi.GetEndpointParams{}) {\n\t\t\t\t\t\tsb.WriteRune('{')\n\t\t\t\t\t\tsb.WriteString(spew.Sdump(\n\t\t\t\t\t\t\t\"id\", ep.ID,\n\t\t\t\t\t\t\t\"identity\", ep.Status.Identity,","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/cilium/cilium/blob/ac7b90affa4baf0642e6685319d56907b3a73a6d/pkg/endpointmanager/script_cmds.go#L78-L114","documentation":"When the requested deletion via epm.RemoveEndpoint returns one or more errors, the script command aggregates them into `delete endpoint %d: %v`. The lookup succeeded but the actual teardown (datapath cleanup, state removal, etc.) failed.","triggerScenarios":"`endpoint delete <id>` where RemoveEndpoint returns a non-empty error slice — e.g. failures removing the endpoint's datapath state or releasing its identity.","commonSituations":"Endpoint in a bad state (mid-regeneration, already disconnecting); underlying networking/link removal failures in the environment; concurrent delete of the same endpoint.","solutions":["Read the aggregated %v error list to find the underlying cause, then retry the delete.","Check the endpoint state with `endpoint list` — wait for it to leave 'disconnecting' state.","Check agent logs for datapath/identity errors during deletion.","As a last resort restart the agent, which triggers endpoint state recovery."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"ep := epm.LookupCiliumID(uint16(id))\nif ep == nil {\n    return fmt.Errorf(\"cannot delete: endpoint %d not found\", id)\n}\n// optionally check ep.State() is in a deletable state before calling RemoveEndpoint","typeGuard":null,"tryCatchPattern":"for attempt := 0; attempt < 3; attempt++ {\n    _, _, err := run(\"endpoint delete\", id)\n    if err == nil {\n        break\n    }\n    log.Printf(\"delete attempt %d failed: %v; retrying\", attempt+1, err)\n    time.Sleep(2 * time.Second)\n}","preventionTips":["Wait for endpoints to be in a stable state before deleting.","Avoid concurrent deletes of the same endpoint.","Check agent logs for the underlying datapath error in the aggregated list."],"tags":["cli","deletion","endpoint","datapath"],"backgroundTag":"endpoint-delete-failed","analyzedSha":"ac7b90affa4baf0642e6685319d56907b3a73a6d","analyzedAt":"2026-08-31T18:27:15.868Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}