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

Add the simple strategy to cluster settings #49414

Merged
merged 12 commits into from
Nov 22, 2019
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
---
"Add transient remote cluster in simple mode with invalid sniff settings":
- do:
cluster.get_settings:
include_defaults: true

- set: { defaults.cluster.remote.my_remote_cluster.seeds.0: remote_ip }

- do:
catch: bad_request
cluster.put_settings:
flat_settings: true
body:
transient:
cluster.remote.test_remote_cluster.mode: "simple"
cluster.remote.test_remote_cluster.sniff.node_connections: "5"
cluster.remote.test_remote_cluster.simple.addresses: $remote_ip

- match: { status: 400 }
- match: { error.root_cause.0.type: "illegal_argument_exception" }
- match: { error.root_cause.0.reason: "Setting \"cluster.remote.test_remote_cluster.sniff.node_connections\" cannot be
used with the configured \"cluster.remote.test_remote_cluster.mode\" [required=SNIFF, configured=SIMPLE]" }

- do:
catch: bad_request
cluster.put_settings:
flat_settings: true
body:
transient:
cluster.remote.test_remote_cluster.mode: "simple"
cluster.remote.test_remote_cluster.sniff.seeds: $remote_ip
cluster.remote.test_remote_cluster.simple.addresses: $remote_ip

- match: { status: 400 }
- match: { error.root_cause.0.type: "illegal_argument_exception" }
- match: { error.root_cause.0.reason: "Setting \"cluster.remote.test_remote_cluster.sniff.seeds\" cannot be
used with the configured \"cluster.remote.test_remote_cluster.mode\" [required=SNIFF, configured=SIMPLE]" }

---
"Add transient remote cluster in sniff mode with invalid simple settings":
- do:
cluster.get_settings:
include_defaults: true

- set: { defaults.cluster.remote.my_remote_cluster.seeds.0: remote_ip }

- do:
catch: bad_request
cluster.put_settings:
flat_settings: true
body:
transient:
cluster.remote.test_remote_cluster.simple.socket_connections: "20"
cluster.remote.test_remote_cluster.sniff.seeds: $remote_ip

- match: { status: 400 }
- match: { error.root_cause.0.type: "illegal_argument_exception" }
- match: { error.root_cause.0.reason: "Setting \"cluster.remote.test_remote_cluster.simple.socket_connections\" cannot be
used with the configured \"cluster.remote.test_remote_cluster.mode\" [required=SIMPLE, configured=SNIFF]" }

- do:
catch: bad_request
cluster.put_settings:
flat_settings: true
body:
transient:
cluster.remote.test_remote_cluster.simple.addresses: $remote_ip
cluster.remote.test_remote_cluster.sniff.seeds: $remote_ip

- match: { status: 400 }
- match: { error.root_cause.0.type: "illegal_argument_exception" }
- match: { error.root_cause.0.reason: "Setting \"cluster.remote.test_remote_cluster.simple.addresses\" cannot be
used with the configured \"cluster.remote.test_remote_cluster.mode\" [required=SIMPLE, configured=SNIFF]" }

---
"Add transient remote cluster using simple connection mode using valid settings":
- do:
cluster.get_settings:
include_defaults: true

- set: { defaults.cluster.remote.my_remote_cluster.seeds.0: remote_ip }

- do:
cluster.put_settings:
flat_settings: true
body:
transient:
cluster.remote.test_remote_cluster.mode: "simple"
cluster.remote.test_remote_cluster.simple.socket_connections: "3"
cluster.remote.test_remote_cluster.simple.addresses: $remote_ip

- match: {transient.cluster\.remote\.test_remote_cluster\.mode: "simple"}
- match: {transient.cluster\.remote\.test_remote_cluster\.simple\.socket_connections: "3"}
- match: {transient.cluster\.remote\.test_remote_cluster\.simple\.addresses: $remote_ip}

- do:
search:
rest_total_hits_as_int: true
index: test_remote_cluster:test_index

- is_false: num_reduce_phases
- match: {_clusters.total: 1}
- match: {_clusters.successful: 1}
- match: {_clusters.skipped: 0}
- match: { _shards.total: 3 }
- match: { hits.total: 6 }
- match: { hits.hits.0._index: "test_remote_cluster:test_index" }

---
"Add transient remote cluster using sniff connection mode using valid settings":
- do:
cluster.get_settings:
include_defaults: true

- set: { defaults.cluster.remote.my_remote_cluster.seeds.0: remote_ip }

- do:
cluster.put_settings:
flat_settings: true
body:
transient:
cluster.remote.test_remote_cluster.mode: "sniff"
cluster.remote.test_remote_cluster.sniff.node_connections: "3"
cluster.remote.test_remote_cluster.sniff.seeds: $remote_ip

- match: {transient.cluster\.remote\.test_remote_cluster\.mode: "sniff"}
- match: {transient.cluster\.remote\.test_remote_cluster\.sniff\.node_connections: "3"}
- match: {transient.cluster\.remote\.test_remote_cluster\.sniff\.seeds: $remote_ip}

- do:
search:
rest_total_hits_as_int: true
index: test_remote_cluster:test_index

