Skip to content

Commit b01b1c2

Browse files
authored
Remove azure deprecated settings (#26099)
Follow up for #23405. We remove azure deprecated settings in 7.0: * The legacy azure settings which where starting with `cloud.azure.storage.` prefix have been removed. This includes `account`, `key`, `default` and `timeout`. You need to use settings which are starting with `azure.client.` prefix instead. * Global timeout setting `cloud.azure.storage.timeout` has been removed. You must set it per azure client instead. Like `azure.client.default.timeout: 10s` for example.
1 parent 0e57a41 commit b01b1c2

File tree

11 files changed

+32
-537
lines changed

11 files changed

+32
-537
lines changed

docs/plugins/repository-azure.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ before retrying after a first timeout or failure. The maximum backoff period is
4646

4747
[source,yaml]
4848
----
49-
cloud.azure.storage.timeout: 10s
49+
azure.client.default.timeout: 10s
5050
azure.client.default.max_retries: 7
5151
azure.client.secondary.timeout: 30s
5252
----

docs/reference/migration/migrate_7_0.asciidoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,11 @@ way to reindex old indices is to use the `reindex` API.
2929
* <<breaking_70_indices_changes>>
3030
* <<breaking_70_mappings_changes>>
3131
* <<breaking_70_search_changes>>
32+
* <<breaking_70_plugins_changes>>
3233

3334
include::migrate_7_0/aggregations.asciidoc[]
3435
include::migrate_7_0/cluster.asciidoc[]
3536
include::migrate_7_0/indices.asciidoc[]
3637
include::migrate_7_0/mappings.asciidoc[]
3738
include::migrate_7_0/search.asciidoc[]
39+
include::migrate_7_0/plugins.asciidoc[]
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[[breaking_70_plugins_changes]]
2+
=== Plugins changes
3+
4+
==== Azure Repository plugin
5+
6+
* The legacy azure settings which where starting with `cloud.azure.storage.` prefix have been removed.
7+
This includes `account`, `key`, `default` and `timeout`.
8+
You need to use settings which are starting with `azure.client.` prefix instead.
9+
10+
* Global timeout setting `cloud.azure.storage.timeout` has been removed.
11+
You must set it per azure client instead. Like `azure.client.default.timeout: 10s` for example.
12+
13+
See {plugins}/repository-azure-usage.html#repository-azure-repository-settings[Azure Repository settings].
14+

plugins/repository-azure/build.gradle

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ thirdPartyAudit.excludes = [
4343
]
4444

4545
integTestCluster {
46-
setting 'cloud.azure.storage.my_account_test.account', 'cloudazureresource'
47-
setting 'cloud.azure.storage.my_account_test.key', 'abcdefgh'
4846
keystoreSetting 'azure.client.default.account', 'cloudazureresource'
4947
keystoreSetting 'azure.client.default.key', 'abcdefgh'
5048
keystoreSetting 'azure.client.secondary.account', 'cloudazureresource'

plugins/repository-azure/src/main/java/org/elasticsearch/cloud/azure/storage/AzureStorageService.java

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,8 @@
2222
import com.microsoft.azure.storage.LocationMode;
2323
import com.microsoft.azure.storage.StorageException;
2424
import org.elasticsearch.common.blobstore.BlobMetaData;
25-
import org.elasticsearch.common.settings.Setting;
26-
import org.elasticsearch.common.settings.Setting.Property;
27-
import org.elasticsearch.common.settings.Settings;
2825
import org.elasticsearch.common.unit.ByteSizeUnit;
2926
import org.elasticsearch.common.unit.ByteSizeValue;
30-
import org.elasticsearch.common.unit.TimeValue;
3127

3228
import java.io.IOException;
3329
import java.io.InputStream;
@@ -44,22 +40,6 @@ public interface AzureStorageService {
4440
ByteSizeValue MIN_CHUNK_SIZE = new ByteSizeValue(1, ByteSizeUnit.BYTES);
4541
ByteSizeValue MAX_CHUNK_SIZE = new ByteSizeValue(64, ByteSizeUnit.MB);
4642

47-
final class Storage {
48-
@Deprecated
49-
public static final String PREFIX = "cloud.azure.storage.";
50-
51-
@Deprecated
52-
public static final Setting<Settings> STORAGE_ACCOUNTS = Setting.groupSetting(Storage.PREFIX, Setting.Property.NodeScope);
53-
54-
/**
55-
* Azure timeout (defaults to -1 minute)
56-
* @deprecated We don't want to support global timeout settings anymore
57-
*/
58-
@Deprecated
59-
static final Setting<TimeValue> TIMEOUT_SETTING =
60-
Setting.timeSetting("cloud.azure.storage.timeout", TimeValue.timeValueMinutes(-1), Property.NodeScope, Property.Deprecated);
61-
}
62-
6343
boolean doesContainerExist(String account, LocationMode mode, String container);
6444

6545
void removeContainer(String account, LocationMode mode, String container) throws URISyntaxException, StorageException;

plugins/repository-azure/src/main/java/org/elasticsearch/cloud/azure/storage/AzureStorageServiceImpl.java

Lines changed: 12 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,9 @@
3333
import org.apache.logging.log4j.message.ParameterizedMessage;
3434
import org.apache.logging.log4j.util.Supplier;
3535
import org.elasticsearch.cloud.azure.blobstore.util.SocketAccess;
36-
import org.elasticsearch.common.Strings;
3736
import org.elasticsearch.common.blobstore.BlobMetaData;
3837
import org.elasticsearch.common.blobstore.support.PlainBlobMetaData;
3938
import org.elasticsearch.common.collect.MapBuilder;
40-
import org.elasticsearch.common.collect.Tuple;
4139
import org.elasticsearch.common.component.AbstractComponent;
4240
import org.elasticsearch.common.settings.Settings;
4341
import org.elasticsearch.repositories.RepositoryException;
@@ -53,53 +51,26 @@
5351
public class AzureStorageServiceImpl extends AbstractComponent implements AzureStorageService {
5452

5553
final Map<String, AzureStorageSettings> storageSettings;
56-
final Map<String, AzureStorageSettings> deprecatedStorageSettings;
5754

58-
final Map<String, CloudBlobClient> clients;
55+
final Map<String, CloudBlobClient> clients = new HashMap<>();
5956

60-
public AzureStorageServiceImpl(Settings settings, Map<String, AzureStorageSettings> regularStorageSettings) {
57+
public AzureStorageServiceImpl(Settings settings, Map<String, AzureStorageSettings> storageSettings) {
6158
super(settings);
6259

63-
if (regularStorageSettings.isEmpty()) {
64-
this.storageSettings = new HashMap<>();
65-
// We have deprecated settings so we need to migrate them to the new implementation
66-
Tuple<AzureStorageSettings, Map<String, AzureStorageSettings>> storageSettingsMapTuple = AzureStorageSettings.loadLegacy(settings);
67-
deprecatedStorageSettings = storageSettingsMapTuple.v2();
68-
if (storageSettingsMapTuple.v1() != null) {
69-
if (storageSettingsMapTuple.v1().getName().equals("default") == false) {
70-
// We add the primary configuration to the list of all settings with its deprecated name in case someone is
71-
// forcing a specific configuration name when creating the repository instance
72-
deprecatedStorageSettings.put(storageSettingsMapTuple.v1().getName(), storageSettingsMapTuple.v1());
73-
}
74-
// We add the primary configuration to the list of all settings as the "default" one
75-
deprecatedStorageSettings.put("default", storageSettingsMapTuple.v1());
76-
} else {
77-
// If someone did not register any settings or deprecated settings, they
78-
// basically can't use the plugin
79-
throw new IllegalArgumentException("If you want to use an azure repository, you need to define a client configuration.");
80-
}
81-
60+
this.storageSettings = storageSettings;
8261

83-
} else {
84-
this.storageSettings = regularStorageSettings;
85-
this.deprecatedStorageSettings = new HashMap<>();
62+
if (storageSettings.isEmpty()) {
63+
// If someone did not register any settings, they basically can't use the plugin
64+
throw new IllegalArgumentException("If you want to use an azure repository, you need to define a client configuration.");
8665
}
8766

88-
this.clients = new HashMap<>();
89-
9067
logger.debug("starting azure storage client instance");
9168

9269
// We register all regular azure clients
9370
for (Map.Entry<String, AzureStorageSettings> azureStorageSettingsEntry : this.storageSettings.entrySet()) {
9471
logger.debug("registering regular client for account [{}]", azureStorageSettingsEntry.getKey());
9572
createClient(azureStorageSettingsEntry.getValue());
9673
}
97-
98-
// We register all deprecated azure clients
99-
for (Map.Entry<String, AzureStorageSettings> azureStorageSettingsEntry : this.deprecatedStorageSettings.entrySet()) {
100-
logger.debug("registering deprecated client for account [{}]", azureStorageSettingsEntry.getKey());
101-
createClient(azureStorageSettingsEntry.getValue());
102-
}
10374
}
10475

10576
void createClient(AzureStorageSettings azureStorageSettings) {
@@ -125,31 +96,21 @@ void createClient(AzureStorageSettings azureStorageSettings) {
12596
}
12697
}
12798

128-
CloudBlobClient getSelectedClient(String account, LocationMode mode) {
129-
logger.trace("selecting a client for account [{}], mode [{}]", account, mode.name());
130-
AzureStorageSettings azureStorageSettings = this.storageSettings.get(account);
99+
CloudBlobClient getSelectedClient(String clientName, LocationMode mode) {
100+
logger.trace("selecting a client named [{}], mode [{}]", clientName, mode.name());
101+
AzureStorageSettings azureStorageSettings = this.storageSettings.get(clientName);
131102
if (azureStorageSettings == null) {
132-
// We can't find a client that has been registered using regular settings so we try deprecated client
133-
azureStorageSettings = this.deprecatedStorageSettings.get(account);
134-
if (azureStorageSettings == null) {
135-
// We did not get an account. That's bad.
136-
if (Strings.hasLength(account)) {
137-
throw new IllegalArgumentException("Can not find named azure client [" + account +
138-
"]. Check your elasticsearch.yml.");
139-
}
140-
throw new IllegalArgumentException("Can not find primary/secondary client using deprecated settings. " +
141-
"Check your elasticsearch.yml.");
142-
}
103+
throw new IllegalArgumentException("Can not find named azure client [" + clientName + "]. Check your settings.");
143104
}
144105

145106
CloudBlobClient client = this.clients.get(azureStorageSettings.getAccount());
146107

147108
if (client == null) {
148-
throw new IllegalArgumentException("Can not find an azure client for account [" + azureStorageSettings.getAccount() + "]");
109+
throw new IllegalArgumentException("Can not find an azure client named [" + azureStorageSettings.getAccount() + "]");
149110
}
150111

151112
// NOTE: for now, just set the location mode in case it is different;
152-
// only one mode per storage account can be active at a time
113+
// only one mode per storage clientName can be active at a time
153114
client.getDefaultRequestOptions().setLocationMode(mode);
154115

155116
// Set timeout option if the user sets cloud.azure.storage.timeout or cloud.azure.storage.xxx.timeout (it's negative by default)

plugins/repository-azure/src/main/java/org/elasticsearch/cloud/azure/storage/AzureStorageSettings.java

Lines changed: 1 addition & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,19 @@
2020
package org.elasticsearch.cloud.azure.storage;
2121

2222
import com.microsoft.azure.storage.RetryPolicy;
23-
import org.elasticsearch.cloud.azure.storage.AzureStorageService.Storage;
24-
import org.elasticsearch.common.collect.Tuple;
2523
import org.elasticsearch.common.settings.SecureSetting;
2624
import org.elasticsearch.common.settings.SecureString;
2725
import org.elasticsearch.common.settings.Setting;
2826
import org.elasticsearch.common.settings.Setting.AffixSetting;
2927
import org.elasticsearch.common.settings.Setting.Property;
3028
import org.elasticsearch.common.settings.Settings;
31-
import org.elasticsearch.common.settings.SettingsException;
3229
import org.elasticsearch.common.unit.TimeValue;
3330

34-
import java.util.ArrayList;
3531
import java.util.Collections;
3632
import java.util.HashMap;
37-
import java.util.List;
3833
import java.util.Map;
3934
import java.util.Set;
4035

41-
import static org.elasticsearch.cloud.azure.storage.AzureStorageService.Storage.STORAGE_ACCOUNTS;
42-
4336
public final class AzureStorageSettings {
4437
// prefix for azure client settings
4538
private static final String PREFIX = "azure.client.";
@@ -64,56 +57,20 @@ public final class AzureStorageSettings {
6457
key -> SecureSetting.secureString(key, null));
6558

6659
public static final AffixSetting<TimeValue> TIMEOUT_SETTING = Setting.affixKeySetting(PREFIX, "timeout",
67-
(key) -> Setting.timeSetting(key, Storage.TIMEOUT_SETTING, Property.NodeScope));
68-
69-
70-
@Deprecated
71-
public static final Setting<TimeValue> DEPRECATED_TIMEOUT_SETTING = Setting.affixKeySetting(Storage.PREFIX, "timeout",
72-
(key) -> Setting.timeSetting(key, Storage.TIMEOUT_SETTING, Property.NodeScope, Property.Deprecated));
73-
@Deprecated
74-
public static final Setting<String> DEPRECATED_ACCOUNT_SETTING = Setting.affixKeySetting(Storage.PREFIX, "account",
75-
(key) -> Setting.simpleString(key, Property.NodeScope, Property.Deprecated));
76-
@Deprecated
77-
public static final Setting<String> DEPRECATED_KEY_SETTING = Setting.affixKeySetting(Storage.PREFIX, "key",
78-
(key) -> Setting.simpleString(key, Property.NodeScope, Property.Deprecated));
79-
@Deprecated
80-
public static final Setting<Boolean> DEPRECATED_DEFAULT_SETTING = Setting.affixKeySetting(Storage.PREFIX, "default",
81-
(key) -> Setting.boolSetting(key, false, Property.NodeScope, Property.Deprecated));
82-
60+
(key) -> Setting.timeSetting(key, TimeValue.timeValueMinutes(-1), Property.NodeScope));
8361

84-
@Deprecated
85-
private final String name;
8662
private final String account;
8763
private final String key;
8864
private final TimeValue timeout;
89-
@Deprecated
90-
private final boolean activeByDefault;
9165
private final int maxRetries;
9266

9367
public AzureStorageSettings(String account, String key, TimeValue timeout, int maxRetries) {
94-
this.name = null;
95-
this.account = account;
96-
this.key = key;
97-
this.timeout = timeout;
98-
this.activeByDefault = false;
99-
this.maxRetries = maxRetries;
100-
}
101-
102-
@Deprecated
103-
public AzureStorageSettings(String name, String account, String key, TimeValue timeout, boolean activeByDefault, int maxRetries) {
104-
this.name = name;
10568
this.account = account;
10669
this.key = key;
10770
this.timeout = timeout;
108-
this.activeByDefault = activeByDefault;
10971
this.maxRetries = maxRetries;
11072
}
11173

112-
@Deprecated
113-
public String getName() {
114-
return name;
115-
}
116-
11774
public String getKey() {
11875
return key;
11976
}
@@ -126,39 +83,21 @@ public TimeValue getTimeout() {
12683
return timeout;
12784
}
12885

129-
@Deprecated
130-
public Boolean isActiveByDefault() {
131-
return activeByDefault;
132-
}
133-
13486
public int getMaxRetries() {
13587
return maxRetries;
13688
}
13789

13890
@Override
13991
public String toString() {
14092
final StringBuilder sb = new StringBuilder("AzureStorageSettings{");
141-
sb.append("name='").append(name).append('\'');
14293
sb.append(", account='").append(account).append('\'');
14394
sb.append(", key='").append(key).append('\'');
144-
sb.append(", activeByDefault='").append(activeByDefault).append('\'');
14595
sb.append(", timeout=").append(timeout);
14696
sb.append(", maxRetries=").append(maxRetries);
14797
sb.append('}');
14898
return sb.toString();
14999
}
150100

151-
/**
152-
* Parses settings and read all legacy settings available under cloud.azure.storage.*
153-
* @param settings settings to parse
154-
* @return A tuple with v1 = primary storage and v2 = secondary storage
155-
*/
156-
@Deprecated
157-
public static Tuple<AzureStorageSettings, Map<String, AzureStorageSettings>> loadLegacy(Settings settings) {
158-
List<AzureStorageSettings> storageSettings = createStorageSettingsDeprecated(settings);
159-
return Tuple.tuple(getPrimary(storageSettings), getSecondaries(storageSettings));
160-
}
161-
162101
/**
163102
* Parses settings and read all settings available under azure.client.*
164103
* @param settings settings to parse
@@ -192,25 +131,6 @@ static AzureStorageSettings getClientSettings(Settings settings, String clientNa
192131
}
193132
}
194133

195-
@Deprecated
196-
private static List<AzureStorageSettings> createStorageSettingsDeprecated(Settings settings) {
197-
// ignore global timeout which has the same prefix but does not belong to any group
198-
Settings groups = STORAGE_ACCOUNTS.get(settings.filter((k) -> k.equals(Storage.TIMEOUT_SETTING.getKey()) == false));
199-
List<AzureStorageSettings> storageSettings = new ArrayList<>();
200-
for (String groupName : groups.getAsGroups().keySet()) {
201-
storageSettings.add(
202-
new AzureStorageSettings(
203-
groupName,
204-
getValue(settings, groupName, DEPRECATED_ACCOUNT_SETTING),
205-
getValue(settings, groupName, DEPRECATED_KEY_SETTING),
206-
getValue(settings, groupName, DEPRECATED_TIMEOUT_SETTING),
207-
getValue(settings, groupName, DEPRECATED_DEFAULT_SETTING),
208-
getValue(settings, groupName, MAX_RETRIES_SETTING))
209-
);
210-
}
211-
return storageSettings;
212-
}
213-
214134
private static <T> T getConfigValue(Settings settings, String clientName,
215135
Setting.AffixSetting<T> clientSetting) {
216136
Setting<T> concreteSetting = clientSetting.getConcreteSettingForNamespace(clientName);
@@ -222,45 +142,4 @@ public static <T> T getValue(Settings settings, String groupName, Setting<T> set
222142
String fullKey = k.toConcreteKey(groupName).toString();
223143
return setting.getConcreteSetting(fullKey).get(settings);
224144
}
225-
226-
@Deprecated
227-
private static AzureStorageSettings getPrimary(List<AzureStorageSettings> settings) {
228-
if (settings.isEmpty()) {
229-
return null;
230-
} else if (settings.size() == 1) {
231-
// the only storage settings belong (implicitly) to the default primary storage
232-
AzureStorageSettings storage = settings.get(0);
233-
return new AzureStorageSettings(storage.getName(), storage.getAccount(), storage.getKey(), storage.getTimeout(), true,
234-
storage.getMaxRetries());
235-
} else {
236-
AzureStorageSettings primary = null;
237-
for (AzureStorageSettings setting : settings) {
238-
if (setting.isActiveByDefault()) {
239-
if (primary == null) {
240-
primary = setting;
241-
} else {
242-
throw new SettingsException("Multiple default Azure data stores configured: [" + primary.getName() + "] and [" + setting.getName() + "]");
243-
}
244-
}
245-
}
246-
if (primary == null) {
247-
throw new SettingsException("No default Azure data store configured");
248-
}
249-
return primary;
250-
}
251-
}
252-
253-
@Deprecated
254-
private static Map<String, AzureStorageSettings> getSecondaries(List<AzureStorageSettings> settings) {
255-
Map<String, AzureStorageSettings> secondaries = new HashMap<>();
256-
// when only one setting is defined, we don't have secondaries
257-
if (settings.size() > 1) {
258-
for (AzureStorageSettings setting : settings) {
259-
if (setting.isActiveByDefault() == false) {
260-
secondaries.put(setting.getName(), setting);
261-
}
262-
}
263-
}
264-
return secondaries;
265-
}
266145
}

0 commit comments

Comments
 (0)