Commit graph

224 commits

Author SHA1 Message Date
David Turner
21813604b4
Skip listing MPUs if TTL set to -1 (#127166)
Recent versions of MinIO will sometimes leak multi-part uploads under
concurrent load, leaving them in the `ListMultipartUploads` output even
though they cannot be aborted. Today this causes repository analysis to
fail since compare-and-exchange operations will not even start if there
are any pre-existing uploads. This commit makes it possible to skip this
pre-flight check (and accept the performance consequences) by adjusting
the relevant settings.

Workaround for minio/minio#21189
Closes #122670
2025-04-23 06:33:40 +01:00
Brendan Cully
d02b65308e
S3BlobContainer: Revert broadened exception handler (#126731)
Catching Exception instead of AmazonClientException in copyBlob and
executeMultipart led to failures in S3RepositoryAnalysisRestIT due to
the injected exceptions getting wrapped in IOExceptions that prevented
them from being caught and handled in BlobAnalyzeAction.

Closes #126576
2025-04-14 19:20:11 +02:00
David Turner
b10b35fccd
Fix S3RepositoryAnalysisRestIT (#126593)
- Translate a 404 during a multipart copy into a `FileNotFoundException`

- Use multiple threads in `S3HttpHandler` to avoid `CopyObject`/`PutObject` deadlock

Closes #126576
2025-04-11 05:41:20 +10:00
Brendan Cully
c1a71ff45c
BlobContainer: add copyBlob method (#125737)
* BlobContainer: add copyBlob method

If a container implements copyBlob, then the copy is
performed by the store, without client-side IO. If the store
does not provide a copy operation then the default implementation
throws UnsupportedOperationException.

This change provides implementations for the FS and S3 blob containers.
More will follow.

Co-authored-by: elasticsearchmachine <infra-root+elasticsearchmachine@elastic.co>
Co-authored-by: David Turner <david.turner@elastic.co>
2025-04-09 10:33:01 -07:00
David Turner
aab40b1247
Introduce TestBlobContainerBuilder (#126445)
The mostly-optional parameters to `createBlobContainer` are getting
rather numerous in this test harness which makes the tests hard to read.
This commit introduces a builder to help name the provided parameters
and skip the omitted ones.
2025-04-09 01:52:16 +10:00
Dianna Hohensee
4b2867a0ef
Support maxConnections override in AbstractBlobContainerRetriesTestCase tests (#126435) 2025-04-08 09:55:01 -04:00
David Turner
fbbbdd7eec
Allow overriding blob container path in tests (#126391)
Some `AbstractBlobContainerRetriesTestCase#createBlobContainer`
implementations choose a path for the container randomly, but we have a
need for a test which re-creates the same container against a different
`S3Service` and `BlobStore` and must therefore specify the same path
each time. This commit exposes a parameter that lets callers specify a
container path.
2025-04-08 03:54:37 +10:00
David Turner
7239540c91
Replace region with regionSupplier in all AWS tests (#126285)
Rather than hard-coding a region name we should always auto-generate it
randomly during test execution. This commit replaces the remaining fixed
`String` arguments with a `Supplier<String>` argument to enable this.
2025-04-05 02:27:28 +11:00
David Turner
3e35900b07
Add missing test security policies (#126309)
Relates #126274 Closes #126301 Closes #126302 Closes #126303 Closes
#126304 Closes #126305 Closes #126306
2025-04-05 02:27:17 +11:00
David Turner
7402dfdf65
Introduce qa subprojects of :modules:repository-s3 (#126274)
Today we have some special-case test classes in `:modules:repository-s3`
within the same source root as the regular tests, with some trickery to
define separate Gradle tasks to run them with their special-case
configs. This commit simplifies the build by just moving each of these
classes into its own Gradle project.
2025-04-04 21:29:05 +11:00
David Turner
896598570c
Reinstate S3SearchableSnapshotsCredentialsReloadIT in FIPS JVMs (#126109)
These tests only don't work in a FIPS JVM because they use a secret key
that is unacceptably short. This commit replaces the relevant uses of
`randomIdentifier` with `randomSecretKey` so they work whether in FIPS
mode or not.
2025-04-04 18:42:09 +11:00
David Turner
7eee6502de
Misc cleanups in S3BlobContainerRetriesTests (#126101)
- Simplify multi-object-delete request detection
- Replace `AtomicBoolean` with volatile field
- Make `ThrottlingDeleteHandler` static
2025-04-04 18:39:51 +11:00
David Turner
69f9914403
Migrate tests away from S3 SDK MD5DigestCalculatingInputStream (#126099)
`S3BlobContainerRetriesTests` uses `MD5DigestCalculatingInputStream`
from the AWS v1 SDK to compute a MD5 checksum, but this feature is not
available in the v2 SDK. With this commit we remove this dependency and
compute the MD5 checksums directly instead.
2025-04-03 14:11:00 +01:00
David Turner
15899afd26
Remove testWriteBlobWithExceptionThrownAtClosingTime (#126096)
Reverts the test added in #123505 - this is not behaviour on which we
rely any more, and it does not apply with SDKv2 anyway.
2025-04-02 09:43:04 +01:00
David Turner
0d64aab4cc
Clean up request parsing in S3HttpHandler (#126034)
The `METHOD /path/components?and=query` string representation of a
request is becoming increasingly difficult to parse, with slight
variations in parsing between the implementation in `S3HttpHandler` and
the various other implementations. This commit gets rid of the
string-concatenate-and-split behaviour in favour of a proper object that
has predicates for testing all the different kinds of request that might
be made against S3.
2025-04-02 05:49:50 +11:00
David Turner
6048d26990
Rename IgnoreNoResponseMetricsCollector (#125934)
Originally this metrics collector was just there to ignore API calls
that didn't make it all the way to S3, but (a) it doesn't really do that
because it also apparently ignores 4xx responses and (b) it also does a
bunch of other metrics collection too. `IgnoreNoResponseMetricsCollector`
is definitely the wrong name these days so this commit renames it to
something more general.
2025-03-31 14:32:38 +01:00
David Turner
36c14bf3a5
Validate region/service in DynamicAwsCredentials (#125671)
Following on from #125559, we can validate the region and service name
in tests that use `DynamicAwsCredentials` too.
2025-03-27 06:14:40 +00:00
David Turner
8d649f2f07
Validate AWS signer region and service in tests (#125559)
Extends the predicate in `AwsCredentialsUtils` to verify that we are
using a proper AWS v4 signature complete with the correct region and
service, rather than just looking for the access key as a substring.
2025-03-26 02:53:21 +11:00
David Turner
4ce1d9ce21
Cosmetic fixes to repository-s3 (#125397)
Relates AWS SDK v2 uprgade, this commit just pulls out some bits that
can go in first.
2025-03-21 13:31:48 +00:00
Patrick Doyle
fd51f44e32
Silence known entitlement warnings (#124883) 2025-03-18 16:52:12 +02:00
Patrick Doyle
df7be39de3
Silence AWS entitlement warnings from ALL-UNNAMED (#124805) 2025-03-13 16:42:29 -04:00
Patrick Doyle
5112dbbb3b
Reduce noise from NotEntitledException logging (#124511)
* Refactor: findRequestingFrame

* INFO instead of WARN for NotEntitledException.

Some of these are expected, so an INFO seems more appropriate.

The stack trace tends to attract attention even when entitlements are not the
cause of a problem, so let's avoid the stack trace, but still include stack
frame info from the frame of interest.

* Use child loggers for Not Entitled logs

* Use warn, and include compoenent name

* Fix ALL_UNNAMED

* Mute entitlement warnings from repositories

* PR feedback

* Common out the Not Entitled prefix.

We're alerting on this, so let's not rely on every caller of notEntitled to remember it.
2025-03-11 15:50:31 -04:00
Lorenzo Dematté
b8f1faac8d
remove addess to home/.aws for repository-s3 (#124190) 2025-03-08 23:30:17 +01:00
David Turner
88eeb8a5a1
Refactor SnapshotInfo dataflow in finalization (#124336)
There's no need to have a `SnapshotInfo` consumer to run at the end of
finalization, we only pass it the value we already calculated earlier.
This replaces it with a bare `Runnable` instead.
2025-03-08 09:17:13 +11:00
Alexey Ivanov
02f01af2a0
Change setting's deprecation message wording (#120718)
Depending on whether a message is critical or warning a message should
indicate to check breaking changes documentation (critical level) or
deprecation changes documentation (warn level)

relates #79666
2025-03-07 15:31:55 +00:00
Yang Wang
a9432ba07a
Limit the log line length for s3 deletion error (#123953)
If all items fail to delete, the current warning log builds a huge
string to include all of them (up to 1000). This PR limits the string
length to first 10 entries.

Relates: #123630
2025-03-06 12:02:27 +11:00
Pooya Salehi
113f0c17cc
Limit number of suppressed S3 deletion errors (#123630)
We've seen this being an issue on 7.x although can happen on all 
versions (I'm pretty sure this PR doesn't cleanly back-port to 7.x
though).

Closes https://github.com/elastic/elasticsearch/issues/123354
2025-03-04 03:06:27 +11:00
Lorenzo Dematté
850d48a944
Missing policies for netty, discovery-azure and repository-s3 (#123696) 2025-03-02 22:34:38 +01:00
Tanguy Leroux
e6eb8efba0
[Test] Add test for AWS SDKv1 swallowing exception at IndexputStream close time (#123505)
This change adds a unit test to demonstrate a specific 
behavior of the AWS SDKv1, which closes the InputStream 
used to upload a blob only after the HTTP request has 
been sent (this is to accomodate for retries). The SDK 
then swallows any exception thrown when closing the 
InputStream which has the effect to hide any potential 
CorruptIndexException that could have been detected 
at that time.

Relates ES-10931
2025-02-27 09:14:06 +01:00
Moritz Mack
d1b7639784
Add missing entitlements discovered in IT tests (#123015) 2025-02-20 15:05:42 +01:00
Moritz Mack
8eb89cf7c1
Add entitlement checks for java.io stream classes (#122406) 2025-02-18 14:12:01 +01:00
Yang Wang
850249b897
Handle status code 200 for s3 CMU response (#122815)
When a CopmleteMultipartUpload request fails after the initial 200
response, the status code of the failure response use to be not set and
hence got translated to status code 0. With #116212, we handle this case
accordingly. Since AWS SDK 1.12.691, the status code is now set to 200
instead of 0. This PR changes our error handling code accordingly.

Relates: #122431 Relates: #116212 Resolves: #122799

Relevant AWS SDK change
430899c217/aws-java-sdk-s3/src/main/java/com/amazonaws/services/s3/AmazonS3Client.java (L3696-L3709)
2025-02-18 20:11:36 +11:00
Alex Kattathra Johnson
5462601fd6
Upgrade AWS SDK to v1.12.746 (#122431) 2025-02-18 02:44:38 +11:00
Patrick Doyle
f8aa047994
Entitlements: manage_threads (#122261)
* Refactor: protected -> private

* Initial thread-related entitlements

* Entitlements from manual test runs

* Refactor: notEntitled method

* Entitlements reporting mode

* Entitlements from CI

* Revert "Entitlements reporting mode"

This reverts commit 443ca767333269a73accd0cedf9ca6c6ac51698a.

* Remove unnecessary EntitledActions.newThread

* Don't log in entitlements ITs by default

* Import SuppressForbidden

* Respond to PR comments

* Move manage_threads tests to their own file
2025-02-13 13:45:51 -05:00
Ryan Ernst
0cf42f2388
Rename environment dir accessors (#121803)
The node environment has many paths. The accessors for these currently
use a "file" suffix, but they are always directories. This commit
renames the accessors to make it clear these paths are directories.
2025-02-05 14:03:28 -08:00
Lorenzo Dematté
cd86b3b497
[Entitlements] Refactor Network Entitlement (#120391) 2025-01-20 18:29:32 +01:00
Patrick Doyle
34059c9dbd
Limit ByteSizeUnit to 2 decimals (#120142)
* Exhaustive testParseFractionalNumber

* Refactor: encapsulate ByteSizeUnit constructor

* Refactor: store size in bytes

* Support up to 2 decimals in parsed ByteSizeValue

* Fix test for rounding up with no warnings

* ByteSizeUnit transport changes

* Update docs/changelog/120142.yaml

* Changelog details and impact

* Fix change log breaking.area

* Address PR comments
2025-01-16 19:30:23 +00:00
Lorenzo Dematté
1848d6bb93
[Entitlements] Network access checks on Sockets (#120093) 2025-01-15 22:01:56 +01:00
Yang Wang
60a54e6ab7
[Test] Upgrade minio docker image used for tests (#120086)
This PR upgrades the minio docker image from
RELEASE.2021-03-01T04-20-55Z which is 3+ years old to the latest
RELEASE.2024-12-18T13-15-44Z.

Relates: #118548
2025-01-14 21:38:09 +11:00
Pooya Salehi
d18e3293eb
Issue S3 web identity token refresh call with sufficient permissions (#119748)
Closes #119747
2025-01-09 11:32:40 +00:00
Rene Groeschke
ba61f8c7f7
Update Gradle wrapper to 8.12 (#118683)
This updates the gradle wrapper to 8.12

We addressed deprecation warnings due to the update that includes:

- Fix change in TestOutputEvent api
- Fix deprecation in groovy syntax
- Use latest ospackage plugin containing our fix
- Remove project usages at execution time
- Fix deprecated project references in repository-old-versions
2024-12-30 15:34:24 +01:00
David Turner
a4d4762802
Introduce aws-fixture-utils (#119319)
Extracts some common utils for creating AWS service test fixtures out of
the `s3-fixture` module and into a separate library independent of S3.
2024-12-27 18:58:07 +00:00
Armin Braun
e94f145350
Fix a bunch of non-final static fields (#119185)
Fixing almost all missing `final` spots, who knows maybe we get a small speedup from
some constant folding here and there.
2024-12-26 19:14:36 +01:00
David Turner
59690f5e67
Add integ test for EC2 special network addresses (#118560)
Replaces the `Ec2NetworkTests` unit test suite with an integ test suite
to cover the resolution process end-to-end.
2024-12-13 07:30:57 +11:00
David Turner
a975927320
Add discovery-ec2 integration test for AZ attr (#118452)
Verifies that the plugin sets the `aws_availability_zone` automatically
by reading the AZ name from the IMDS at startup.
2024-12-12 10:57:57 +00:00
Joe Gallo
537f4ce871
Fix log message format bugs (#118354) 2024-12-10 15:01:53 -05:00
David Turner
0586cbfb34
Remove unused BlobStore#deleteBlobsIgnoringIfNotExists (#118245)
This method is never called against a general `BlobStore`, we only use
it in certain implementations for which a bulk delete at the `BlobStore`
level makes sense. This commit removes the unused interface method.
2024-12-09 15:46:22 +00:00
David Turner
64e0902f58
Pull AWS SDK versions to top level (#118247)
Today each relevant module defines the version of the AWS SDK that it
uses, which means there's a risk that we use different versions in
different modules. This commit pulls the version declarations to the top
level to make sure we keep everything in sync.
2024-12-09 23:11:55 +11:00
Nick Tindall
d411ad82da
AbstractRepositoryS3RestTestCase: Parse response for assertion (#118230) 2024-12-09 13:44:10 +11:00
Nick Tindall
7d43d8a852
Expose operation and request counts separately in repository stats (#117530)
Relates ES-9767
Fixes #104443
2024-12-04 09:19:37 +11:00