Commit graph

16679 commits

Author SHA1 Message Date
Vishal Raj
253e8544a6
[plugin/apm-data] Use component-templates to configure fallback to ILM (#112432) 2024-09-02 20:03:54 +01:00
David Kyle
f15c030b61
[ML]Fix the bug where the run() function of ExecutableInferenceRequest throws an exception when get inferenceEntityId. (#112135) (#112393)
Co-authored-by: Huaixinww <141887897+Huaixinww@users.noreply.github.com>
2024-08-30 22:57:51 +10:00
Armin Braun
d9f6887b44
Fix DLS over Runtime Fields (#112260) (#112318)
There is a DLS query referencing a runtime field loaded from _source, when we create the collector manager we retrieve the numDocs which triggers going through all segments and executing the script for each document. StoredFieldSourceProvider relies on leaf ordinals to build an array, but those ordinals are not populated when computing the numDocs via BaseCompositeReader, as that goes through the subreaders contexts, and not the context leaves (there is a subtle difference that bites us there).

Fixes #111637
2024-08-29 07:19:51 +02:00
Nhat Nguyen
0c45cc7a82
Avoid wrapping rejection exception in exchange (#112178) (#112288)
We should avoid wrapping EsRejectedExecutionException in an 
ElasticsearchException as it would change the status code from 429 to
500. Ideally, we should avoid wrapping exceptions altogether, but that
would require bigger changes.

Closes #112106
2024-08-29 02:01:30 +10:00
Jake Landis
af52f94154
Fix "unexpected field [remote_cluster]" for CCS (RCS 1.0) when using API key that references remote_cluster (#112226) (#112259)
This commit will remove the "remote_cluster" from the role descriptor of API keys that is sent to elder clusters for RCS 1.0. 
This will allow API keys created in 8.15.0 that reference "remote_cluster" to work when sent to an elder cluster. 
The API key could either explicitly reference "remote_cluster" or implicitly reference it via the limited by permissions of the superuser built in role.

Note this in reference to the standard API key, not cross cluster API key. The cross cluster API already removes this for elder clusters.

fixes: #112222
related: #107493
2024-08-28 09:43:49 +10:00
Oleksandr Kolomiiets
00722864ef
Prevent synthetic field loaders accessing stored fields from using stale data (#112173) (#112257)
(cherry picked from commit 38adbb0724)

# Conflicts:
#	rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/indices.create/20_synthetic_source.yml
2024-08-28 09:16:28 +10:00
Johannes Fredén
7b3d73c179
Fix connection timeout for OpenIdConnectAuthenticator get Userinfo (#112230) (#112238)
* Fix connection timeout for OpenIdConnectAuthenticator get Userinfo

* Update docs/changelog/112230.yaml
2024-08-28 00:51:03 +10:00
Nhat Nguyen
dc56dfeaee
Allow query pragmas in release builds (#111953) (#112168)
I have investigated an issue with QA clusters that run release builds. I 
wish I could enable query pragmas to confirm the problem instead of
setting up new clusters and replicating data before testing the theory.
This change allows users to enable query pragmas in release builds.
However, due to the risks associated with using pragmas, the
accept_pragma_risks parameter must be explicitly set to true to proceed.
2024-08-24 07:21:59 +10:00
Kathleen DeRusso
dcd2462428
Semantic reranking should fail whenever inference ID does not exist (#112038) (#112153)
* Semantic reranking should fail whenever inference ID does not exist

* Short circuit text similarity reranking on empty result set

* Update tests

* Remove test - it doesn't do anything useful

* Update docs/changelog/112038.yaml
2024-08-24 01:52:02 +10:00
Vishal Raj
49dbedbcdc
[plugin/apm-data] Set fallback to legacy ILM policies (#112028) (#112097) 2024-08-23 11:24:56 +01:00
Craig Taverner
f3f0d2e865
Always check crsType when folding spatial functions (#112090) (#112099)
* Always check crsType when folding spatial functions

* Update docs/changelog/112090.yaml

* Only require capability for fixed test

The other tests passed on older versions anyway.
2024-08-22 23:42:12 +10:00
Nik Everett
de18703ddc
ESQL: Document date instead of datetime (#111985) (#112034)
This changes the generated types tables in the docs to say `date`
instead of `datetime`. That's the name of the field in Elasticsearch so
it's a lot less confusing to call it that.

Closes #111650
2024-08-21 04:28:49 +10:00
Efe Gürkan YALAMAN
02a308be09
[Bugfix] Add accessDeclaredMembers permission for ObjectMapper to work. (#111285) (#111642)
* bugfix: Add accessDeclaredMembers permission for ObjectMapper to work.

* Update docs/changelog/111285.yaml

* update-changelog

* Update yml tests

* review changes
2024-08-20 10:57:21 +02:00
Nhat Nguyen
1f87f1729a
Avoid losing error message in failure collector (#111983) (#111986)
The node-disconnected exception might not include the root cause. In 
this case, the failure collector incorrectly unwraps the exception and
wraps it in a new Elasticsearch exception, losing the message. We should
instead use the original exception to preserve the reason.

Closes #111894
2024-08-20 06:00:25 +10:00
Jim Ferenczi
7a31a4dbdd
Speed up dense/sparse vector stats (#111729) (#111787)
This change ensures that we don't try to compute stats on mappings that don't have dense or sparse vector fields. We don't need to go through all the fields on every segment, instead we can extract the vector fields upfront and limit the work to only indices that define these types.

Closes #111715
2024-08-12 10:58:26 +10:00
Alexander Spies
ba5ca2b314
Skip LOOKUP/INLINESTATS cases unless on snapshot (#111755) (#111759)
Fix https://github.com/elastic/elasticsearch/issues/111753

(cherry picked from commit f0d06ee380)

# Conflicts:
#	muted-tests.yml
#	x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/VerifierTests.java
2024-08-10 02:55:35 +10:00
Max Hniebergall
14f45d4538
[Inference API] Backport Delete...Action pipeline check to threadpool (#111646)
* Move DeleteInferenceAction pipeline check to utility threadpool

* Update docs/changelog/111646.yaml

* Update docs/changelog/111646.yaml

Co-authored-by: David Kyle <david.kyle@elastic.co>

---------

Co-authored-by: David Kyle <david.kyle@elastic.co>
2024-08-09 09:45:29 -04:00
Alexander Spies
56fde8bffc
ESQL: Add tests for sort, where with unsupported type (#111737) (#111742) 2024-08-09 20:27:12 +10:00
Alexander Spies
e091e165e9
ESQL: Fix for overzealous validation in case of invalid mapped fields (#111475) (#111735)
Fix validation of fields mapped to different types in different indices and align with validation of fields of unsupported type.

* Allow using multi-typed fields in KEEP and DROP, just like unsupported fields.
* Explicitly invalidate using both these field kinds in RENAME.
* Map both kinds of fields to UnsupportedAttribute to enforce consistency.
* Consider convert functions containing valid multi-typed fields as resolved to avoid weird workarounds when resolving STATS.
* Add a bunch of tests.

(cherry picked from commit 585480fe44)

# Conflicts:
#	x-pack/plugin/esql/qa/testFixtures/src/main/resources/union_types.csv-spec
#	x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/analysis/Analyzer.java
#	x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plan/logical/Stats.java
2024-08-09 19:28:19 +10:00
Oleksandr Kolomiiets
15b3c167a8
Remove rollup/security_tests YAML tests (#111656) (#111681) 2024-08-08 02:28:17 +10:00
Panagiotis Bailis
392642871a
Properly handle filters on TextSimilarityRank retriever (#111673) (#111675) 2024-08-07 23:20:25 +10:00
Athena Brown
1a77947f34
Improve security-crypto threadpool overflow handling (#111369) (#111564)
Prior to this PR, when the security-crypto threadpool queue overflows and rejects API key hashing submissions, a toxic value (specifically, a future which will never be completed) is added to the API key auth cache. This toxic cache value causes future authentication attempts with that API key to fail by timeout, because they will attempt to wait for the toxic future, until that value is invalidated and removed from the cache. Additionally, this will hold on to memory for each request that waits on the toxic future, even after the request has timed out.

This PR adds a unit test to replicate this case, and adjusts the code which submits the key hashing task to the security-crypto threadpool to properly handle this point of failure by invalidating the cached future and notifying waiting handlers that the computation has failed.
2024-08-03 07:47:14 +10:00
Mark J. Hoy
ade5b13dc6
Add LTR License Check on PUT for Enterprise Licensing (#111248) (#111460)
* add isLicenseAllowedForAction trained model config

* fixup tests - trial is allowed

* fix license tests

* update tests for validate model static method

* add validateModel test; update license check
2024-07-31 05:53:21 +10:00
Adam Demjen
fd0251983c
Fix score count validation in reranker response (#111424)
* Fix score count validation in reranker response (backport)

* Update docs/changelog/111424.yaml

* Delete docs/changelog/111212.yaml

* Use constructor that exists

* Update 111424.yaml
2024-07-30 09:05:06 -04:00
James Baiera
3f30e388fc
Fix enrich policy runner exception handling on empty segments response (#111290) (#111371)
* Fix enrich segment action listener exception logic

* Update docs/changelog/111290.yaml

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2024-07-30 07:27:37 +10:00
Max Hniebergall
fc352bd210
[Inference API] Replace model_id with inference_id in inference API except when stored (#111366) (#111417)
* Replace model_id with inference_id in inference API except when storing ModelConfigs

* Update docs/changelog/111366.yaml

* replace missed literals in tests
2024-07-29 13:35:48 -04:00
Alexander Spies
17c2161a1a
ESQL: Fix variable shadowing when pushing down past Project (#108360) (#111229)
Fix bugs caused by pushing down Eval, Grok, Dissect and Enrich past Rename, where after the pushdown, the columns added shadowed the columns to be renamed.

For Dissect and Grok, this enables naming their generated attributes to deviate from the names obtained from the dissect/grok patterns.

(cherry picked from commit e8a01bbd9c)

# Conflicts:
#	x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/optimizer/OptimizerRules.java
#	x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plan/logical/Dissect.java
#	x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plan/logical/Enrich.java
#	x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plan/logical/Eval.java
#	x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plan/logical/RegexExtract.java
2024-07-24 20:39:13 +10:00
Luigi Dell'Aquila
0e6673f7ab
ES|QL: reduce max expression depth to 400 (#111186) (#111189) 2024-07-23 23:21:17 +10:00
Albert Zaharovits
e551c743cc
Add comma before charset parameter in WWW-Authenticate response header (#110906) (#111144)
Add comma before charset parameter in WWW-Authenticate response header,
according to RFC 7617.

Co-authored-by: Philippus Baalman <philippus@gmail.com>
2024-07-22 18:07:34 +10:00
Salvatore Campagna
aecc6e2cd8
[8.15] Rename logs index mode to logsdb (#111054) (#111098) 2024-07-19 16:26:13 +02:00
Alexander Spies
0e571fd51a
ESQL: Skip retrofitted tests (#111019) (#111088)
(cherry picked from commit 548aea56ce)

# Conflicts:
#	muted-tests.yml
#	x-pack/plugin/esql/qa/testFixtures/src/main/resources/stats.csv-spec
#	x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java
2024-07-19 19:24:56 +10:00
Joe Gallo
ff9a8eb705
[8.15] Directly download commercial ip geolocation databases from providers (#110844) (#111077)
Co-authored-by: Keith Massey <keith.massey@elastic.co>
2024-07-18 20:19:11 -04:00
Ignacio Vera
5846c231f1
Speed up collecting zero document string terms (#110922) (#111057)
Use segment ordinals when possible to collect zero document buckets
2024-07-19 01:18:54 +10:00
Carson Ip
8f9d06b24e
Update stack monitoring mapping for apm-server metrics (#110568) (#110687)
Update stack monitoring template for .monitoring-beats-mb to include latest apm-server monitoring metrics. All stack monitoring apm-server metrics references in kibana should be intact. To avoid breaking stack monitoring UI, although beat.stats.apm_server.server.response.errors.concurrency is unused and is not present in apm-server stats, it is manually kept in the mapping.

(cherry picked from commit 2fb6c80df2)
2024-07-18 14:44:34 +01:00
Salvatore Campagna
858440dd4b
[8.15] Inject host.name field without relying on (component) templates (#110938) (#111031)
* Inject `host.name` field without relying on (component) templates (#110938)

We do not want to rely on templates or component templates to include
the host.name field in indices using LogsDB. The host.name field is a field
we sort on by default when LogsDB is used. As a result, we just inject it
by default, the same way we do for the @timestamp field. This prevents
sorting errors due to missing host.name field in mappings.

The host.name is a keyword field and depending on the value of subobjects it will
be mapped as a name keyword nested inside a host or as a flat host.name keyword.
We also include ignore_above as we normally do for keywords in observability mappings.

* Enable missing hostname test
2024-07-18 13:52:49 +02:00
Alexander Spies
c7ece9b400
ESQL: Correctly compute Rename's output (#110968) (#110976)
Calling Rename.output() previously returned wrong results.

Since #110488, instead it throws an IllegalStateException. That leads to test failures in the EsqlNodeSubclassTests because e.g. MvExpandExec and FieldExtractExec eagerly calls .output() on its child when it's being constructed, and the child can be a fragment containing a Rename.

(cherry picked from commit 7df1b06525)

# Conflicts:
#	x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plan/logical/Rename.java
2024-07-18 01:15:11 +10:00
Alexander Spies
1284a3580a
[8.15] ESQL: Validate unique plan attribute names (#110488) (#110966)
* ESQL: Validate unique plan attribute names (#110488)

* Enforce an invariant in our dependency checker so that logical plans never have duplicate output attribute names or ids.
* Fix ROW to not produce columns with duplicate names.
* Fix ResolveUnionTypes to not create multiple synthetic field attributes for the same union type.
* Add tests for commands using the same column name more than once.
* Update docs w.r.t. how commands behave if they are used with duplicate column names.

(cherry picked from commit da5392134f)

# Conflicts:
#	x-pack/plugin/esql/qa/testFixtures/src/main/resources/stats.csv-spec
#	x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java
#	x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/optimizer/OptimizerRules.java
#	x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plan/logical/Rename.java

* Remove unrelated csv tests

These slipped in via merge conflicts.
2024-07-17 22:33:42 +10:00
Simon Cooper
ef93c95227
Add a cluster listener to fix missing cluster features after upgrade (#110710) (#110924)
Non-master-eligible nodes that are already part of a cluster when the master is upgraded don't re-join the cluster, so their cluster features never get updated. This adds a cluster listener that spots this occurring, and manually gets the node's features with a new transport action and updates the cluster state after the fact.
2024-07-17 00:39:20 +10:00
Craig Taverner
e946fa8086
Backport bugfixes for union-types to 8.15 (#110872)
* Fix bug in union-types with type-casting in grouping key of STATS (#110476)

* Allow auto-generated type-cast fields in CsvTests

This allows, for example, a csv-spec test result header like `client_ip::ip:ip`, which is generated with a command like `STATS count=count(*) BY client_ip::ip`

It is also a small cleanup of the header parsing code, since it was using Strings.split() in an odd way.

* Fix bug in union-types with type-casting in grouping key of STATS

* Update docs/changelog/110476.yaml

* Added casting_operator required capability

Using the new `::` syntax requires disabling support for older versions in multi-cluster tests.

* Added more tests for inline stats over long/datetime

* Trying to fix the STATS...STATS bug

This makes two changes:

* Keeps the Alias in the aggs.aggregates from the grouping key, so that ReplaceStatsNestedExpressionWithEval still works
* Adds explicit support for union-types conversion at grouping key loading in the ordinalGroupingOperatorFactory

Neither fix the particular edge case, but do seem correct

* Added EsqlCapability for this change

So that mixed cluster tests don't fail these new queries.

* Fix InsertFieldExtract for union types

Union types require a FieldExtractExec to be performed first thing at
the bottom of local physical plans.

In queries like
```
  from testidx*
  | eval x = to_string(client_ip)
  | stats c = count(*) by x
  | keep c
```
The `stats` has the grouping `x` but the aggregates get pruned to just
`c`. In cases like this, we did not insert a FieldExtractExec, which
this fixes.

* Revert query that previously failed

With Alex's fix, this query now passes.

* Revert integration of union-types to ordinals aggregator

This is because we have not found a test case that actually demonstrates this is necessary.

* More tests that would fail without the latest fix

* Correct code style

* Fix failing case when aggregating on union-type with invalid grouping key

* Capabilities restrictions on the new YML tests

* Update docs/changelog/110476.yaml

---------

Co-authored-by: Alexander Spies <alexander.spies@elastic.co>

* An alternative approach to supporting union-types on stats grouping field (#110600)

* Added union-types field extration to ordinals aggregation

* Revert previous approach to getting union-types working in aggregations

Where the grouping field is erased by later commands, like a subsequent stats.
Instead we include union-type supports in the ordinals aggregation and mark the block loader as not supporting ordinals.

* Fix union-types when aggregating on inline conversion function (#110652)

A query like:

```
FROM sample_data, sample_data_str
| STATS count=count(*) BY client_ip = TO_IP(client_ip)
| SORT count DESC, client_ip ASC
| KEEP count, client_ip
```

Failed due to unresolved aggregates from the union-type in the grouping key

* Fix for union-types for multiple columns with the same name (#110793)

* Make union types use unique attribute names

* Cleanup leftover

* Added failing test and final fix to EsRelation

* Implement FieldAttribute.fieldName()

* Fix tests

* Refactor

* Do not ignore union typed field's parent

* Fix important typo

D'oh

* Mute unrelated (part of) test

* Move capability to better location

* Fix analyzer tests

* multi-node tests with an earlier version of union-types (before this change) fail

* Add capability to remaining failing tests

* Remove variable

* Add more complex test

* Consolidate union type cleanup rules

* Add 3 more required_capability's to make CI happy

* Update caps for union type subfield yaml tests

* Update docs/changelog/110793.yaml

* Refined changelog text

* Mute BWC for 8.15.0 for failing YAML tests

* union_types_remove_fields for all 160_union_types tests

The tests fail spordically, so safer to mute the entire suite.

---------

Co-authored-by: Alexander Spies <alexander.spies@elastic.co>

---------

Co-authored-by: Alexander Spies <alexander.spies@elastic.co>
2024-07-16 10:50:45 +02:00
Michael Peterson
eb36da88f5
Revert "Search coordinator uses event.ingested in cluster state to do rewrites (#110352) (#110782)" (#110883)
This reverts commit 9092394b19.
2024-07-15 14:22:15 -04:00
Mark Tozzi
d5085ac93c
[Backport] 110824 to 8.15 (#110843)
* [ESQL] Count_distinct(_source) should return a 400 (#110824)

Resolves
[#105240](https://github.com/elastic/elasticsearch/issues/105240)

Count_distinct doesn't work on source, but the type resolution was
allowing that through.  This resulted in a 500 layer deeper in the
aggregations code.  This PR fixes the 500 error by correctly failing
during type resolution.

* Even hand-backporting, I messed up the capabilities file

* one more
2024-07-16 00:24:00 +10:00
Luigi Dell'Aquila
6c12360958
ES|QL: better validation for GROK patterns (#110574) (#110682)
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2024-07-15 23:38:21 +10:00
Oleksandr Kolomiiets
223647fe3f
[8.15] Fix RollupIndexerStateTests (#110804) 2024-07-12 10:38:40 -07:00
Michael Peterson
9092394b19
Search coordinator uses event.ingested in cluster state to do rewrites (#110352) (#110782)
Min/max range for the event.ingested timestamp field (part of Elastic Common
Schema) was added to IndexMetadata in cluster state for searchable snapshots
in #106252.

This commit modifies the search coordinator to rewrite searches to MatchNone
if the query searches a range of event.ingested that, from the min/max range
in cluster state, is known to not overlap. This is the same behavior we currently
have for the @timestamp field.
2024-07-11 12:01:08 -04:00
Mark Tozzi
0ee975bed0
[ESQL] Fix parsing of large magnitude negative numbers (#110665) (#110758)
Resolves https://github.com/elastic/elasticsearch/issues/104323

This fixes and adds tests for the first of the two bullets in the linked
issue.  `ExpressionBuilder#visitIntegerValue` will attempt to parse a
string as an integral value, and return a Literal of the appropriate
type.  The actual parsing happens in `StringUtils#parseIntegral`.  That
function has special handling for values that are larger than
`Long.MAX_VALUE` where it attempts to turn them into unsigned longs, and
if the number is still out of range, throw `InvalidArgumentException`.
`ExpressionBuilder` catches that `InvalidArgumentException` and tries to
parse a `double` instead.  If, on the other hand, the value is smaller
than `Long.MIN_VALUE`, `StringUtils` never enters the unsigned long path
and just calls `intValueExact`, which throws `ArithmeticException`.
This PR solves the issue by catching that `ArithmeticException` and
rethrowing it as an `InvalidArgumentException`.
2024-07-12 00:53:06 +10:00
Panagiotis Bailis
5fb62fead0
unmuting tests (#110708) 2024-07-10 23:02:55 +10:00
Felix Barnsteiner
77392d64e7
Remove default_field: message from metrics index templates (#110651) (#110683)
This is a follow-up from
https://github.com/elastic/elasticsearch/pull/102456
2024-07-10 18:15:06 +10:00
Keith Massey
06cfe31289
Do not run TickerScheduleTriggerEngine watches if the schedule trigger engine is paused (#110061) (#110674) 2024-07-10 08:29:14 +10:00
Albert Zaharovits
2a6ad97048
Remove dep com.nimbusds:nimbus-jose-jwt from module org.elasticsearch.xcore (#110565) (#110642)
The types from com.nimbusds.jwt are almost not needed in x-pack/plugin/core.
They're only needed in module org.elasticsearch.security, x-pack:plugin:security project.
2024-07-10 01:38:16 +10:00
Iván Cea Fontenla
48cbdbfb2d
ESQL: Fix Max not working with negative or zero doubles (#110635)
Partial backport from https://github.com/elastic/elasticsearch/pull/110586

Just the Max fix and an extra test for it.
2024-07-09 15:28:00 +02:00