mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-10 06:55:32 +00:00
Create a directory during repository verification
The repository verification process should create a subdirectory to make sure we check permission of newly created directories in case elasticsearch processes on different nodes are running using different uids and creating blobs with incompatible permissions. Closes #11611
This commit is contained in:
parent
aea97c373c
commit
354504334f
@ -221,10 +221,10 @@ public class BlobStoreIndexShardRepository extends AbstractComponent implements
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void verify(String seed) {
|
public void verify(String seed) {
|
||||||
BlobContainer testBlobContainer = blobStore.blobContainer(basePath);
|
BlobContainer testBlobContainer = blobStore.blobContainer(basePath.add(testBlobPrefix(seed)));
|
||||||
DiscoveryNode localNode = clusterService.localNode();
|
DiscoveryNode localNode = clusterService.localNode();
|
||||||
if (testBlobContainer.blobExists(testBlobPrefix(seed) + "-master")) {
|
if (testBlobContainer.blobExists("master.dat")) {
|
||||||
try (OutputStream outputStream = testBlobContainer.createOutput(testBlobPrefix(seed) + "-" + localNode.getId())) {
|
try (OutputStream outputStream = testBlobContainer.createOutput("data-" + localNode.getId() + ".dat")) {
|
||||||
outputStream.write(Strings.toUTF8Bytes(seed));
|
outputStream.write(Strings.toUTF8Bytes(seed));
|
||||||
} catch (IOException exp) {
|
} catch (IOException exp) {
|
||||||
throw new RepositoryVerificationException(repositoryName, "store location [" + blobStore + "] is not accessible on the node [" + localNode + "]", exp);
|
throw new RepositoryVerificationException(repositoryName, "store location [" + blobStore + "] is not accessible on the node [" + localNode + "]", exp);
|
||||||
|
@ -624,12 +624,13 @@ public abstract class BlobStoreRepository extends AbstractLifecycleComponent<Rep
|
|||||||
try {
|
try {
|
||||||
String seed = Strings.randomBase64UUID();
|
String seed = Strings.randomBase64UUID();
|
||||||
byte[] testBytes = Strings.toUTF8Bytes(seed);
|
byte[] testBytes = Strings.toUTF8Bytes(seed);
|
||||||
String blobName = testBlobPrefix(seed) + "-master";
|
BlobContainer testContainer = blobStore().blobContainer(basePath().add(testBlobPrefix(seed)));
|
||||||
try (OutputStream outputStream = snapshotsBlobContainer.createOutput(blobName + "-temp")) {
|
String blobName = "master.dat";
|
||||||
|
try (OutputStream outputStream = testContainer.createOutput(blobName + "-temp")) {
|
||||||
outputStream.write(testBytes);
|
outputStream.write(testBytes);
|
||||||
}
|
}
|
||||||
// Make sure that move is supported
|
// Make sure that move is supported
|
||||||
snapshotsBlobContainer.move(blobName + "-temp", blobName);
|
testContainer.move(blobName + "-temp", blobName);
|
||||||
return seed;
|
return seed;
|
||||||
} catch (IOException exp) {
|
} catch (IOException exp) {
|
||||||
throw new RepositoryVerificationException(repositoryName, "path " + basePath() + " is not accessible on master node", exp);
|
throw new RepositoryVerificationException(repositoryName, "path " + basePath() + " is not accessible on master node", exp);
|
||||||
@ -639,7 +640,7 @@ public abstract class BlobStoreRepository extends AbstractLifecycleComponent<Rep
|
|||||||
@Override
|
@Override
|
||||||
public void endVerification(String seed) {
|
public void endVerification(String seed) {
|
||||||
try {
|
try {
|
||||||
snapshotsBlobContainer.deleteBlobsByPrefix(testBlobPrefix(seed));
|
blobStore().delete(basePath().add(testBlobPrefix(seed)));
|
||||||
} catch (IOException exp) {
|
} catch (IOException exp) {
|
||||||
throw new RepositoryVerificationException(repositoryName, "cannot delete test data at " + basePath(), exp);
|
throw new RepositoryVerificationException(repositoryName, "cannot delete test data at " + basePath(), exp);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user