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

Add support for the desired nodes API #5650

Merged
merged 24 commits into from
May 30, 2022

Conversation

barkbay
Copy link
Contributor

@barkbay barkbay commented May 10, 2022

This PR is a draft implementation to add support for the Elasticsearch desired API. I want to raise it now to allow anyone interested in this feature to try it out. There is an ongoing discussion regarding how the CPU capacity should be provided to Elasticsearch (refer to the related ECK issue or this Elasticsearch PR) which is not yet reflected in this draft.

Required resources

For the operator to be able to call the desired node API the following resources are expected in nodeSets[*].podTemplate.spec.containers["elasticsearch"]:

  • memory: Both the limit and the request must be set to a same value.
  • cpu:
    • limit is returned if set
    • if limit is not set then request is returned
  • storage: Multiple storage data path is not supported. The storage path must be backed by a volume claim. The storage capacity is read from the PersistentVolumeClaim status, or from the PersistentVolumeClaim specification if it is not bound yet.

What if resources are missing?

If the capacity of at least one resource (cpu,memory or storage) cannot be calculated the reconciliation is not stopped, the desired node API is however not called, it is also cleared. The Elasticsearch status subresource helps to understand why, here are a few examples:

    {
      "lastTransitionTime": "2022-05-10T12:54:14Z",
      "message": "Cannot get compute and storage resources from Elasticsearch resource generation 2: cannot compute resources for NodeSet \"ml\": no CPU request or limit set",
      "status": "False",
      "type": "ResourcesAwareManagement"
    }
    {
      "lastTransitionTime": "2022-05-10T12:59:29Z",
      "message": "Cannot get compute and storage resources from Elasticsearch resource generation 2: cannot compute resources for NodeSet \"hot\": Memory limit is set but value is 0",
      "status": "False",
      "type": "ResourcesAwareManagement"
    }

If the state of the desired node API can be calculated for a generation:

    {
      "lastTransitionTime": "2022-05-10T13:03:44Z",
      "message": "Successfully calculated compute and storage resources from Elasticsearch resource generation 4",
      "status": "True",
      "type": "ResourcesAwareManagement"
    }

Testing

Minimum Elasticsearch version to test this PR is 8.1.0

@barkbay barkbay added the >enhancement Enhancement of existing functionality label May 10, 2022
Copy link
Collaborator

@pebrc pebrc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks really clean 👌. I left a few minor comments. In my experiments what I found confusing is the interaction between our resource defaults and resource limits/requests I set explicitly but that is nothing to do with your work here.

pkg/controller/elasticsearch/client/desired_nodes.go Outdated Show resolved Hide resolved
pkg/controller/elasticsearch/client/desired_nodes.go Outdated Show resolved Hide resolved
pkg/controller/elasticsearch/driver/desired_nodes.go Outdated Show resolved Hide resolved
pkg/controller/elasticsearch/nodespec/desired_nodes.go Outdated Show resolved Hide resolved
pkg/controller/elasticsearch/nodespec/desired_nodes.go Outdated Show resolved Hide resolved
pkg/controller/elasticsearch/nodespec/desired_nodes.go Outdated Show resolved Hide resolved
@barkbay
Copy link
Contributor Author

barkbay commented May 17, 2022

Commit f511711 relies on elastic/elasticsearch#86434 to set the CPU resources, and makes Elasticsearch 8.3.0 the min. supported version.

@barkbay
Copy link
Contributor Author

barkbay commented May 20, 2022

This PR is ready for review, however you'll need elastic/elasticsearch#86434 to be merged in 8.3.0-SNAPSHOT to test it or run the new E2E check. I'll post a comment here once it is the case.

@fcofdez
Copy link

fcofdez commented May 20, 2022

I've just merged elastic/elasticsearch#86434. It should be available in the next 8.3.0-SNAPSHOT build

@barkbay
Copy link
Contributor Author

barkbay commented May 20, 2022

Jenkins test this please

@barkbay
Copy link
Contributor Author

barkbay commented May 23, 2022

elastic/elasticsearch#86434 is now available in the last 8.3.0-SNAPSHOT Elasticsearch image (docker.elastic.co/elasticsearch/elasticsearch@sha256:2e822d038c0b0f14ac906ca9077c594fdc06458cab0566966b8a95c9ddce6f9b).

Copy link
Collaborator

@pebrc pebrc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍 as I said before its very clean and easy to read. I did some tests with the latest snapshot build of Elasticsearch that contains the processor ranges change. But my tests where not super thorough I just checked that API was called and that it contained desired nodes information. I am not sure how to verify whether Elasticsearch can take advantage of that information.

pkg/controller/elasticsearch/driver/desired_nodes.go Outdated Show resolved Hide resolved
pkg/controller/elasticsearch/driver/desired_nodes_test.go Outdated Show resolved Hide resolved
test/e2e/test/elasticsearch/checks_es.go Outdated Show resolved Hide resolved
return nil, false, err
}
visit(nil, settings, func(s string) string {
return knownVariablesReplacer.Replace(s)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to better understand why we have to replace these variables for the desired nodes API. #5528 (comment) it seems that you are worried some of the optimisations that ES does will be negatively affected if there are still variables in the settings. Can you maybe add a comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a comment, the main motivation is to provide a value to the node.name parameter.

Copy link
Contributor

@thbkrkr thbkrkr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some very minor comments.
LGTM!

pkg/controller/elasticsearch/nodespec/desired_nodes.go Outdated Show resolved Hide resolved
pkg/controller/elasticsearch/nodespec/desired_nodes.go Outdated Show resolved Hide resolved
pkg/controller/elasticsearch/nodespec/desired_nodes.go Outdated Show resolved Hide resolved
pkg/controller/elasticsearch/nodespec/desired_nodes.go Outdated Show resolved Hide resolved
pkg/controller/elasticsearch/nodespec/desired_nodes.go Outdated Show resolved Hide resolved
pkg/controller/elasticsearch/nodespec/desired_nodes.go Outdated Show resolved Hide resolved
pkg/controller/elasticsearch/nodespec/desired_nodes.go Outdated Show resolved Hide resolved
pkg/controller/elasticsearch/driver/desired_nodes_test.go Outdated Show resolved Hide resolved
barkbay and others added 2 commits May 24, 2022 15:11
Co-authored-by: Thibault Richard <thbkrkr@users.noreply.github.com>
Co-authored-by: Thibault Richard <thbkrkr@users.noreply.github.com>
Co-authored-by: Thibault Richard <thbkrkr@users.noreply.github.com>
@barkbay barkbay added the v2.3.0 label May 30, 2022
@barkbay barkbay merged commit df5a158 into elastic:main May 30, 2022
@barkbay barkbay deleted the feature/desired-nodes branch May 30, 2022 05:57
fantapsody pushed a commit to fantapsody/cloud-on-k8s that referenced this pull request Feb 7, 2023
Co-authored-by: Peter Brachwitz <peter.brachwitz@gmail.com>
Co-authored-by: Thibault Richard <thbkrkr@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>enhancement Enhancement of existing functionality v2.3.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants