Skip to content

Commit 35c2bcf

Browse files
authored
Merge branch 'main' into ES-9767_update_metering_stats_endpoints
2 parents bd0be0e + 5663728 commit 35c2bcf

File tree

17 files changed

+838
-130
lines changed

17 files changed

+838
-130
lines changed

docs/changelog/104125.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
pr: 104125
2+
summary: Disable machine learning on macOS x86_64
3+
area: Machine Learning
4+
type: breaking
5+
issues: []
6+
breaking:
7+
title: Disable machine learning on macOS x86_64
8+
area: Packaging
9+
details: The machine learning plugin is permanently disabled on macOS x86_64.
10+
For the last three years Apple has been selling hardware based on the arm64
11+
architecture, and support will increasingly focus on this architecture in
12+
the future. Changes to upstream dependencies of Elastic's machine learning
13+
functionality have made it unviable for Elastic to continue to build machine
14+
learning on macOS x86_64.
15+
impact: To continue to use machine learning functionality on macOS please switch to
16+
an arm64 machine (Apple silicon). Alternatively, it will still be possible to run
17+
Elasticsearch with machine learning enabled in a Docker container on macOS x86_64.
18+
notable: false

modules/repository-azure/src/internalClusterTest/java/org/elasticsearch/repositories/azure/AzureBlobStoreRepositoryTests.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
package org.elasticsearch.repositories.azure;
1010

1111
import fixture.azure.AzureHttpHandler;
12+
import fixture.azure.MockAzureBlobStore;
1213

1314
import com.azure.storage.common.policy.RequestRetryOptions;
1415
import com.azure.storage.common.policy.RetryPolicyType;
@@ -181,7 +182,12 @@ long getUploadBlockSize() {
181182
@SuppressForbidden(reason = "this test uses a HttpHandler to emulate an Azure endpoint")
182183
private static class AzureBlobStoreHttpHandler extends AzureHttpHandler implements BlobStoreHttpHandler {
183184
AzureBlobStoreHttpHandler(final String account, final String container) {
184-
super(account, container, null /* no auth header validation - sometimes it's omitted in these tests (TODO why?) */);
185+
super(
186+
account,
187+
container,
188+
null /* no auth header validation - sometimes it's omitted in these tests (TODO why?) */,
189+
MockAzureBlobStore.LeaseExpiryPredicate.NEVER_EXPIRE
190+
);
185191
}
186192
}
187193

modules/repository-azure/src/internalClusterTest/java/org/elasticsearch/repositories/azure/AzureStorageCleanupThirdPartyTests.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
package org.elasticsearch.repositories.azure;
1111

1212
import fixture.azure.AzureHttpFixture;
13+
import fixture.azure.MockAzureBlobStore;
1314

1415
import com.azure.core.exception.HttpResponseException;
1516
import com.azure.storage.blob.BlobContainerClient;
@@ -60,7 +61,8 @@ public class AzureStorageCleanupThirdPartyTests extends AbstractThirdPartyReposi
6061
System.getProperty("test.azure.container"),
6162
System.getProperty("test.azure.tenant_id"),
6263
System.getProperty("test.azure.client_id"),
63-
AzureHttpFixture.sharedKeyForAccountPredicate(AZURE_ACCOUNT)
64+
AzureHttpFixture.sharedKeyForAccountPredicate(AZURE_ACCOUNT),
65+
MockAzureBlobStore.LeaseExpiryPredicate.NEVER_EXPIRE
6466
);
6567

6668
@Override

modules/repository-azure/src/main/java/org/elasticsearch/repositories/azure/AzureBlobContainer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ protected String buildKey(String blobName) {
180180
}
181181

182182
private boolean skipRegisterOperation(ActionListener<?> listener) {
183-
return skipCas(listener) || skipIfNotPrimaryOnlyLocationMode(listener);
183+
return skipIfNotPrimaryOnlyLocationMode(listener);
184184
}
185185

