Skip to content

Commit e140571

Browse files
increase the wait timeout to fetch the master key (opensearch-project#3151) (opensearch-project#3177)
* increase the wait timeout to fetch the master key Signed-off-by: Jing Zhang <jngz@amazon.com> * fix UTs Signed-off-by: Jing Zhang <jngz@amazon.com> --------- Signed-off-by: Jing Zhang <jngz@amazon.com> (cherry picked from commit c7e564c) Co-authored-by: Jing Zhang <jngz@amazon.com>
1 parent e9921e2 commit e140571

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

ml-algorithms/src/main/java/org/opensearch/ml/engine/encryptor/EncryptorImpl.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,10 @@ private void initMasterKey() {
181181
}));
182182

183183
try {
184-
latch.await(1, SECONDS);
184+
boolean completed = latch.await(3, SECONDS);
185+
if (!completed) {
186+
throw new MLException("Fetching master key timed out.");
187+
}
185188
} catch (InterruptedException e) {
186189
throw new IllegalStateException(e);
187190
}

ml-algorithms/src/test/java/org/opensearch/ml/engine/encryptor/EncryptorImplTest.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -462,8 +462,8 @@ public void decrypt() {
462462

463463
@Test
464464
public void encrypt_NullMasterKey_NullMasterKey_MasterKeyNotExistInIndex() {
465-
exceptionRule.expect(ResourceNotFoundException.class);
466-
exceptionRule.expectMessage(MASTER_KEY_NOT_READY_ERROR);
465+
exceptionRule.expect(MLException.class);
466+
exceptionRule.expectMessage("Fetching master key timed out.");
467467

468468
doAnswer(invocation -> {
469469
ActionListener<GetResponse> listener = invocation.getArgument(1);
@@ -517,8 +517,8 @@ public void decrypt_NoResponseToInitConfigIndex() {
517517

518518
@Test
519519
public void decrypt_MLConfigIndexNotFound() {
520-
exceptionRule.expect(ResourceNotFoundException.class);
521-
exceptionRule.expectMessage(MASTER_KEY_NOT_READY_ERROR);
520+
exceptionRule.expect(MLException.class);
521+
exceptionRule.expectMessage("Fetching master key timed out.");
522522

523523
Metadata metadata = new Metadata.Builder().indices(ImmutableMap.of()).build();
524524
when(clusterState.metadata()).thenReturn(metadata);

0 commit comments

Comments
 (0)