Fix Azure repository with only one primary account
Using a single azure account is now rejected. This commit fixes this issue and adds a test for it. This regression was introduced with #13779. Hopefully no elasticsearch version has been released since then. Needs to be merged in 2.2, 2.x and master branches.
This commit is contained in:
parent
dc51dd0056
commit
ed45ad6327
|
@ -90,8 +90,8 @@ public class AzureStorageServiceImpl extends AbstractLifecycleComponent<AzureSto
|
|||
logger.trace("selecting a client for account [{}], mode [{}]", account, mode.name());
|
||||
AzureStorageSettings azureStorageSettings = null;
|
||||
|
||||
if (this.primaryStorageSettings == null || this.secondariesStorageSettings.isEmpty()) {
|
||||
throw new IllegalArgumentException("No azure storage can be found. Check your elasticsearch.yml.");
|
||||
if (this.primaryStorageSettings == null) {
|
||||
throw new IllegalArgumentException("No primary azure storage can be found. Check your elasticsearch.yml.");
|
||||
}
|
||||
|
||||
if (account != null) {
|
||||
|
|
|
@ -47,10 +47,20 @@ public class AzureStorageServiceTest extends ESTestCase {
|
|||
azureStorageService.getSelectedClient("whatever", LocationMode.PRIMARY_ONLY);
|
||||
fail("we should have raised an IllegalArgumentException");
|
||||
} catch (IllegalArgumentException e) {
|
||||
assertThat(e.getMessage(), is("No azure storage can be found. Check your elasticsearch.yml."));
|
||||
assertThat(e.getMessage(), is("No primary azure storage can be found. Check your elasticsearch.yml."));
|
||||
}
|
||||
}
|
||||
|
||||
public void testGetSelectedClientWithNoSecondary() {
|
||||
AzureStorageServiceImpl azureStorageService = new AzureStorageServiceMock(Settings.builder()
|
||||
.put("cloud.azure.storage.azure1.account", "myaccount1")
|
||||
.put("cloud.azure.storage.azure1.key", "mykey1")
|
||||
.build());
|
||||
azureStorageService.doStart();
|
||||
CloudBlobClient client = azureStorageService.getSelectedClient("azure1", LocationMode.PRIMARY_ONLY);
|
||||
assertThat(client.getEndpoint(), is(URI.create("https://azure1")));
|
||||
}
|
||||
|
||||
public void testGetSelectedClientPrimary() {
|
||||
AzureStorageServiceImpl azureStorageService = new AzureStorageServiceMock(settings);
|
||||
azureStorageService.doStart();
|
||||
|
|
Loading…
Reference in New Issue