186186
private boolean skipIfNotPrimaryOnlyLocationMode(ActionListener<?> listener) {

modules/repository-azure/src/main/java/org/elasticsearch/repositories/azure/AzureBlobStore.java

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import com.azure.storage.blob.models.ListBlobsOptions;
4141
import com.azure.storage.blob.options.BlobParallelUploadOptions;
4242
import com.azure.storage.blob.options.BlockBlobSimpleUploadOptions;
43+
import com.azure.storage.blob.specialized.BlobLeaseClient;
4344
import com.azure.storage.blob.specialized.BlobLeaseClientBuilder;
4445
import com.azure.storage.blob.specialized.BlockBlobAsyncClient;
4546

@@ -1030,7 +1031,7 @@ private static BytesReference innerCompareAndExchangeRegister(
10301031
}
10311032
return currentValue;
10321033
} finally {
1033-
leaseClient.releaseLease();
1034+
bestEffortRelease(leaseClient);
10341035
}
10351036
} else {
10361037
if (expected.length() == 0) {
@@ -1040,6 +1041,29 @@ private static BytesReference innerCompareAndExchangeRegister(
10401041
}
10411042
}
10421043

1044+
/**
1045+
* Release the lease, ignoring conflicts due to expiry
1046+
*
1047+
* @see <a href="https://learn.microsoft.com/en-us/rest/api/storageservices/lease-blob?outcomes-of-lease-operations-on-blobs-by-lease-state">Outcomes of lease operations by lease state</a>
1048+
* @param leaseClient The client for the lease
1049+
*/
1050+
private static void bestEffortRelease(BlobLeaseClient leaseClient) {
1051+
try {
1052+
leaseClient.releaseLease();
1053+
} catch (BlobStorageException blobStorageException) {
1054+
if (blobStorageException.getStatusCode() == RestStatus.CONFLICT.getStatus()) {
1055+
// This is OK, we tried to release a lease that was expired/re-acquired
1056+
logger.debug(
1057+
"Ignored conflict on release: errorCode={}, message={}",
1058+
blobStorageException.getErrorCode(),
1059+
blobStorageException.getMessage()
1060+
);
1061+
} else {
1062+
throw blobStorageException;
1063+
}
1064+
}
1065+
}
1066+
10431067
private static BytesReference downloadRegisterBlob(
10441068
String containerPath,
10451069
String blobKey,

modules/repository-azure/src/test/java/org/elasticsearch/repositories/azure/AzureBlobContainerStatsTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
package org.elasticsearch.repositories.azure;
1111

1212
import fixture.azure.AzureHttpHandler;
13+
import fixture.azure.MockAzureBlobStore;
1314

1415
import org.elasticsearch.common.blobstore.EndpointStats;
1516
import org.elasticsearch.common.blobstore.OperationPurpose;
@@ -27,7 +28,7 @@ public class AzureBlobContainerStatsTests extends AbstractAzureServerTestCase {
2728
@SuppressForbidden(reason = "use a http server")
2829
@Before
2930
public void configureAzureHandler() {
30-
httpServer.createContext("/", new AzureHttpHandler(ACCOUNT, CONTAINER, null));
31+
httpServer.createContext("/", new AzureHttpHandler(ACCOUNT, CONTAINER, null, MockAzureBlobStore.LeaseExpiryPredicate.NEVER_EXPIRE));
3132
}
3233

3334
public void testOperationPurposeIsReflectedInBlobStoreStats() throws IOException {

modules/repository-azure/src/yamlRestTest/java/org/elasticsearch/repositories/azure/RepositoryAzureClientYamlTestSuiteIT.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
package org.elasticsearch.repositories.azure;
1111

1212
import fixture.azure.AzureHttpFixture;
13+
import fixture.azure.MockAzureBlobStore;
1314

1415
import com.carrotsearch.randomizedtesting.annotations.Name;
1516
import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
@@ -47,7 +48,8 @@ public class RepositoryAzureClientYamlTestSuiteIT extends ESClientYamlSuiteTestC
4748
AZURE_TEST_CONTAINER,
4849
AZURE_TEST_TENANT_ID,
4950
AZURE_TEST_CLIENT_ID,
50-
decideAuthHeaderPredicate()
51+
decideAuthHeaderPredicate(),
52+
MockAzureBlobStore.LeaseExpiryPredicate.NEVER_EXPIRE
5153
);
5254

5355
private static Predicate<String> decideAuthHeaderPredicate() {

modules/repository-azure/src/yamlRestTest/resources/rest-api-spec/test/repository_azure/20_repository.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,20 @@ setup:
193193
container: zHHkfSqlbnBsbpSgvCYtxrEfFLqghXtyPvvvKPNBnRCicNHQLE
194194
client: integration_test
195195

196+
---
197+
"Register a read-only repository with a non existing container":
198+
199+
- do:
200+
catch: /repository_verification_exception/
201+
snapshot.create_repository:
202+
repository: repository
203+
body:
204+
type: azure
205+
settings:
206+
container: zHHkfSqlbnBsbpSgvCYtxrEfFLqghXtyPvvvKPNBnRCicNHQLE
207+
client: integration_test
208+
readonly: true
209+
196210
---
197211
"Register a repository with a non existing client":
198212

test/fixtures/azure-fixture/src/main/java/fixture/azure/AzureHttpFixture.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public class AzureHttpFixture extends ExternalResource {
4545
private final String clientId;
4646
private final String tenantId;
4747
private final Predicate<String> authHeaderPredicate;
48+
private final MockAzureBlobStore.LeaseExpiryPredicate leaseExpiryPredicate;
4849

4950
private HttpServer server;
5051
private HttpServer metadataServer;
@@ -116,7 +117,8 @@ public AzureHttpFixture(
116117
String container,
117118
@Nullable String rawTenantId,
118119
@Nullable String rawClientId,
119-
Predicate<String> authHeaderPredicate
120+
Predicate<String> authHeaderPredicate,
121+
MockAzureBlobStore.LeaseExpiryPredicate leaseExpiryPredicate
120122
) {
121123
final var tenantId = Strings.hasText(rawTenantId) ? rawTenantId : null;
122124
final var clientId = Strings.hasText(rawClientId) ? rawClientId : null;
@@ -135,6 +137,7 @@ public AzureHttpFixture(
135137
this.tenantId = tenantId;
136138
this.clientId = clientId;
137139
this.authHeaderPredicate = authHeaderPredicate;
140+
this.leaseExpiryPredicate = leaseExpiryPredicate;
138141
}
139142

140143
private String scheme() {
@@ -193,7 +196,10 @@ protected void before() {
193196
}
194197
case HTTP -> {
195198
server = HttpServer.create(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0), 0);
196-
server.createContext("/" + account, new AzureHttpHandler(account, container, actualAuthHeaderPredicate));
199+
server.createContext(
200+
"/" + account,
201+
new AzureHttpHandler(account, container, actualAuthHeaderPredicate, leaseExpiryPredicate)
202+
);
197203
server.start();
198204

199205
oauthTokenServiceServer = HttpServer.create(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0), 0);
@@ -222,7 +228,10 @@ protected void before() {
222228
final var httpsServer = HttpsServer.create(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0), 0);
223229
this.server = httpsServer;
224230
httpsServer.setHttpsConfigurator(new HttpsConfigurator(sslContext));
225-
httpsServer.createContext("/" + account, new AzureHttpHandler(account, container, actualAuthHeaderPredicate));
231+
httpsServer.createContext(
232+
"/" + account,
233+
new AzureHttpHandler(account, container, actualAuthHeaderPredicate, leaseExpiryPredicate)
234+
);
226235
httpsServer.start();
227236
}
228237
{

0 commit comments

Comments
 (0)