Skip to content

Commit

Permalink
Merge main into change_extension_reading and remove test
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Bogan <rbogan@amazon.com>
  • Loading branch information
ryanbogan committed Jan 11, 2023
2 parents 582c97d + eeca443 commit 0675de8
Show file tree
Hide file tree
Showing 58 changed files with 2,192 additions and 237 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

# CHANGELOG

All notable changes to this project are documented in this file.
Expand All @@ -15,6 +16,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- [Test] Add IAE test for deprecated edgeNGram analyzer name ([#5040](https://github.com/opensearch-project/OpenSearch/pull/5040))
- Allow mmap to use new JDK-19 preview APIs in Apache Lucene 9.4+ ([#5151](https://github.com/opensearch-project/OpenSearch/pull/5151))
- Add feature flag for extensions ([#5211](https://github.com/opensearch-project/OpenSearch/pull/5211))
- Support to fail open requests on search shard failures with weighted traffic routing ([#5072](https://github.com/opensearch-project/OpenSearch/pull/5072))
- Added jackson dependency to server ([#5366] (https://github.com/opensearch-project/OpenSearch/pull/5366))
- Adding support to register settings dynamically ([#5495](https://github.com/opensearch-project/OpenSearch/pull/5495))
- Added experimental support for extensions ([#5347](https://github.com/opensearch-project/OpenSearch/pull/5347)), ([#5518](https://github.com/opensearch-project/OpenSearch/pull/5518), ([#5597](https://github.com/opensearch-project/OpenSearch/pull/5597)), ([#5615](https://github.com/opensearch-project/OpenSearch/pull/5615)))
- Add CI bundle pattern to distribution download ([#5348](https://github.com/opensearch-project/OpenSearch/pull/5348))
Expand All @@ -24,7 +27,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Add support for discovered cluster manager and remove local weights ([#5680](https://github.com/opensearch-project/OpenSearch/pull/5680))
- Added support for feature flags in opensearch.yml ([#4959](https://github.com/opensearch-project/OpenSearch/pull/4959))
- Add query for initialized extensions ([#5658](https://github.com/opensearch-project/OpenSearch/pull/5658))
- Remove two permissions from server security policy and change extension reading ([#5768](https://github.com/opensearch-project/OpenSearch/pull/5768))
- Revert 'Added jackson dependency to server' and change extension reading ([#5768](https://github.com/opensearch-project/OpenSearch/pull/5768))

### Dependencies
- Bumps `log4j-core` from 2.18.0 to 2.19.0
Expand Down Expand Up @@ -67,6 +70,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Changed http code on create index API with bad input raising NotXContentException from 500 to 400 ([#4773](https://github.com/opensearch-project/OpenSearch/pull/4773))
- Change http code for DecommissioningFailedException from 500 to 400 ([#5283](https://github.com/opensearch-project/OpenSearch/pull/5283))
- Pre conditions check before updating weighted routing metadata ([#4955](https://github.com/opensearch-project/OpenSearch/pull/4955))
- Gracefully handle concurrent zone decommission action ([#5542](https://github.com/opensearch-project/OpenSearch/pull/5542))

### Deprecated

Expand Down Expand Up @@ -102,6 +106,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Add max_shard_size parameter for shrink API ([#5229](https://github.com/opensearch-project/OpenSearch/pull/5229))
- Added support to apply index create block ([#4603](https://github.com/opensearch-project/OpenSearch/issues/4603))
- Support request level durability for remote-backed indexes ([#5671](https://github.com/opensearch-project/OpenSearch/issues/5671))
- Added new level to get health per awareness attribute in _cluster/health ([#5694](https://github.com/opensearch-project/OpenSearch/pull/5694))

### Dependencies
- Bumps `bcpg-fips` from 1.0.5.1 to 1.0.7.1
Expand Down
1 change: 1 addition & 0 deletions release-notes/opensearch.release-notes-2.4.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,5 @@
- Fix error handling while reading analyzer mapping rules ([6d20423](https://github.com/opensearch-project/OpenSearch/commit/6d20423f5920745463b1abc5f1daf6a786c41aa0))

### Security
- Fixes CVE-2022-41917 ([#5141](https://github.com/opensearch-project/OpenSearch/pull/5141))
- CVE-2022-25857 org.yaml:snakeyaml DOS vulnerability ([#4341](https://github.com/opensearch-project/OpenSearch/pull/4341))
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@
"options":[
"cluster",
"indices",
"shards"
"shards",
"awareness_attributes"
],
"default":"cluster",
"description":"Specify the level of detail for returned information"
Expand Down Expand Up @@ -106,6 +107,10 @@
"red"
],
"description":"Wait until cluster is in a specific state"
},
"awareness_attribute":{
"type":"string",
"description":"The awareness attribute for which the health is required"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,220 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

package org.opensearch.cluster;

import org.opensearch.action.admin.cluster.health.ClusterHealthResponse;
import org.opensearch.cluster.awarenesshealth.ClusterAwarenessAttributesHealth;
import org.opensearch.cluster.node.DiscoveryNodeRole;
import org.opensearch.common.settings.Settings;
import org.opensearch.test.OpenSearchIntegTestCase;

import java.util.List;
import java.util.Map;

import static org.hamcrest.Matchers.equalTo;
import static org.opensearch.test.NodeRoles.onlyRole;

@OpenSearchIntegTestCase.ClusterScope(scope = OpenSearchIntegTestCase.Scope.TEST, numDataNodes = 0)
public class clusterAwarenessHealthIT extends OpenSearchIntegTestCase {

public void testAwarenessAttributeHealthSucceeded() {
createIndex("test");
ensureGreen();

for (final String node : internalCluster().getNodeNames()) {
// a very high time out, which should never fire due to the local flag
logger.info("--> getting cluster health on [{}]", node);
final ClusterHealthResponse health = client(node).admin()
.cluster()
.prepareHealth()
.setTimeout("30s")
.setLevel("awareness_attributes")
.setAwarenessAttribute("zone")
.get("10s");

assertFalse("timed out on " + node, health.isTimedOut());
assertThat(
"health status on " + node,
health.getClusterAwarenessHealth().getClusterAwarenessAttributesHealthMap().size(),
equalTo(1)
);
}
}

public void testAwarenessAttributeHealthValidationFailed() {
createIndex("test");
ensureGreen();
for (final String node : internalCluster().getNodeNames()) {
// a very high time out, which should never fire due to the local flag
logger.info("--> getting cluster health on [{}]", node);
try {
final ClusterHealthResponse health = client(node).admin()
.cluster()
.prepareHealth()
.setTimeout("30s")
.setAwarenessAttribute("zone")
.get("10s");
} catch (Exception exception) {
assertThat(
exception.getMessage(),
equalTo("Validation Failed: 1: level=awareness_attributes is required with awareness_attribute parameter;")
);
}
}
}

public void testAwarenessAttributeHealthValidationFailedOnIndexHealth() {
createIndex("test");
ensureGreen();
for (final String node : internalCluster().getNodeNames()) {
// a very high time out, which should never fire due to the local flag
logger.info("--> getting cluster health on [{}]", node);
try {
final ClusterHealthResponse health = client(node).admin()
.cluster()
.prepareHealth("test")
.setTimeout("30s")
.setLevel("awareness_attributes")
.setAwarenessAttribute("zone")
.get("10s");
} catch (Exception exception) {
assertThat(
exception.getMessage(),
equalTo("Validation Failed: 1: awareness_attribute is not a supported parameter with index health;")
);
}
}
}

public void testAwarenessAttributeHealth() {
Settings commonSettings = Settings.builder()
.put("cluster.routing.allocation.awareness.attributes", "zone")
.put("cluster.routing.allocation.awareness.force.zone.values", "a,b,c")
.build();

logger.info("--> start 3 cluster manager nodes on zones 'd' & 'e' & 'f'");
List<String> clusterManagerNodes = internalCluster().startNodes(
Settings.builder()
.put(commonSettings)
.put("node.attr.zone", "d")
.put(onlyRole(commonSettings, DiscoveryNodeRole.CLUSTER_MANAGER_ROLE))
.build(),
Settings.builder()
.put(commonSettings)
.put("node.attr.zone", "e")
.put(onlyRole(commonSettings, DiscoveryNodeRole.CLUSTER_MANAGER_ROLE))
.build(),
Settings.builder()
.put(commonSettings)
.put("node.attr.zone", "f")
.put(onlyRole(commonSettings, DiscoveryNodeRole.CLUSTER_MANAGER_ROLE))
.build()
);

logger.info("--> start 3 data nodes on zones 'a' & 'b' & 'c'");
List<String> dataNodes = internalCluster().startNodes(
Settings.builder()
.put(commonSettings)
.put("node.attr.zone", "a")
.put(onlyRole(commonSettings, DiscoveryNodeRole.DATA_ROLE))
.build(),
Settings.builder()
.put(commonSettings)
.put("node.attr.zone", "b")
.put(onlyRole(commonSettings, DiscoveryNodeRole.DATA_ROLE))
.build(),
Settings.builder()
.put(commonSettings)
.put("node.attr.zone", "c")
.put(onlyRole(commonSettings, DiscoveryNodeRole.DATA_ROLE))
.build()
);

final ClusterHealthResponse health = client(dataNodes.get(0)).admin()
.cluster()
.prepareHealth()
.setTimeout("30s")
.setLevel("awareness_attributes")
.setAwarenessAttribute("zone")
.get("10s");

ensureStableCluster(6);
assertThat(health.getClusterAwarenessHealth().getClusterAwarenessAttributesHealthMap().size(), equalTo(1));
Map<String, ClusterAwarenessAttributesHealth> attributes = health.getClusterAwarenessHealth()
.getClusterAwarenessAttributesHealthMap();
for (String attribute : attributes.keySet()) {
String attributeName = attributes.get(attribute).getAwarenessAttributeName();
assertThat(attributeName, equalTo("zone"));
assertThat(attributes.get(attribute).getAwarenessAttributeHealthMap().size(), equalTo(3));
}
}

public void testAwarenessAttributeHealthAttributeDoesNotExists() {
Settings commonSettings = Settings.builder()
.put("cluster.routing.allocation.awareness.attributes", "zone")
.put("cluster.routing.allocation.awareness.force.zone.values", "a,b,c")
.build();

logger.info("--> start 3 cluster manager nodes on zones 'd' & 'e' & 'f'");
List<String> clusterManagerNodes = internalCluster().startNodes(
Settings.builder()
.put(commonSettings)
.put("node.attr.zone", "d")
.put(onlyRole(commonSettings, DiscoveryNodeRole.CLUSTER_MANAGER_ROLE))
.build(),
Settings.builder()
.put(commonSettings)
.put("node.attr.zone", "e")
.put(onlyRole(commonSettings, DiscoveryNodeRole.CLUSTER_MANAGER_ROLE))
.build(),
Settings.builder()
.put(commonSettings)
.put("node.attr.zone", "f")
.put(onlyRole(commonSettings, DiscoveryNodeRole.CLUSTER_MANAGER_ROLE))
.build()
);

logger.info("--> start 3 data nodes on zones 'a' & 'b' & 'c'");
List<String> dataNodes = internalCluster().startNodes(
Settings.builder()
.put(commonSettings)
.put("node.attr.zone", "a")
.put(onlyRole(commonSettings, DiscoveryNodeRole.DATA_ROLE))
.build(),
Settings.builder()
.put(commonSettings)
.put("node.attr.zone", "b")
.put(onlyRole(commonSettings, DiscoveryNodeRole.DATA_ROLE))
.build(),
Settings.builder()
.put(commonSettings)
.put("node.attr.zone", "c")
.put(onlyRole(commonSettings, DiscoveryNodeRole.DATA_ROLE))
.build()
);

final ClusterHealthResponse health = client(dataNodes.get(0)).admin()
.cluster()
.prepareHealth()
.setTimeout("30s")
.setLevel("awareness_attributes")
.setAwarenessAttribute("rack")
.get("10s");

ensureStableCluster(6);
assertThat(health.getClusterAwarenessHealth().getClusterAwarenessAttributesHealthMap().size(), equalTo(1));
Map<String, ClusterAwarenessAttributesHealth> attributes = health.getClusterAwarenessHealth()
.getClusterAwarenessAttributesHealthMap();
for (String attribute : attributes.keySet()) {
String attributeName = attributes.get(attribute).getAwarenessAttributeName();
assertThat(attributeName, equalTo("rack"));
assertThat(attributes.get(attribute).getAwarenessAttributeHealthMap().size(), equalTo(0));
}
}
}
Loading

0 comments on commit 0675de8

Please sign in to comment.