-
Notifications
You must be signed in to change notification settings - Fork 25.4k
POC #131168
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
base: main
Are you sure you want to change the base?
POC #131168
Changes from all commits
980723e
4ff5e6e
3df7a1d
c21a0a9
5266376
650dd77
9d63d77
8eec08e
fe6b696
8dee748
f9d6407
be2ab99
710d789
3587e6a
26a49c0
2a45f5b
9d29d4f
0ef2258
88104ce
035ffc1
f5cad57
fe3dea0
1153dfa
3fd532e
512222e
b867e69
08d3e4e
d36c3f6
d20a8c9
32ed394
67f5cdf
e25d8b2
137195f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the "Elastic License | ||
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
* Public License v 1"; you may not use this file except in compliance with, at | ||
* your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
* License v3.0 only", or the "Server Side Public License, v 1". | ||
*/ | ||
|
||
package org.elasticsearch; | ||
|
||
import org.elasticsearch.action.IndicesRequest; | ||
import org.elasticsearch.core.Nullable; | ||
|
||
import java.util.List; | ||
|
||
public interface CrossProjectAwareRequest extends IndicesRequest { | ||
/** | ||
* Can be used to determine if this should be processed in cross-project mode vs. stateful CCS. | ||
*/ | ||
boolean crossProjectModeEnabled(); | ||
|
||
/** | ||
* Only called if cross-project rewriting (flat-world, linked project filtering) was applied | ||
*/ | ||
void qualified(List<QualifiedExpression> qualifiedExpressions); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we rename this method? This is a mutator, and There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah we for sure want a better name -- I'm also wondering if this should go in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That would require a new method like |
||
|
||
@Nullable | ||
String queryRouting(); | ||
|
||
/** | ||
* Used to track a mapping from original expression (potentially flat-world) to canonicalized CCS expressions. | ||
* e.g. for an original index expression `logs-*`, this would be: | ||
* original=logs-* | ||
* qualified=[(logs-*, _local), (my-remote:logs-*, my-remote)] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So we're storing the remote name twice here, as I understand? What's the reason for that? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh ya, we don't really need to -- I added it to clarify that that info will be available but in a production ready version of this, we wouldn't want to duplicate that info, you're right |
||
*/ | ||
record QualifiedExpression(String original, List<ExpressionWithProject> qualified) { | ||
public boolean hasFlatOriginalExpression() { | ||
return true; | ||
} | ||
} | ||
|
||
record ExpressionWithProject(String expression, String project) {} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
|
||
package org.elasticsearch.action.fieldcaps; | ||
|
||
import org.elasticsearch.CrossProjectAwareRequest; | ||
import org.elasticsearch.TransportVersions; | ||
import org.elasticsearch.action.ActionRequestValidationException; | ||
import org.elasticsearch.action.IndicesRequest; | ||
|
@@ -36,11 +37,16 @@ | |
import java.util.Arrays; | ||
import java.util.Collections; | ||
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Objects; | ||
import java.util.Set; | ||
|
||
public final class FieldCapabilitiesRequest extends LegacyActionRequest implements IndicesRequest.Replaceable, ToXContentObject { | ||
public final class FieldCapabilitiesRequest extends LegacyActionRequest | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need some way to tell field caps not to do the rewrite, because when processing e.g. lookups we probably don't need that. Alternatively, we'd need to change lookup code so it qualifies all the indices. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes I think that's true but I want to think through how that actually looks, I don't know if we want just a boolean flag |
||
implements | ||
CrossProjectAwareRequest, | ||
IndicesRequest.Replaceable, | ||
ToXContentObject { | ||
public static final String NAME = "field_caps_request"; | ||
public static final IndicesOptions DEFAULT_INDICES_OPTIONS = IndicesOptions.strictExpandOpenAndForbidClosed(); | ||
|
||
|
@@ -58,6 +64,7 @@ public final class FieldCapabilitiesRequest extends LegacyActionRequest implemen | |
private QueryBuilder indexFilter; | ||
private Map<String, Object> runtimeFields = Collections.emptyMap(); | ||
private Long nowInMillis; | ||
private List<QualifiedExpression> qualifiedExpressions; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How this is meant to be used? We store the result of flat resolution in the indices anyway, so we essentially storing it twice. Not sure I understand why? |
||
|
||
public FieldCapabilitiesRequest(StreamInput in) throws IOException { | ||
super(in); | ||
|
@@ -373,4 +380,25 @@ public String getDescription() { | |
} | ||
}; | ||
} | ||
|
||
@Override | ||
public boolean crossProjectModeEnabled() { | ||
return qualifiedExpressions != null; | ||
} | ||
|
||
@Override | ||
public void qualified(List<QualifiedExpression> qualifiedExpressions) { | ||
this.qualifiedExpressions = qualifiedExpressions; | ||
indices( | ||
qualifiedExpressions.stream() | ||
.flatMap(indexExpression -> indexExpression.qualified().stream().map(ExpressionWithProject::expression)) | ||
.toArray(String[]::new) | ||
); | ||
} | ||
|
||
@Override | ||
public String queryRouting() { | ||
// TODO how would this look in ES|QL? | ||
return null; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.core.security; | ||
|
||
import org.elasticsearch.transport.Transport; | ||
import org.elasticsearch.transport.TransportInterceptor; | ||
import org.elasticsearch.transport.TransportRequest; | ||
import org.elasticsearch.transport.TransportRequestOptions; | ||
import org.elasticsearch.transport.TransportResponse; | ||
import org.elasticsearch.transport.TransportResponseHandler; | ||
|
||
public interface CrossProjectRemoteServerTransportInterceptor { | ||
// TODO probably don't want this | ||
boolean enabled(); | ||
|
||
// TODO this should be a wrapper around TransportInterceptor.AsyncSender instead | ||
<T extends TransportResponse> void sendRequest( | ||
TransportInterceptor.AsyncSender sender, | ||
Transport.Connection connection, | ||
String action, | ||
TransportRequest request, | ||
TransportRequestOptions options, | ||
TransportResponseHandler<T> handler | ||
); | ||
|
||
CustomServerTransportFilter getFilter(); | ||
|
||
class Default implements CrossProjectRemoteServerTransportInterceptor { | ||
@Override | ||
public boolean enabled() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public <T extends TransportResponse> void sendRequest( | ||
TransportInterceptor.AsyncSender sender, | ||
Transport.Connection connection, | ||
String action, | ||
TransportRequest request, | ||
TransportRequestOptions options, | ||
TransportResponseHandler<T> handler | ||
) { | ||
sender.sendRequest(connection, action, request, options, handler); | ||
} | ||
|
||
@Override | ||
public CustomServerTransportFilter getFilter() { | ||
return new CustomServerTransportFilter.Default(); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.core.security; | ||
|
||
import org.elasticsearch.action.ActionListener; | ||
import org.elasticsearch.transport.TransportRequest; | ||
|
||
public interface CustomServerTransportFilter { | ||
void filter(String securityAction, TransportRequest request, ActionListener<Void> authenticationListener); | ||
|
||
class Default implements CustomServerTransportFilter { | ||
@Override | ||
public void filter(String securityAction, TransportRequest request, ActionListener<Void> listener) { | ||
listener.onResponse(null); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What will be using this method? The javadoc describes what it does but it's unclear to me which parts needs to know that.