Remove global `repositories.azure` settings
Today we have multiple ways to define settings when a user needs to create a repository: * in `elasticsearch.yml` file using `repositories.azure` prefix * when creating the repository itself with `PUT _snaphot/repo` The plan is to: * Deprecate `repositories.azure` settings in 5.x (done with #22856) * Remove in 6.x (this PR) Related to #22800
This commit is contained in:
parent
872412f645
commit
da907e7a7d
|
@ -185,22 +185,6 @@ client.admin().cluster().preparePutRepository("my_backup_java1")
|
|||
).get();
|
||||
----
|
||||
|
||||
[[repository-azure-global-settings]]
|
||||
===== Global repositories settings
|
||||
|
||||
All those repository settings can also be defined globally in `elasticsearch.yml` file using prefix
|
||||
`repositories.azure.`. For example:
|
||||
|
||||
[source,yaml]
|
||||
----
|
||||
repositories.azure:
|
||||
container: backup-container
|
||||
base_path: backups
|
||||
chunk_size: 32m
|
||||
compress": true
|
||||
----
|
||||
|
||||
|
||||
[[repository-azure-validation]]
|
||||
===== Repository validation rules
|
||||
|
||||
|
|
|
@ -25,3 +25,11 @@ the region of the configured bucket.
|
|||
|
||||
* The container an azure repository is configured with will no longer be created automatically.
|
||||
It must exist before the azure repository is created.
|
||||
|
||||
* Global repositories settings you are able to set in elasticsearch config file under `repositories.azure`
|
||||
name space have been removed. This includes `repositories.azure.account`, `repositories.azure.container`,
|
||||
`repositories.azure.base_path`, `repositories.azure.location_mode`, `repositories.azure.chunk_size` and
|
||||
`repositories.azure.compress`.
|
||||
You must set those settings per repository instead. Respectively `account`, `container`, `base_path`,
|
||||
`location_mode`, `chunk_size` and `compress`.
|
||||
See {plugins}/repository-azure-usage.html#repository-azure-repository-settings[Azure Repository settings].
|
||||
|
|
|
@ -39,7 +39,6 @@ import java.net.URISyntaxException;
|
|||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.elasticsearch.cloud.azure.storage.AzureStorageSettings.getValue;
|
||||
import static org.elasticsearch.repositories.azure.AzureRepository.Repository;
|
||||
|
||||
public class AzureBlobStore extends AbstractComponent implements BlobStore {
|
||||
|
@ -55,11 +54,11 @@ public class AzureBlobStore extends AbstractComponent implements BlobStore {
|
|||
AzureStorageService client) throws URISyntaxException, StorageException {
|
||||
super(settings);
|
||||
this.client = client;
|
||||
this.container = getValue(metadata.settings(), settings, Repository.CONTAINER_SETTING, Storage.CONTAINER_SETTING);
|
||||
this.container = Repository.CONTAINER_SETTING.get(metadata.settings());
|
||||
this.repositoryName = metadata.name();
|
||||
this.accountName = getValue(metadata.settings(), settings, Repository.ACCOUNT_SETTING, Storage.ACCOUNT_SETTING);
|
||||
this.accountName = Repository.ACCOUNT_SETTING.get(metadata.settings());
|
||||
|
||||
String modeStr = getValue(metadata.settings(), settings, Repository.LOCATION_MODE_SETTING, Storage.LOCATION_MODE_SETTING);
|
||||
String modeStr = Repository.LOCATION_MODE_SETTING.get(metadata.settings());
|
||||
if (Strings.hasLength(modeStr)) {
|
||||
this.locMode = LocationMode.valueOf(modeStr.toUpperCase(Locale.ROOT));
|
||||
} else {
|
||||
|
|
|
@ -21,7 +21,6 @@ package org.elasticsearch.cloud.azure.storage;
|
|||
|
||||
import com.microsoft.azure.storage.LocationMode;
|
||||
import com.microsoft.azure.storage.StorageException;
|
||||
|
||||
import org.elasticsearch.common.blobstore.BlobMetaData;
|
||||
import org.elasticsearch.common.settings.Setting;
|
||||
import org.elasticsearch.common.settings.Setting.Property;
|
||||
|
@ -35,7 +34,6 @@ import java.io.InputStream;
|
|||
import java.io.OutputStream;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* Azure Storage Service interface
|
||||
|
@ -53,18 +51,6 @@ public interface AzureStorageService {
|
|||
|
||||
public static final Setting<TimeValue> TIMEOUT_SETTING =
|
||||
Setting.timeSetting("cloud.azure.storage.timeout", TimeValue.timeValueMinutes(-1), Property.NodeScope);
|
||||
public static final Setting<String> ACCOUNT_SETTING =
|
||||
Setting.simpleString("repositories.azure.account", Property.NodeScope, Property.Filtered);
|
||||
public static final Setting<String> CONTAINER_SETTING =
|
||||
new Setting<>("repositories.azure.container", "elasticsearch-snapshots", Function.identity(), Property.NodeScope);
|
||||
public static final Setting<String> BASE_PATH_SETTING =
|
||||
Setting.simpleString("repositories.azure.base_path", Property.NodeScope);
|
||||
public static final Setting<String> LOCATION_MODE_SETTING =
|
||||
Setting.simpleString("repositories.azure.location_mode", Property.NodeScope);
|
||||
public static final Setting<ByteSizeValue> CHUNK_SIZE_SETTING =
|
||||
Setting.byteSizeSetting("repositories.azure.chunk_size", MAX_CHUNK_SIZE, MIN_CHUNK_SIZE, MAX_CHUNK_SIZE, Property.NodeScope);
|
||||
public static final Setting<Boolean> COMPRESS_SETTING =
|
||||
Setting.boolSetting("repositories.azure.compress", false, Property.NodeScope);
|
||||
}
|
||||
|
||||
boolean doesContainerExist(String account, LocationMode mode, String container);
|
||||
|
|
|
@ -25,14 +25,12 @@ import org.elasticsearch.common.settings.Setting;
|
|||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.settings.SettingsException;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.node.Node;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
public final class AzureStorageSettings {
|
||||
private static final Setting<TimeValue> TIMEOUT_SETTING = Setting.affixKeySetting(Storage.PREFIX, "timeout",
|
||||
|
@ -161,25 +159,4 @@ public final class AzureStorageSettings {
|
|||
}
|
||||
return Collections.unmodifiableMap(secondaries);
|
||||
}
|
||||
|
||||
public static <T> T getValue(Settings repositorySettings,
|
||||
Settings globalSettings,
|
||||
Setting<T> repositorySetting,
|
||||
Setting<T> repositoriesSetting) {
|
||||
if (repositorySetting.exists(repositorySettings)) {
|
||||
return repositorySetting.get(repositorySettings);
|
||||
} else {
|
||||
return repositoriesSetting.get(globalSettings);
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> Setting<T> getEffectiveSetting(Settings repositorySettings,
|
||||
Setting<T> repositorySetting,
|
||||
Setting<T> repositoriesSetting) {
|
||||
if (repositorySetting.exists(repositorySettings)) {
|
||||
return repositorySetting;
|
||||
} else {
|
||||
return repositoriesSetting;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,13 +53,7 @@ public class AzureRepositoryPlugin extends Plugin implements RepositoryPlugin {
|
|||
|
||||
@Override
|
||||
public List<Setting<?>> getSettings() {
|
||||
return Arrays.asList(AzureStorageService.Storage.STORAGE_ACCOUNTS,
|
||||
AzureStorageService.Storage.ACCOUNT_SETTING,
|
||||
AzureStorageService.Storage.COMPRESS_SETTING,
|
||||
AzureStorageService.Storage.CONTAINER_SETTING,
|
||||
AzureStorageService.Storage.BASE_PATH_SETTING,
|
||||
AzureStorageService.Storage.CHUNK_SIZE_SETTING,
|
||||
AzureStorageService.Storage.LOCATION_MODE_SETTING);
|
||||
return Collections.singletonList(AzureStorageService.Storage.STORAGE_ACCOUNTS);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -23,7 +23,6 @@ import com.microsoft.azure.storage.LocationMode;
|
|||
import com.microsoft.azure.storage.StorageException;
|
||||
import org.elasticsearch.cloud.azure.blobstore.AzureBlobStore;
|
||||
import org.elasticsearch.cloud.azure.storage.AzureStorageService;
|
||||
import org.elasticsearch.cloud.azure.storage.AzureStorageService.Storage;
|
||||
import org.elasticsearch.cluster.metadata.MetaData;
|
||||
import org.elasticsearch.cluster.metadata.RepositoryMetaData;
|
||||
import org.elasticsearch.common.Strings;
|
||||
|
@ -46,7 +45,6 @@ import java.util.function.Function;
|
|||
|
||||
import static org.elasticsearch.cloud.azure.storage.AzureStorageService.MAX_CHUNK_SIZE;
|
||||
import static org.elasticsearch.cloud.azure.storage.AzureStorageService.MIN_CHUNK_SIZE;
|
||||
import static org.elasticsearch.cloud.azure.storage.AzureStorageSettings.getValue;
|
||||
|
||||
/**
|
||||
* Azure file system implementation of the BlobStoreRepository
|
||||
|
@ -86,10 +84,10 @@ public class AzureRepository extends BlobStoreRepository {
|
|||
super(metadata, environment.settings(), namedXContentRegistry);
|
||||
|
||||
blobStore = new AzureBlobStore(metadata, environment.settings(), storageService);
|
||||
String container = getValue(metadata.settings(), settings, Repository.CONTAINER_SETTING, Storage.CONTAINER_SETTING);
|
||||
this.chunkSize = getValue(metadata.settings(), settings, Repository.CHUNK_SIZE_SETTING, Storage.CHUNK_SIZE_SETTING);
|
||||
this.compress = getValue(metadata.settings(), settings, Repository.COMPRESS_SETTING, Storage.COMPRESS_SETTING);
|
||||
String modeStr = getValue(metadata.settings(), settings, Repository.LOCATION_MODE_SETTING, Storage.LOCATION_MODE_SETTING);
|
||||
String container = Repository.CONTAINER_SETTING.get(metadata.settings());
|
||||
this.chunkSize = Repository.CHUNK_SIZE_SETTING.get(metadata.settings());
|
||||
this.compress = Repository.COMPRESS_SETTING.get(metadata.settings());
|
||||
String modeStr = Repository.LOCATION_MODE_SETTING.get(metadata.settings());
|
||||
Boolean forcedReadonly = metadata.settings().getAsBoolean("readonly", null);
|
||||
// If the user explicitly did not define a readonly value, we set it by ourselves depending on the location mode setting.
|
||||
// For secondary_only setting, the repository should be read only
|
||||
|
@ -104,7 +102,7 @@ public class AzureRepository extends BlobStoreRepository {
|
|||
readonly = forcedReadonly;
|
||||
}
|
||||
|
||||
String basePath = getValue(metadata.settings(), settings, Repository.BASE_PATH_SETTING, Storage.BASE_PATH_SETTING);
|
||||
String basePath = Repository.BASE_PATH_SETTING.get(metadata.settings());
|
||||
|
||||
if (Strings.hasLength(basePath)) {
|
||||
// Remove starting / if any
|
||||
|
|
Loading…
Reference in New Issue