-
Notifications
You must be signed in to change notification settings - Fork 100
Add NODE_AWARE metadata support #278
Add NODE_AWARE metadata support #278
Conversation
With 3.12.11 IMDG release, new metadata introduced to define partition group based on Kubernetes node that Hazelcast cluster runs on.The discovery plugin should pass name of the node to the core SPI via using discoverLocalMetadata method like zone info. This method passes both zone and node name metadata. User can not enable tow group types at the same time so cluster will decide which metadata will be used based on cluster config.
leszko
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a few comments, but in general it looks good. Thanks for the PR @hasancelik
pom.xml
Outdated
| <powermock.version>1.7.3</powermock.version> | ||
|
|
||
| <hazelcast.version>3.12.6</hazelcast.version> | ||
| <hazelcast.version>3.12.11-SNAPSHOT</hazelcast.version> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change should be backward-compatible so that we wouldn't change compatibility in patch releases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PartitionGroupMetaData.PARTITION_GROUP_NODE is/will be introduced with 3.12.11 so this version of hazelcast should be used, please check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The other option is to not use PartitionGroupMetaData.PARTITION_GROUP_NODE in the kubernetes plugin, but just copy the same constant. It's just this one constant, so to be honest, I'd favor keeping backward-compatibility than reusing this one constant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, backward compatibility is more important than the convention for this scenario.
| private String discoverNodeName() { | ||
| if (DiscoveryMode.KUBERNETES_API.equals(config.getMode())) { | ||
| try { | ||
| String podName = System.getenv("POD_NAME"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These lines look the same as in discoverZone(). Could you extract it to a method String podName()?
| } | ||
| String nodeName = client.nodeName(podName); | ||
| if (nodeName != null) { | ||
| getLogger().info(String.format("Kubernetes plugin extracted node name: %s", nodeName)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| getLogger().info(String.format("Kubernetes plugin extracted node name: %s", nodeName)); | |
| getLogger().info(String.format("Kubernetes plugin discovered node name: %s", nodeName)); |
For the sake of consistency.
| * @return Node name | ||
| * @see <a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.11">Kubernetes Endpoint API</a> | ||
| */ | ||
| String nodeName(String podName) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you use this method in zone(String podName). Like the zone method should now look like this:
String nodeUrlString = String.format("%s/api/v1/nodes/%s", kubernetesMaster, nodeName(podName));
return extractZone(callGet(nodeUrlString));
|
Thanks for the review @leszko. I have addressed all of your comments, PTAL. |
README.md
Outdated
| * Retrieving name of the node uses Kubernetes API, so RBAC must be configured as described [here](#granting-permissions-to-use-kubernetes-api) | ||
| * `NODE_AWARE` feature works correctly when Hazelcast members are distributed equally in all nodes, so your Kubernetes cluster must orchestrate PODs equally. | ||
|
|
||
| Note also that retrieving name of the node assumes that your container's hostname is the same as POD Name, which is almost always true. If you happen to change your hostname in the container, then please define the following environment variable: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Note also that retrieving name of the node assumes that your container's hostname is the same as POD Name, which is almost always true. If you happen to change your hostname in the container, then please define the following environment variable: | |
| Note also that retrieving name of the node assumes that your container's hostname is the same as POD Name, which is almost always true. If you happen to change your hostname in the container, then please define the following environment variable: |
| fieldPath: metadata.name | ||
| ``` | ||
|
|
||
| ### Node Aware |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The content of the Node Aware section is almost the same as Zone Aware. Could you maybe merge both of them and create a section like Zone / Node Aware?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know they are almost identical but separate section with own requirements and config is easily digestible. User wants to use Node Aware feature will not be disturbed by Zone Aware requirements or config.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, you're right. One thing that we could improve is to put them both under one section like "High Availability", "Zone/Node Failure Resilience", or "Zone/Node Aware". To have something like:
### High Availability
#### Zone Aware
#### Node Aware
Anyway, I leave it up to you.
pom.xml
Outdated
| <powermock.version>1.7.3</powermock.version> | ||
|
|
||
| <hazelcast.version>3.12.6</hazelcast.version> | ||
| <hazelcast.version>3.12.11-SNAPSHOT</hazelcast.version> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The other option is to not use PartitionGroupMetaData.PARTITION_GROUP_NODE in the kubernetes plugin, but just copy the same constant. It's just this one constant, so to be honest, I'd favor keeping backward-compatibility than reusing this one constant.
| String podName = podName(); | ||
| String nodeName = client.nodeName(podName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| String podName = podName(); | |
| String nodeName = client.nodeName(podName); | |
| String nodeName = client.nodeName(podName()); |
Nit: Consider inlining.
| fieldPath: metadata.name | ||
| ``` | ||
|
|
||
| ### Node Aware |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, you're right. One thing that we could improve is to put them both under one section like "High Availability", "Zone/Node Failure Resilience", or "Zone/Node Aware". To have something like:
### High Availability
#### Zone Aware
#### Node Aware
Anyway, I leave it up to you.
* Add NODE_AWARE metadata support With 3.12.11 IMDG release, new metadata introduced to define partition group based on Kubernetes node that Hazelcast cluster runs on.The discovery plugin should pass name of the node to the core SPI via using discoverLocalMetadata method like zone info. This method passes both zone and node name metadata. User can not enable tow group types at the same time so cluster will decide which metadata will be used based on cluster config.
With
3.12.11 IMDG release, new metadata/group type introduced to define partition group based on Kubernetes node that Hazelcast cluster runs on. The discovery plugin should pass name of the node to the core SPI via usingdiscoverLocalMetadatamethod like zone info. This method passes bothzoneandnode namemetadata. User can not enable two group types at the same time so cluster will decide which metadata will be used based on cluster config:Here is the related PRD.
These changes will be forward-port to master(2.2.x) branch.
IMDG core counterpart PR .
Todo: