Skip to content
This repository was archived by the owner on Dec 9, 2024. It is now read-only.

Conversation

@hasancelik
Copy link

@hasancelik hasancelik commented Nov 24, 2020

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 using discoverLocalMetadata method like zone info. This method passes both zone and node name metadata. User can not enable two group types at the same time so cluster will decide which metadata will be used based on cluster config:

    hazelcast:
      partition-group:
        enabled: true
        group-type: NODE_AWARE

Here is the related PRD.

These changes will be forward-port to master(2.2.x) branch.

IMDG core counterpart PR .

Todo:

  • Add NODE_AWARE section into README

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.
@hasancelik hasancelik added this to the 1.5.5 milestone Nov 24, 2020
@hasancelik hasancelik requested a review from leszko November 24, 2020 13:44
Copy link

@leszko leszko left a 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>
Copy link

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.

Copy link
Author

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.

Copy link

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.

Copy link
Author

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");
Copy link

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));
Copy link

Choose a reason for hiding this comment

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

Suggested change
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) {
Copy link

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));

@hasancelik
Copy link
Author

Thanks for the review @leszko. I have addressed all of your comments, PTAL.

@hasancelik hasancelik requested a review from leszko November 25, 2020 10:19
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:
Copy link

Choose a reason for hiding this comment

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

Suggested change
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
Copy link

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?

Copy link
Author

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.

Copy link

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>
Copy link

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.

Comment on lines 109 to 110
String podName = podName();
String nodeName = client.nodeName(podName);
Copy link

Choose a reason for hiding this comment

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

Suggested change
String podName = podName();
String nodeName = client.nodeName(podName);
String nodeName = client.nodeName(podName());

Nit: Consider inlining.

@hasancelik hasancelik requested a review from leszko November 30, 2020 13:22
fieldPath: metadata.name
```

### Node Aware
Copy link

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.

@hasancelik hasancelik merged commit 9f70794 into hazelcast:1.5.x Dec 1, 2020
hasancelik pushed a commit that referenced this pull request Dec 1, 2020
* 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.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants