{"record":{"id":"9f8341a07a4002d3","repo":"jaegertracing/jaeger","slug":"failed-to-create-elasticsearch-client-w","errorCode":null,"errorMessage":"failed to create Elasticsearch client: %w","messagePattern":"failed to create Elasticsearch client: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/es-rollover/app/actions.go","lineNumber":74,"sourceCode":"type ActionExecuteOptions struct {\n\tArgs   []string\n\tViper  *viper.Viper\n\tLogger *zap.Logger\n}\n\n// ActionCreatorFunction type is the function type in charge of create the action to be executed\ntype ActionCreatorFunction func(*esclient.Client, Config) Action\n\n// ExecuteAction execute the action returned by the createAction function\nfunc ExecuteAction(opts ActionExecuteOptions, createAction ActionCreatorFunction) error {\n\tcfg := Config{}\n\tif err := cfg.InitFromViper(opts.Viper); err != nil {\n\t\treturn fmt.Errorf(\"failed to initialize config: %w\", err)\n\t}\n\n\tesClient, err := newESClient(context.Background(), opts.Args[0], &cfg, opts.Logger)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to create Elasticsearch client: %w\", err)\n\t}\n\taction := createAction(esClient, cfg)\n\treturn action.Do()\n}\n","sourceCodeStart":56,"sourceCodeEnd":79,"githubUrl":"https://github.com/jaegertracing/jaeger/blob/806f4447841ecdb60519f408b004a599d515f437/cmd/es-rollover/app/actions.go#L56-L79","documentation":"After the config loads, ExecuteAction creates an Elasticsearch client via newESClient; any failure is wrapped as \"failed to create Elasticsearch client\". Like error 130, the root cause is preserved via %w — typically the ES endpoint is unreachable, unauthenticated, or the client setup (TLS, version discovery) failed.","triggerScenarios":"Running any es-rollover action (init, rollover, lookback) when the Elasticsearch host in the first argument cannot be connected to, TLS handshake fails, or credentials are rejected during client construction.","commonSituations":"ES still starting when the rollover cronjob fires; wrong ES_URL; missing ca cert or bearer token for a secured cluster; network policy blocking pod-to-ES traffic.","solutions":["Read the wrapped underlying error and address it directly (DNS, refused, 401, x509).","Confirm ES_URL connectivity with curl from the same environment.","Supply correct TLS/auth flags for secured Elasticsearch/OpenSearch.","Ensure ordering: run init after ES is healthy (readiness gate, retry)."],"exampleFix":"// before\n./es-rollover init http://localhost:9200   # ES not on localhost\n// after\n./es-rollover init http://elasticsearch.default.svc:9200","handlingStrategy":"retry","validationCode":"resp, err := http.Get(esURL + \"/_cluster/health\")\nif err != nil || resp.StatusCode != 200 {\n    return fmt.Errorf(\"ES not ready at %s\", esURL)\n}\nresp.Body.Close()","typeGuard":null,"tryCatchPattern":"err := ExecuteAction(opts, createAction)\nfor retries := 0; err != nil && errors.Is(err, errTransient) && retries < 3; retries++ {\n    time.Sleep(backoff)\n    err = ExecuteAction(opts, createAction)\n}","preventionTips":["Gate rollover jobs on ES cluster-health readiness.","Centralize the ES URL in one config source to avoid typos.","Provide TLS material (ca/token) as mounted secrets, not inline flags.","Read the %w-wrapped cause first when debugging."],"tags":["elasticsearch","client-init","startup"],"backgroundTag":"elasticsearch-client-init-failed","analyzedSha":"806f4447841ecdb60519f408b004a599d515f437","analyzedAt":"2026-09-01T02:39:22.140Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}