{"record":{"id":"fca10a0cbef99021","repo":"hashicorp/nomad","slug":"failed-to-get-docker-long-operations-client-w","errorCode":null,"errorMessage":"failed to get docker long operations client: %w","messagePattern":"failed to get docker long operations client: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/docker/driver.go","lineNumber":265,"sourceCode":"\n\tvar handleState taskHandleState\n\tif err := handle.GetDriverState(&handleState); err != nil {\n\t\treturn fmt.Errorf(\"failed to decode driver task state: %v\", err)\n\t}\n\n\tdockerClient, err := d.getDockerClient()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to get docker client: %w\", err)\n\t}\n\n\tdockerInfo, err := dockerClient.Info(d.ctx, mclient.InfoOptions{})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to fetch docker daemon info: %v\", err)\n\t}\n\n\tinfinityClient, err := d.getInfinityClient()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to get docker long operations client: %w\", err)\n\t}\n\n\tcontainer, err := dockerClient.ContainerInspect(d.ctx, handleState.ContainerID, mclient.ContainerInspectOptions{})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to inspect container for id %q: %v\", handleState.ContainerID, err)\n\t}\n\n\th := &taskHandle{\n\t\tdockerClient:            dockerClient,\n\t\tdockerCGroupDriver:      dockerInfo.Info.CgroupDriver,\n\t\tinfinityClient:          infinityClient,\n\t\tlogger:                  d.logger.With(\"container_id\", container.Container.ID),\n\t\ttask:                    handle.Config,\n\t\tcontainerID:             container.Container.ID,\n\t\tcontainerCgroup:         string(container.Container.HostConfig.Cgroup),\n\t\tcontainerImage:          container.Container.Image,\n\t\tdoneCh:                  make(chan bool),\n\t\twaitCh:                  make(chan struct{}),","sourceCodeStart":247,"sourceCodeEnd":283,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/drivers/docker/driver.go#L247-L283","documentation":"After fetching daemon info, RecoverTask obtains a secondary client (via d.getInfinityClient) used for long-running docker operations. Failure here means the driver could not construct that client from the driver's endpoint/TLS configuration, so recovery cannot proceed and the error is wrapped with %w so callers can unwrap the underlying cause.","triggerScenarios":"getInfinityClient fails because the docker endpoint is unset or malformed, the underlying client factory cannot dial the daemon, TLS cert/key/CA files are missing or unreadable, or client construction (API negotiation) returns an error.","commonSituations":"Driver plugin restarted with a stale or changed `docker endpoint` config; TLS secrets rotated or deleted between restarts; environment where DOCKER_HOST is only set in the original plugin process; memory/fd exhaustion preventing new client creation.","solutions":["Check the driver's docker endpoint and TLS config (cert/key/CA files exist and are readable) — the same settings that worked at task start.","Run `docker info` against the configured endpoint to confirm the daemon is dialable.","Restart the nomad client/plugin so the driver re-reads its config, then retry task recovery.","Inspect the unwrapped cause (`errors.Unwrap`) — the %w wrapping preserves the root error from the client factory."],"exampleFix":"// before\ninfinityClient, err := d.getInfinityClient()\nif err != nil {\n\treturn fmt.Errorf(\"failed to get docker long operations client: %w\", err)\n}\n// after\ninfinityClient, err := d.getInfinityClient()\nif err != nil {\n\td.logger.Error(\"infinity client setup failed\", \"endpoint\", d.config.Endpoint, \"error\", err)\n\treturn fmt.Errorf(\"failed to get docker long operations client: %w\", err)\n}","handlingStrategy":"validation","validationCode":"// validate driver docker config before starting/recovering tasks\nfunc validateDockerDriverConfig(endpoint string, tls *TLSConfig) error {\n\tif endpoint == \"\" {\n\t\treturn errors.New(\"docker endpoint is empty\")\n\t}\n\tif tls != nil {\n\t\tfor _, p := range []string{tls.Cert, tls.Key, tls.CA} {\n\t\t\tif p != \"\" {\n\t\t\t\tif _, err := os.Stat(p); err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"tls file missing: %s: %w\", p, err)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}","typeGuard":null,"tryCatchPattern":"// Go: unwrap the %w cause to distinguish config vs connectivity\nerr := driver.RecoverTask(handle)\nvar root error\nfor e := err; e != nil; e = errors.Unwrap(e) {\n\troot = e\n}\nif err != nil && strings.Contains(err.Error(), \"long operations client\") {\n\tlog.Printf(\"infinity client init failed, root cause: %v\", root)\n}","preventionTips":["Keep docker endpoint/TLS driver config stable across agent restarts.","Pre-flight validate endpoint and TLS file existence at agent startup.","Rotate TLS secrets only with a coordinated agent reload.","Check fd/memory limits if many clients are created concurrently."],"tags":["docker","client-init","tls","task-recovery"],"backgroundTag":"docker-client-init-failed","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}