Skip to content

Commit 713698a

Browse files
Provide an Option to Use Path-Style-Access with S3 Repo
* As discussed, added the option to use path style access back again and deprecated it. * Defaulted to `false` * Added warning to docs * Closes elastic#41816
1 parent 7276fb6 commit 713698a

File tree

4 files changed

+31
-9
lines changed

4 files changed

+31
-9
lines changed

docs/plugins/repository-s3.asciidoc

+11-4
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,17 @@ settings belong in the `elasticsearch.yml` file.
145145
Whether retries should be throttled (i.e. should back off). Must be `true`
146146
or `false`. Defaults to `true`.
147147

148+
`path_style_access`::
149+
150+
Whether to use the path style access pattern. Defaults to `false`.
151+
152+
NOTE: This setting is deprecated and only intended as a stop-gap solution to provide
153+
compatibility with alternative S3 implementations that do not provide compatibility with the domain style access pattern.
154+
AWS S3 will stop supporting the path style access pattern from
155+
https://forums.aws.amazon.com/ann.jspa?annID=6776[September 30th, 2020]. Releases of Elasticsearch will likely stop supporting
156+
this setting before that data. Any setups using the path style access pattern should be switched to the domain style access pattern
157+
as soon as possible to ensure continued compatibility with the S3 repository plugin.
158+
148159
[float]
149160
[[repository-s3-compatible-services]]
150161
===== S3-compatible services
@@ -381,10 +392,6 @@ bucket, in this example, named "foo".
381392
The bucket needs to exist to register a repository for snapshots. If you did not
382393
create the bucket then the repository registration will fail.
383394

384-
Note: Starting in version 7.0, all bucket operations are using the path style
385-
access pattern. In previous versions the decision to use virtual hosted style or
386-
path style access was made by the AWS Java SDK.
387-
388395
[[repository-s3-aws-vpc]]
389396
[float]
390397
==== AWS VPC Bandwidth Settings

plugins/repository-s3/src/main/java/org/elasticsearch/repositories/s3/S3ClientSettings.java

+15-3
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ final class S3ClientSettings {
9595
static final Setting.AffixSetting<Boolean> USE_THROTTLE_RETRIES_SETTING = Setting.affixKeySetting(PREFIX, "use_throttle_retries",
9696
key -> Setting.boolSetting(key, ClientConfiguration.DEFAULT_THROTTLE_RETRIES, Property.NodeScope));
9797

98+
/** Whether the s3 client should use path style access. */
99+
static final Setting.AffixSetting<Boolean> USE_PATH_STYLE_ACCESS = Setting.affixKeySetting(PREFIX, "path_style_access",
100+
key -> Setting.boolSetting(key, false, Property.NodeScope, Property.Deprecated));
101+
98102
/** Credentials to authenticate with s3. */
99103
final S3BasicCredentials credentials;
100104

@@ -127,9 +131,13 @@ final class S3ClientSettings {
127131
/** Whether the s3 client should use an exponential backoff retry policy. */
128132
final boolean throttleRetries;
129133

134+
/** Whether the s3 client should use path style access. */
135+
final boolean pathStyleAccess;
136+
130137
private S3ClientSettings(S3BasicCredentials credentials, String endpoint, Protocol protocol,
131138
String proxyHost, int proxyPort, String proxyUsername, String proxyPassword,
132-
int readTimeoutMillis, int maxRetries, boolean throttleRetries) {
139+
int readTimeoutMillis, int maxRetries, boolean throttleRetries,
140+
boolean pathStyleAccess) {
133141
this.credentials = credentials;
134142
this.endpoint = endpoint;
135143
this.protocol = protocol;
@@ -140,6 +148,7 @@ private S3ClientSettings(S3BasicCredentials credentials, String endpoint, Protoc
140148
this.readTimeoutMillis = readTimeoutMillis;
141149
this.maxRetries = maxRetries;
142150
this.throttleRetries = throttleRetries;
151+
this.pathStyleAccess = pathStyleAccess;
143152
}
144153

145154
/**
@@ -162,6 +171,7 @@ S3ClientSettings refine(RepositoryMetaData metadata) {
162171
getRepoSettingOrDefault(READ_TIMEOUT_SETTING, normalizedSettings, TimeValue.timeValueMillis(readTimeoutMillis)).millis());
163172
final int newMaxRetries = getRepoSettingOrDefault(MAX_RETRIES_SETTING, normalizedSettings, maxRetries);
164173
final boolean newThrottleRetries = getRepoSettingOrDefault(USE_THROTTLE_RETRIES_SETTING, normalizedSettings, throttleRetries);
174+
final boolean usePathStyleAccess = getRepoSettingOrDefault(USE_PATH_STYLE_ACCESS, normalizedSettings, pathStyleAccess);
165175
final S3BasicCredentials newCredentials;
166176
if (checkDeprecatedCredentials(repoSettings)) {
167177
newCredentials = loadDeprecatedCredentials(repoSettings);
@@ -183,7 +193,8 @@ S3ClientSettings refine(RepositoryMetaData metadata) {
183193
proxyPassword,
184194
newReadTimeoutMillis,
185195
newMaxRetries,
186-
newThrottleRetries
196+
newThrottleRetries,
197+
usePathStyleAccess
187198
);
188199
}
189200

@@ -270,7 +281,8 @@ static S3ClientSettings getClientSettings(final Settings settings, final String
270281
proxyPassword.toString(),
271282
Math.toIntExact(getConfigValue(settings, clientName, READ_TIMEOUT_SETTING).millis()),
272283
getConfigValue(settings, clientName, MAX_RETRIES_SETTING),
273-
getConfigValue(settings, clientName, USE_THROTTLE_RETRIES_SETTING)
284+
getConfigValue(settings, clientName, USE_THROTTLE_RETRIES_SETTING),
285+
getConfigValue(settings, clientName, USE_PATH_STYLE_ACCESS)
274286
);
275287
}
276288
}

plugins/repository-s3/src/main/java/org/elasticsearch/repositories/s3/S3RepositoryPlugin.java

+1
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ public List<Setting<?>> getSettings() {
105105
S3ClientSettings.READ_TIMEOUT_SETTING,
106106
S3ClientSettings.MAX_RETRIES_SETTING,
107107
S3ClientSettings.USE_THROTTLE_RETRIES_SETTING,
108+
S3ClientSettings.USE_PATH_STYLE_ACCESS,
108109
S3Repository.ACCESS_KEY_SETTING,
109110
S3Repository.SECRET_KEY_SETTING);
110111
}

plugins/repository-s3/src/main/java/org/elasticsearch/repositories/s3/S3Service.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,10 @@ AmazonS3 buildClient(final S3ClientSettings clientSettings) {
153153
//
154154
// We do this because directly constructing the client is deprecated (was already deprecated in 1.1.223 too)
155155
// so this change removes that usage of a deprecated API.
156-
builder.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(endpoint, null))
157-
.enablePathStyleAccess();
156+
builder.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(endpoint, null));
157+
if (clientSettings.pathStyleAccess) {
158+
builder.enablePathStyleAccess();
159+
}
158160

159161
return builder.build();
160162
}

0 commit comments

Comments
 (0)