Skip to content

Commit

Permalink
increase the wait timeout to fetch the master key (#3151) (#3178)
Browse files Browse the repository at this point in the history
* increase the wait timeout to fetch the master key

Signed-off-by: Jing Zhang <[email protected]>

* fix UTs

Signed-off-by: Jing Zhang <[email protected]>

---------

Signed-off-by: Jing Zhang <[email protected]>
  • Loading branch information
opensearch-trigger-bot[bot] authored and jngz-es committed Nov 13, 2024
1 parent 00aea6a commit 587ec83
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,10 @@ private void initMasterKey() {
}

try {
latch.await(5, SECONDS);
boolean completed = latch.await(3, SECONDS);
if (!completed) {
throw new MLException("Fetching master key timed out.");
}
} catch (InterruptedException e) {
throw new IllegalStateException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ public void decrypt() {

@Test
public void encrypt_NullMasterKey_NullMasterKey_MasterKeyNotExistInIndex() {
exceptionRule.expect(ResourceNotFoundException.class);
exceptionRule.expectMessage(MASTER_KEY_NOT_READY_ERROR);
exceptionRule.expect(MLException.class);
exceptionRule.expectMessage("Fetching master key timed out.");

doAnswer(invocation -> {
ActionListener<GetResponse> listener = invocation.getArgument(1);
Expand Down Expand Up @@ -165,8 +165,8 @@ public void decrypt_NullMasterKey_GetMasterKey_Exception() {

@Test
public void decrypt_MLConfigIndexNotFound() {
exceptionRule.expect(ResourceNotFoundException.class);
exceptionRule.expectMessage(MASTER_KEY_NOT_READY_ERROR);
exceptionRule.expect(MLException.class);
exceptionRule.expectMessage("Fetching master key timed out.");

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

0 comments on commit 587ec83

Please sign in to comment.