Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into remote-state-stats
Browse files Browse the repository at this point in the history
  • Loading branch information
Aman Khare committed Oct 24, 2023
2 parents a1efd42 + 5a288ed commit 2b50d4e
Show file tree
Hide file tree
Showing 38 changed files with 106 additions and 104 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Add search query categorizer ([#10255](https://github.com/opensearch-project/OpenSearch/pull/10255))
- Introduce ConcurrentQueryProfiler to profile query using concurrent segment search path and support concurrency during rewrite and create weight ([10352](https://github.com/opensearch-project/OpenSearch/pull/10352))
- [Remote cluster state] Make index and global metadata upload timeout dynamic cluster settings ([#10814](https://github.com/opensearch-project/OpenSearch/pull/10814))
- Added cluster setting cluster.restrict.index.replication_type to restrict setting of index setting replication type ([#10866](https://github.com/opensearch-project/OpenSearch/pull/10866))
- Add cluster state stats ([#10670](https://github.com/opensearch-project/OpenSearch/pull/10670))

### Dependencies
Expand All @@ -108,6 +109,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Bump `org.codehaus.woodstox:stax2-api` from 4.2.1 to 4.2.2 ([#10639](https://github.com/opensearch-project/OpenSearch/pull/10639))
- Bump `com.google.http-client:google-http-client` from 1.43.2 to 1.43.3 ([#10635](https://github.com/opensearch-project/OpenSearch/pull/10635))
- Bump `com.squareup.okio:okio` from 3.5.0 to 3.6.0 ([#10637](https://github.com/opensearch-project/OpenSearch/pull/10637))
- Bump `org.apache.logging.log4j:log4j-core` from 2.20.0 to 2.21.0 ([#10858](https://github.com/opensearch-project/OpenSearch/pull/10858))

### Changed
- Mute the query profile IT with concurrent execution ([#9840](https://github.com/opensearch-project/OpenSearch/pull/9840))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ plugins {
repositories {
mavenCentral()
}

dependencies {
implementation "org.apache.logging.log4j:log4j-core:2.20.0"
implementation "org.apache.logging.log4j:log4j-core:2.21.0"
}

["0.0.1", "0.0.2"].forEach { v ->
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/version.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jackson_databind = 2.15.2
snakeyaml = 2.1
icu4j = 70.1
supercsv = 2.4.0
log4j = 2.20.0
log4j = 2.21.0
slf4j = 1.7.36
asm = 9.6
jettison = 1.5.4
Expand Down
1 change: 0 additions & 1 deletion libs/core/licenses/log4j-api-2.20.0.jar.sha1

This file was deleted.

1 change: 1 addition & 0 deletions libs/core/licenses/log4j-api-2.21.0.jar.sha1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
760192f2b69eacf4a4afc78e5a1d7a8de054fcbd
1 change: 0 additions & 1 deletion plugins/crypto-kms/licenses/log4j-1.2-api-2.20.0.jar.sha1

This file was deleted.

1 change: 1 addition & 0 deletions plugins/crypto-kms/licenses/log4j-1.2-api-2.21.0.jar.sha1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
12bad3819a9570807f3c97315930699584c12152

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
12bad3819a9570807f3c97315930699584c12152

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
12bad3819a9570807f3c97315930699584c12152

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
12bad3819a9570807f3c97315930699584c12152

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
12bad3819a9570807f3c97315930699584c12152

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
911fdb5b1a1df36719c579ecc6f2957b88bce1ab

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
12bad3819a9570807f3c97315930699584c12152
5 changes: 5 additions & 0 deletions qa/os/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ tasks.dependenciesInfo.enabled = false

tasks.thirdPartyAudit.ignoreMissingClasses()

tasks.thirdPartyAudit.ignoreViolations(
'org.apache.logging.log4j.core.util.internal.UnsafeUtil',
'org.apache.logging.log4j.core.util.internal.UnsafeUtil$1'
)

tasks.register('destructivePackagingTest') {
dependsOn 'destructiveDistroTest'
}
Expand Down
4 changes: 3 additions & 1 deletion server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,9 @@ tasks.named("thirdPartyAudit").configure {
'com.google.protobuf.UnsafeUtil$Android32MemoryAccessor',
'com.google.protobuf.UnsafeUtil$Android64MemoryAccessor',
'com.google.protobuf.UnsafeUtil$JvmMemoryAccessor',
'com.google.protobuf.UnsafeUtil$MemoryAccessor'
'com.google.protobuf.UnsafeUtil$MemoryAccessor',
'org.apache.logging.log4j.core.util.internal.UnsafeUtil',
'org.apache.logging.log4j.core.util.internal.UnsafeUtil$1'
)
}

Expand Down
1 change: 0 additions & 1 deletion server/licenses/log4j-api-2.20.0.jar.sha1

This file was deleted.

1 change: 1 addition & 0 deletions server/licenses/log4j-api-2.21.0.jar.sha1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
760192f2b69eacf4a4afc78e5a1d7a8de054fcbd
1 change: 0 additions & 1 deletion server/licenses/log4j-core-2.20.0.jar.sha1

This file was deleted.

1 change: 1 addition & 0 deletions server/licenses/log4j-core-2.21.0.jar.sha1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
122e1a9e0603cc9eae07b0846a6ff01f2454bc49
1 change: 0 additions & 1 deletion server/licenses/log4j-jul-2.20.0.jar.sha1

This file was deleted.

1 change: 1 addition & 0 deletions server/licenses/log4j-jul-2.21.0.jar.sha1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
f0da61113f4a47654677e6a98b1e13ca7de2483d
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.opensearch.test.OpenSearchIntegTestCase;

import static org.opensearch.cluster.metadata.IndexMetadata.SETTING_REPLICATION_TYPE;
import static org.opensearch.indices.IndicesService.CLUSTER_RESTRICT_INDEX_REPLICATION_TYPE_SETTING;
import static org.opensearch.indices.IndicesService.CLUSTER_SETTING_REPLICATION_TYPE;

@OpenSearchIntegTestCase.ClusterScope(scope = OpenSearchIntegTestCase.Scope.TEST, numDataNodes = 0)
Expand Down Expand Up @@ -123,4 +124,30 @@ public void testIndexReplicationSettingOverridesDocRepClusterSetting() throws Ex
assertEquals(indicesService.indexService(anotherIndex).getIndexSettings().isSegRepEnabled(), false);
}

public void testIndexReplicationTypeWhenRestrictSettingTrue() {
testRestrictIndexReplicationTypeSetting(true, randomFrom(ReplicationType.values()));
}

public void testIndexReplicationTypeWhenRestrictSettingFalse() {
testRestrictIndexReplicationTypeSetting(false, randomFrom(ReplicationType.values()));
}

private void testRestrictIndexReplicationTypeSetting(boolean setRestrict, ReplicationType replicationType) {
String expectedExceptionMsg =
"Validation Failed: 1: index setting [index.replication.type] is not allowed to be set as [cluster.restrict.index.replication_type=true];";
String clusterManagerName = internalCluster().startNode(
Settings.builder().put(CLUSTER_RESTRICT_INDEX_REPLICATION_TYPE_SETTING.getKey(), setRestrict).build()
);
internalCluster().startDataOnlyNodes(1);

// Test create index fails
Settings indexSettings = Settings.builder().put(indexSettings()).put(SETTING_REPLICATION_TYPE, replicationType).build();
if (setRestrict) {
IllegalArgumentException exception = expectThrows(IllegalArgumentException.class, () -> createIndex(INDEX_NAME, indexSettings));
assertEquals(expectedExceptionMsg, exception.getMessage());
} else {
createIndex(INDEX_NAME, indexSettings);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,39 +10,33 @@

import org.opensearch.action.admin.cluster.remotestore.restore.RestoreRemoteStoreRequest;
import org.opensearch.action.admin.cluster.remotestore.restore.RestoreRemoteStoreResponse;
import org.opensearch.action.admin.indices.get.GetIndexRequest;
import org.opensearch.action.admin.indices.get.GetIndexResponse;
import org.opensearch.action.support.PlainActionFuture;
import org.opensearch.cluster.health.ClusterHealthStatus;
import org.opensearch.cluster.metadata.IndexMetadata;
import org.opensearch.cluster.node.DiscoveryNode;
import org.opensearch.cluster.service.ClusterService;
import org.opensearch.common.settings.Settings;
import org.opensearch.common.unit.TimeValue;
import org.opensearch.core.common.unit.ByteSizeUnit;
import org.opensearch.repositories.RepositoriesService;
import org.opensearch.repositories.Repository;
import org.opensearch.test.CorruptionUtils;
import org.opensearch.test.InternalTestCluster;
import org.opensearch.test.OpenSearchIntegTestCase;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static org.opensearch.node.remotestore.RemoteStoreNodeAttribute.REMOTE_STORE_REPOSITORY_SETTINGS_ATTRIBUTE_KEY_PREFIX;
import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertAcked;
import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertHitCount;
import static org.hamcrest.Matchers.greaterThan;

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

/**
Expand Down Expand Up @@ -467,30 +461,5 @@ public void testRateLimitedRemoteDownloads() throws Exception {
}
}

public void testRestoreCorruptSegmentShouldFail() throws IOException, ExecutionException, InterruptedException {
prepareCluster(1, 3, INDEX_NAME, 0, 1);
indexData(randomIntBetween(3, 4), true, INDEX_NAME);

GetIndexResponse getIndexResponse = client().admin().indices().getIndex(new GetIndexRequest()).get();
String indexUUID = getIndexResponse.getSettings().get(INDEX_NAME).get(IndexMetadata.SETTING_INDEX_UUID);

logger.info("--> Corrupting segment files in remote segment store");
Path path = segmentRepoPath.resolve(indexUUID).resolve("0").resolve("segments").resolve("data");
try (Stream<Path> dataPath = Files.list(path)) {
CorruptionUtils.corruptFile(random(), dataPath.toArray(Path[]::new));
}

logger.info("--> Stop primary");
internalCluster().stopRandomNode(InternalTestCluster.nameFilter(primaryNodeName(INDEX_NAME)));

logger.info("--> Close and restore the index");
client().admin()
.cluster()
.restoreRemoteStore(new RestoreRemoteStoreRequest().indices(INDEX_NAME).waitForCompletion(true), PlainActionFuture.newFuture());

logger.info("--> Check for index status, should be red due to corruption");
ensureRed(INDEX_NAME);
}

// TODO: Restore flow - index aliases
}
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ public SearchRequest(StreamInput in) throws IOException {
if (in.getVersion().onOrAfter(Version.V_2_7_0)) {
pipeline = in.readOptionalString();
}
if (in.getVersion().onOrAfter(Version.V_3_0_0)) {
if (in.getVersion().onOrAfter(Version.V_2_12_0)) {
phaseTook = in.readOptionalBoolean();
}
}
Expand Down Expand Up @@ -290,7 +290,7 @@ public void writeTo(StreamOutput out) throws IOException {
if (out.getVersion().onOrAfter(Version.V_2_7_0)) {
out.writeOptionalString(pipeline);
}
if (out.getVersion().onOrAfter(Version.V_3_0_0)) {
if (out.getVersion().onOrAfter(Version.V_2_12_0)) {
out.writeOptionalBoolean(phaseTook);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public SearchResponse(StreamInput in) throws IOException {
clusters = new Clusters(in);
scrollId = in.readOptionalString();
tookInMillis = in.readVLong();
if (in.getVersion().onOrAfter(Version.V_3_0_0)) {
if (in.getVersion().onOrAfter(Version.V_2_12_0)) {
phaseTook = in.readOptionalWriteable(PhaseTook::new);
} else {
phaseTook = null;
Expand Down Expand Up @@ -557,7 +557,7 @@ public void writeTo(StreamOutput out) throws IOException {
clusters.writeTo(out);
out.writeOptionalString(scrollId);
out.writeVLong(tookInMillis);
if (out.getVersion().onOrAfter(Version.V_3_0_0)) {
if (out.getVersion().onOrAfter(Version.V_2_12_0)) {
out.writeOptionalWriteable(phaseTook);
}
out.writeVInt(skippedShards);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1252,6 +1252,7 @@ List<String> getIndexSettingsValidationErrors(
if (forbidPrivateIndexSettings) {
validationErrors.addAll(validatePrivateSettingsNotExplicitlySet(settings, indexScopedSettings));
}
validateIndexReplicationTypeSettings(settings, clusterService.getClusterSettings()).ifPresent(validationErrors::add);
if (indexName.isEmpty() || indexName.get().charAt(0) != '.') {
// Apply aware replica balance validation only to non system indices
int replicaCount = settings.getAsInt(
Expand Down Expand Up @@ -1306,6 +1307,24 @@ private static List<String> validateIndexCustomPath(Settings settings, @Nullable
return validationErrors;
}

/**
* Validates {@code index.replication.type} is not set if {@code cluster.restrict.index.replication_type} is set to true.
*
* @param requestSettings settings passed in during index create request
* @param clusterSettings cluster setting
*/
private static Optional<String> validateIndexReplicationTypeSettings(Settings requestSettings, ClusterSettings clusterSettings) {
if (requestSettings.hasValue(SETTING_REPLICATION_TYPE)
&& clusterSettings.get(IndicesService.CLUSTER_RESTRICT_INDEX_REPLICATION_TYPE_SETTING)) {
return Optional.of(
"index setting [index.replication.type] is not allowed to be set as ["
+ IndicesService.CLUSTER_RESTRICT_INDEX_REPLICATION_TYPE_SETTING.getKey()
+ "=true]"
);
}
return Optional.empty();
}

/**
* Validates the settings and mappings for shrinking an index.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,8 @@ public void apply(Settings value, Settings current, Settings previous) {
AdmissionControlSettings.ADMISSION_CONTROL_TRANSPORT_LAYER_MODE,
CPUBasedAdmissionControllerSettings.CPU_BASED_ADMISSION_CONTROLLER_TRANSPORT_LAYER_MODE,
CPUBasedAdmissionControllerSettings.INDEXING_CPU_USAGE_LIMIT,
CPUBasedAdmissionControllerSettings.SEARCH_CPU_USAGE_LIMIT
CPUBasedAdmissionControllerSettings.SEARCH_CPU_USAGE_LIMIT,
IndicesService.CLUSTER_RESTRICT_INDEX_REPLICATION_TYPE_SETTING
)
)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ public ClusterMetadataManifest(StreamInput in) throws IOException {
this.indices = Collections.unmodifiableList(in.readList(UploadedIndexMetadata::new));
this.previousClusterUUID = in.readString();
this.clusterUUIDCommitted = in.readBoolean();
if (in.getVersion().onOrAfter(Version.V_3_0_0)) {
if (in.getVersion().onOrAfter(Version.V_2_12_0)) {
this.codecVersion = in.readInt();
this.globalMetadataFileName = in.readString();
} else {
Expand Down Expand Up @@ -316,7 +316,7 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeCollection(indices);
out.writeString(previousClusterUUID);
out.writeBoolean(clusterUUIDCommitted);
if (out.getVersion().onOrAfter(Version.V_3_0_0)) {
if (out.getVersion().onOrAfter(Version.V_2_12_0)) {
out.writeInt(codecVersion);
out.writeString(globalMetadataFileName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,10 +290,6 @@ public void setWrittenByMajor(int writtenByMajor) {
);
}
}

public int getWrittenByMajor() {
return writtenByMajor;
}
}

/**
Expand Down
Loading

0 comments on commit 2b50d4e

Please sign in to comment.