Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Data] Take into account failure-store selector #207438

Merged
merged 3 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/platform/packages/shared/kbn-es-query/src/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,17 @@ describe('util tests', () => {
it('should validate CCS pattern', () => {
expect(isCCSRemoteIndexName('*:logstash-{now/d-2d}')).toBe(true);
});

it('should not validate selctor with wildcard', () => {
thomasneirynck marked this conversation as resolved.
Show resolved Hide resolved
expect(isCCSRemoteIndexName('my-data-stream::*')).toBe(false);
});

it('should not validate index name with selector', () => {
expect(isCCSRemoteIndexName('my-data-stream::failures')).toBe(false);
});

it('should not validate wildcard with selector', () => {
expect(isCCSRemoteIndexName('-logs-*::data')).toBe(false);
});
});
});
9 changes: 7 additions & 2 deletions src/platform/packages/shared/kbn-es-query/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export function getDataViewFieldSubtypeMulti(field: HasSubtype) {
* The index name is assumed to be individual index (no commas) but can contain `-`, wildcards,
* datemath, remote cluster name and any other syntax permissible in index expression component.
*
* 2024/10/11 Implementation taken from https://github.com/smalyshev/elasticsearch/blob/main/server/src/main/java/org/elasticsearch/transport/RemoteClusterAware.java
* 2025/01/21 Implementation taken from https://github.com/smalyshev/elasticsearch/blob/main/server/src/main/java/org/elasticsearch/transport/RemoteClusterAware.java
*
* @param indexExpression
*/
Expand All @@ -52,6 +52,11 @@ export function isCCSRemoteIndexName(indexExpression: string): boolean {
// Thus, whatever it is, this is definitely not a remote index.
return false;
}

const idx = indexExpression.indexOf(':');
// Check to make sure the remote cluster separator ':' isn't actually a selector separator '::'
const isSelector = indexExpression.startsWith('::', idx);
thomasneirynck marked this conversation as resolved.
Show resolved Hide resolved

// Note remote index name also can not start with ':'
return indexExpression.indexOf(':') > 0;
return idx > 0 && !isSelector;
}