{"record":{"id":"c9825fe29f2f94d2","repo":"t8y2/dbx","slug":"connect-to-zookeeper-w","errorCode":null,"errorMessage":"connect to ZooKeeper: %w","messagePattern":"connect to ZooKeeper: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/argo-go/discovery.go","lineNumber":106,"sourceCode":"\t\t\t\tdialer := &net.Dialer{Timeout: dialTimeout}\n\t\t\t\treturn tls.DialWithDialer(dialer, network, address, config)\n\t\t\t}),\n\t\t)\n\t}\n}\n\nfunc (discovery *zooKeeperDiscovery) Endpoints(ctx context.Context, rejected map[string]bool) ([]endpoint, error) {\n\taddresses := make([]string, 0, len(discovery.servers))\n\tfor _, server := range discovery.servers {\n\t\taddresses = append(addresses, server.address())\n\t}\n\ttimeout := discovery.timeout\n\tif timeout <= 0 {\n\t\ttimeout = defaultConnectTimeout\n\t}\n\tconnection, events, err := discovery.dialer(addresses, timeout)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"connect to ZooKeeper: %w\", err)\n\t}\n\tdefer connection.Close()\n\tif err := waitForZooKeeperSession(ctx, events, timeout); err != nil {\n\t\treturn nil, err\n\t}\n\tif discovery.authScheme != \"\" || discovery.auth != \"\" {\n\t\tif discovery.authScheme == \"\" || discovery.auth == \"\" {\n\t\t\treturn nil, errors.New(\"ZooKeeper auth scheme and credentials must be configured together\")\n\t\t}\n\t\tif err := connection.AddAuth(discovery.authScheme, []byte(discovery.auth)); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"authenticate to ZooKeeper: %w\", err)\n\t\t}\n\t}\n\tresolved := make([]endpoint, 0)\n\tvar listedPath string\n\tvar nodeFailures []string\n\tfor _, path := range discovery.paths() {\n\t\tchildren, _, childrenErr := connection.Children(path)","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/argo-go/discovery.go#L88-L124","documentation":"ZooKeeperDiscovery.Endpoints dials the ZooKeeper ensemble via the configured dialer and wraps any dial failure with this message. The %w preserves the underlying go-zookeeper error (refused, timeout, DNS failure). It is thrown before any session/auth work because no endpoint list can be read without a live connection.","triggerScenarios":"Calling Endpoints (via Hive discovery Connect) where discovery.dialer(addresses, timeout) fails: unreachable ZK hosts, connection timeout, TLS dial failure, DNS resolution failure.","commonSituations":"ZooKeeper ensemble down or in maintenance; wrong ZK host list/ports in the DSN; network partition or security-group rules; ZK client TLS endpoint used with plain dialer or vice versa; timeout too small for a loaded cluster.","solutions":["Check the wrapped cause and verify ZooKeeper hosts/ports are correct and reachable","Confirm the ZooKeeper ensemble is up (ruok/stat via four-letter words or zkCli)","Increase the connect timeout if the ensemble is slow to accept","Verify firewall/security-group and TLS dial configuration between client and ZK"],"exampleFix":"// before\ndsn := \"zookeeper://zk1.internal:2181/hs2\"  // zk1 decommissioned\n// after\ndsn := \"zookeeper://zk1.internal:2181,zk2.internal:2181,zk3.internal:2181/hs2\"","handlingStrategy":"retry","validationCode":"for _, hp := range strings.Split(zkHosts, \",\") {\n    conn, err := net.DialTimeout(\"tcp\", hp, 3*time.Second)\n    if err != nil {\n        return fmt.Errorf(\"ZooKeeper %s unreachable: %w\", hp, err)\n    }\n    conn.Close()\n}","typeGuard":null,"tryCatchPattern":"eps, err := discovery.Endpoints(ctx)\nif err != nil {\n    if strings.HasPrefix(err.Error(), \"connect to ZooKeeper:\") && errors.Is(err, context.DeadlineExceeded) {\n        time.Sleep(2 * time.Second)\n        eps, err = discovery.Endpoints(ctx) // retry with fresh session\n    }\n    if err != nil { return err }\n}","preventionTips":["List multiple ZK servers in the DSN for ensemble failover","Monitor ZK ensemble health (mode, latency) from the client network","Use an adequate connect timeout for loaded clusters","Verify network policy/security groups allow client->ZK:2181"],"tags":["zookeeper","network","discovery","dial"],"backgroundTag":"connection-refused","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}