Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetClusterHealthWaitForAllEvents may return empty/default value #4507

Closed
barkbay opened this issue May 25, 2021 · 1 comment · Fixed by #4803
Closed

GetClusterHealthWaitForAllEvents may return empty/default value #4507

barkbay opened this issue May 25, 2021 · 1 comment · Fixed by #4803
Assignees
Labels
>bug Something isn't working v1.8.0

Comments

@barkbay
Copy link
Contributor

barkbay commented May 25, 2021

If the Elasticsearch endpoint "/_cluster/health?wait_for_events=languid&timeout=0s" returns 408 (Timeout) then GetClusterHealthWaitForAllEvents swallows the error and returns an empty/default value. TimedOut may hold the default value false while the API actually returned true:

{
	"cluster_name": "elasticsearch-sample",
	"status": "green",
	"timed_out": true,
	"number_of_nodes": 3,
	"number_of_data_nodes": 3,
	"active_primary_shards": 12,
	"active_shards": 24,
	"relocating_shards": 0,
	"initializing_shards": 0,
	"unassigned_shards": 0,
	"delayed_unassigned_shards": 0,
	"number_of_pending_tasks": 0,
	"number_of_in_flight_fetch": 0,
	"task_max_waiting_in_queue_millis": 0,
	"active_shards_percent_as_number": 100.0
}

The returned value is not initialized because we do not attempt to parse/decode the body and return immediately when there is an error:

func (c *baseClient) request(
	...
	responseObj interface{},
) error {
	resp, err := c.doRequest(ctx, request)
	if err != nil {
		return err // <--- here
	}
    ...
	if responseObj != nil {
		if err := json.NewDecoder(resp.Body).Decode(responseObj); err != nil {
			return err
		}
	}

Should we attempt to decode the body as a best effort even if there is an error ?

@barkbay barkbay added >bug Something isn't working v1.7.0 labels May 25, 2021
@barkbay
Copy link
Contributor Author

barkbay commented May 25, 2021

408 should be replaced by 200 in the future: elastic/elasticsearch#70849 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug Something isn't working v1.8.0
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants