Skip to content

Commit

Permalink
Add opensearch version info while deserialization
Browse files Browse the repository at this point in the history
Signed-off-by: Sooraj Sinha <[email protected]>
  • Loading branch information
soosinha committed Oct 27, 2024
1 parent 6f1b59e commit 64c813f
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- [Workload Management] Fixing Create/Update QueryGroup TransportActions to execute from non-cluster manager nodes ([16422](https://github.com/opensearch-project/OpenSearch/pull/16422))
- Fix flaky test in `testApproximateRangeWithSizeOverDefault` by adjusting totalHits assertion logic ([#16434](https://github.com/opensearch-project/OpenSearch/pull/16434#pullrequestreview-2386999409))
- Revert changes to upload remote state manifest using minimum codec version([#16403](https://github.com/opensearch-project/OpenSearch/pull/16403))
- Use OpenSearch version to deserializat remote custom metadata([#16494](https://github.com/opensearch-project/OpenSearch/pull/16494))

### Security

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1262,7 +1262,8 @@ ClusterState readClusterStateInParallel(
entry.getKey(),
clusterUUID,
blobStoreRepository.getCompressor(),
namedWriteableRegistry
namedWriteableRegistry,
manifest.getOpensearchVersion()
),
listener
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,8 @@ Metadata getGlobalMetadata(String clusterUUID, ClusterMetadataManifest clusterMe
key,
clusterUUID,
compressor,
namedWriteableRegistry
namedWriteableRegistry,
clusterMetadataManifest.getOpensearchVersion()
);
builder.putCustom(key, (Custom) getStore(remoteCustomMetadata).read(remoteCustomMetadata));
} catch (IOException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

package org.opensearch.gateway.remote.model;

import org.opensearch.Version;
import org.opensearch.cluster.metadata.Metadata.Custom;
import org.opensearch.common.io.Streams;
import org.opensearch.common.remote.AbstractClusterMetadataWriteableBlobEntity;
Expand Down Expand Up @@ -67,16 +68,17 @@ public RemoteCustomMetadata(
final String customType,
final String clusterUUID,
final Compressor compressor,
final NamedWriteableRegistry namedWriteableRegistry
final NamedWriteableRegistry namedWriteableRegistry,
final Version version
) {
super(clusterUUID, compressor, null);
this.blobName = blobName;
this.customType = customType;
this.namedWriteableRegistry = namedWriteableRegistry;
this.customBlobStoreFormat = new ChecksumWritableBlobStoreFormat<>(
"custom",
is -> readFrom(is, namedWriteableRegistry, customType)
);
this.customBlobStoreFormat = new ChecksumWritableBlobStoreFormat<>("custom", is -> {
is.setVersion(version);
return readFrom(is, namedWriteableRegistry, customType);
});
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

package org.opensearch.gateway.remote;

import org.opensearch.Version;
import org.opensearch.action.LatchedActionListener;
import org.opensearch.cluster.ClusterModule;
import org.opensearch.cluster.ClusterName;
Expand Down Expand Up @@ -487,7 +488,8 @@ public void testGetAsyncReadRunnable_CustomMetadata() throws Exception {
IndexGraveyard.TYPE,
CLUSTER_UUID,
compressor,
namedWriteableRegistry
namedWriteableRegistry,
Version.CURRENT
);
when(blobStoreTransferService.downloadBlob(anyIterable(), anyString())).thenReturn(
customMetadataForDownload.customBlobStoreFormat.serialize(customMetadata, fileName, compressor).streamInput()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ public void testClusterUUID() {
"test-custom",
clusterUUID,
compressor,
namedWriteableRegistry
namedWriteableRegistry,
Version.CURRENT
);
assertThat(remoteObjectForDownload.clusterUUID(), is(clusterUUID));
}
Expand All @@ -128,7 +129,8 @@ public void testFullBlobName() {
"test-custom",
clusterUUID,
compressor,
namedWriteableRegistry
namedWriteableRegistry,
Version.CURRENT
);
assertThat(remoteObjectForDownload.getFullBlobName(), is(TEST_BLOB_NAME));
}
Expand All @@ -150,7 +152,8 @@ public void testBlobFileName() {
"test-custom",
clusterUUID,
compressor,
namedWriteableRegistry
namedWriteableRegistry,
Version.CURRENT
);
assertThat(remoteObjectForDownload.getBlobFileName(), is(TEST_BLOB_FILE_NAME));
}
Expand All @@ -162,7 +165,8 @@ public void testBlobPathTokens() {
"test-custom",
clusterUUID,
compressor,
namedWriteableRegistry
namedWriteableRegistry,
Version.CURRENT
);
assertThat(remoteObjectForDownload.getBlobPathTokens(), is(new String[] { "user", "local", "opensearch", "customMetadata" }));
}
Expand Down

0 comments on commit 64c813f

Please sign in to comment.