- is_false: num_reduce_phases
- match: {_clusters.total: 1}
- match: {_clusters.successful: 1}
- match: {_clusters.skipped: 0}
- match: { _shards.total: 3 }
- match: { hits.total: 6 }
- match: { hits.hits.0._index: "test_remote_cluster:test_index" }

---
"Switch connection mode for configured cluster":
- do:
cluster.get_settings:
include_defaults: true

- set: { defaults.cluster.remote.my_remote_cluster.seeds.0: remote_ip }

- do:
cluster.put_settings:
flat_settings: true
body:
transient:
cluster.remote.test_remote_cluster.mode: "sniff"
cluster.remote.test_remote_cluster.sniff.seeds: $remote_ip

- match: {transient.cluster\.remote\.test_remote_cluster\.mode: "sniff"}
Tim-Brooks marked this conversation as resolved.
Show resolved Hide resolved
- match: {transient.cluster\.remote\.test_remote_cluster\.sniff\.seeds: $remote_ip}

- do:
search:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this might fail as switching the remote connection mode does not wait for 10 seconds for the new connections to be established. I think we should adapt the waiting logic to take this into account.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So you want me to just always wait? Setting aside the mode, any change to a remote cluster config through settings will involve the connection being torn down and rebuilt.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made a change in remote cluster service to always wait. The update method will complete the listener before returning if the connection is being destroyed or unchanged (meaning no wait.)

rest_total_hits_as_int: true
index: test_remote_cluster:test_index

- is_false: num_reduce_phases
- match: {_clusters.total: 1}
- match: {_clusters.successful: 1}
- match: {_clusters.skipped: 0}
- match: { _shards.total: 3 }
- match: { hits.total: 6 }
- match: { hits.hits.0._index: "test_remote_cluster:test_index" }

- do:
catch: bad_request
cluster.put_settings:
flat_settings: true
body:
transient:
cluster.remote.test_remote_cluster.mode: "simple"
cluster.remote.test_remote_cluster.simple.addresses: $remote_ip

- match: { status: 400 }
- match: { error.root_cause.0.type: "illegal_argument_exception" }
- match: { error.root_cause.0.reason: "Setting \"cluster.remote.test_remote_cluster.sniff.seeds\" cannot be
used with the configured \"cluster.remote.test_remote_cluster.mode\" [required=SNIFF, configured=SIMPLE]" }

- do:
cluster.put_settings:
flat_settings: true
body:
transient:
cluster.remote.test_remote_cluster.mode: "simple"
cluster.remote.test_remote_cluster.sniff.seeds: null
cluster.remote.test_remote_cluster.simple.addresses: $remote_ip

- match: {transient.cluster\.remote\.test_remote_cluster\.mode: "simple"}
- match: {transient.cluster\.remote\.test_remote_cluster\.simple\.addresses: $remote_ip}

- do:
search:
rest_total_hits_as_int: true
index: test_remote_cluster:test_index

- is_false: num_reduce_phases
- match: {_clusters.total: 1}
- match: {_clusters.successful: 1}
- match: {_clusters.skipped: 0}
- match: { _shards.total: 3 }
- match: { hits.total: 6 }
- match: { hits.hits.0._index: "test_remote_cluster:test_index" }
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@
import org.elasticsearch.search.fetch.subphase.highlight.FastVectorHighlighter;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.RemoteClusterService;
import org.elasticsearch.transport.RemoteConnectionStrategy;
import org.elasticsearch.transport.SimpleConnectionStrategy;
import org.elasticsearch.transport.SniffConnectionStrategy;
import org.elasticsearch.transport.TransportSettings;
import org.elasticsearch.watcher.ResourceWatcherService;
Expand Down Expand Up @@ -281,12 +283,15 @@ public void apply(Settings value, Settings current, Settings previous) {
SearchService.DEFAULT_ALLOW_PARTIAL_SEARCH_RESULTS,
TransportSearchAction.SHARD_COUNT_LIMIT_SETTING,
RemoteClusterService.REMOTE_CLUSTER_SKIP_UNAVAILABLE,
RemoteClusterService.REMOTE_CONNECTIONS_PER_CLUSTER,
SniffConnectionStrategy.REMOTE_CONNECTIONS_PER_CLUSTER,
RemoteClusterService.REMOTE_INITIAL_CONNECTION_TIMEOUT_SETTING,
RemoteClusterService.REMOTE_NODE_ATTRIBUTE,
RemoteClusterService.ENABLE_REMOTE_CLUSTERS,
RemoteClusterService.REMOTE_CLUSTER_PING_SCHEDULE,
RemoteClusterService.REMOTE_CLUSTER_COMPRESS,
RemoteConnectionStrategy.REMOTE_CONNECTION_MODE,
SimpleConnectionStrategy.REMOTE_CLUSTER_ADDRESSES,
SimpleConnectionStrategy.REMOTE_SOCKET_CONNECTIONS,
SniffConnectionStrategy.REMOTE_CLUSTER_SEEDS_OLD,
SniffConnectionStrategy.REMOTE_CLUSTERS_PROXY,
SniffConnectionStrategy.REMOTE_CLUSTER_SEEDS,
Expand Down
Loading