Skip to content

Backport remote proxy mode stats and naming #50402

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

Merged
merged 6 commits into from
Dec 20, 2019
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public void setupRemoteClusterConfig() throws Exception {
String transportAddress = (String) nodesResponse.get("transport_address");

ClusterUpdateSettingsRequest updateSettingsRequest = new ClusterUpdateSettingsRequest();
updateSettingsRequest.transientSettings(Collections.singletonMap("cluster.remote.local_cluster.sniff.seeds", transportAddress));
updateSettingsRequest.transientSettings(Collections.singletonMap("cluster.remote.local_cluster.seeds", transportAddress));
ClusterUpdateSettingsResponse updateSettingsResponse =
highLevelClient().cluster().putSettings(updateSettingsRequest, RequestOptions.DEFAULT);
assertThat(updateSettingsResponse.isAcknowledged(), is(true));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public void setupRemoteClusterConfig() throws IOException {
String transportAddress = (String) nodesResponse.get("transport_address");

ClusterUpdateSettingsRequest updateSettingsRequest = new ClusterUpdateSettingsRequest();
updateSettingsRequest.transientSettings(Collections.singletonMap("cluster.remote.local.sniff.seeds", transportAddress));
updateSettingsRequest.transientSettings(Collections.singletonMap("cluster.remote.local.seeds", transportAddress));
ClusterUpdateSettingsResponse updateSettingsResponse =
client.cluster().putSettings(updateSettingsRequest, RequestOptions.DEFAULT);
assertThat(updateSettingsResponse.isAcknowledged(), is(true));
Expand Down
5 changes: 3 additions & 2 deletions docs/reference/ccr/getting-started.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ remote cluster.
"num_nodes_connected" : 1, <2>
"max_connections_per_cluster" : 3,
"initial_connect_timeout" : "30s",
"skip_unavailable" : false
"skip_unavailable" : false,
"mode" : "sniff"
}
}
--------------------------------------------------
Expand All @@ -146,7 +147,7 @@ remote cluster.
alias `leader`
<2> This shows the number of nodes in the remote cluster the local cluster is
connected to.

Alternatively, you can manage remote clusters on the
*Management / Elasticsearch / Remote Clusters* page in {kib}:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public void testSearchSkipUnavailable() throws IOException {
try (MockTransportService remoteTransport = startTransport("node0", new CopyOnWriteArrayList<>(), Version.CURRENT, threadPool)) {
DiscoveryNode remoteNode = remoteTransport.getLocalDiscoNode();

updateRemoteClusterSettings(Collections.singletonMap("sniff.seeds", remoteNode.getAddress().toString()));
updateRemoteClusterSettings(Collections.singletonMap("seeds", remoteNode.getAddress().toString()));

for (int i = 0; i < 10; i++) {
restHighLevelClient.index(
Expand Down Expand Up @@ -229,7 +229,7 @@ public void testSearchSkipUnavailable() throws IOException {
assertSearchConnectFailure();

Map<String, Object> map = new HashMap<>();
map.put("sniff.seeds", null);
map.put("seeds", null);
map.put("skip_unavailable", null);
updateRemoteClusterSettings(map);
}
Expand All @@ -248,32 +248,32 @@ public void testSkipUnavailableDependsOnSeeds() throws IOException {
() -> client().performRequest(request));
assertEquals(400, responseException.getResponse().getStatusLine().getStatusCode());
assertThat(responseException.getMessage(),
containsString("missing required setting [cluster.remote.remote1.sniff.seeds] " +
containsString("missing required setting [cluster.remote.remote1.seeds] " +
"for setting [cluster.remote.remote1.skip_unavailable]"));
}

Map<String, Object> settingsMap = new HashMap<>();
settingsMap.put("sniff.seeds", remoteNode.getAddress().toString());
settingsMap.put("seeds", remoteNode.getAddress().toString());
settingsMap.put("skip_unavailable", randomBoolean());
updateRemoteClusterSettings(settingsMap);

{
//check that seeds cannot be reset alone if skip_unavailable is set
Request request = new Request("PUT", "/_cluster/settings");
request.setEntity(buildUpdateSettingsRequestBody(Collections.singletonMap("sniff.seeds", null)));
request.setEntity(buildUpdateSettingsRequestBody(Collections.singletonMap("seeds", null)));
ResponseException responseException = expectThrows(ResponseException.class,
() -> client().performRequest(request));
assertEquals(400, responseException.getResponse().getStatusLine().getStatusCode());
assertThat(responseException.getMessage(), containsString("missing required setting [cluster.remote.remote1.sniff.seeds] " +
assertThat(responseException.getMessage(), containsString("missing required setting [cluster.remote.remote1.seeds] " +
"for setting [cluster.remote.remote1.skip_unavailable]"));
}

if (randomBoolean()) {
updateRemoteClusterSettings(Collections.singletonMap("skip_unavailable", null));
updateRemoteClusterSettings(Collections.singletonMap("sniff.seeds", null));
updateRemoteClusterSettings(Collections.singletonMap("seeds", null));
} else {
Map<String, Object> nullMap = new HashMap<>();
nullMap.put("sniff.seeds", null);
nullMap.put("seeds", null);
nullMap.put("skip_unavailable", null);
updateRemoteClusterSettings(nullMap);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,10 @@ public void testRemoteClusterSettingsUpgraded() throws IOException {
RemoteClusterService.REMOTE_CLUSTER_SKIP_UNAVAILABLE.getConcreteSettingForNamespace("foo").exists(settings));
assertTrue(RemoteClusterService.REMOTE_CLUSTER_SKIP_UNAVAILABLE.getConcreteSettingForNamespace("foo").get(settings));
assertFalse(SEARCH_REMOTE_CLUSTERS_SEEDS.getConcreteSettingForNamespace("foo").exists(settings));
assertTrue(SniffConnectionStrategy.REMOTE_CLUSTER_SEEDS_OLD.getConcreteSettingForNamespace("foo").exists(settings));
assertFalse(SniffConnectionStrategy.REMOTE_CLUSTER_SEEDS.getConcreteSettingForNamespace("foo").exists(settings));
assertTrue(SniffConnectionStrategy.REMOTE_CLUSTER_SEEDS.getConcreteSettingForNamespace("foo")
.existsOrFallbackExists(settings));
assertTrue(SniffConnectionStrategy.REMOTE_CLUSTER_SEEDS.getConcreteSettingForNamespace("foo").exists(settings));
assertThat(
SniffConnectionStrategy.REMOTE_CLUSTER_SEEDS.getConcreteSettingForNamespace("foo").get(settings),
equalTo(Collections.singletonList("localhost:9200")));
assertThat(
SniffConnectionStrategy.REMOTE_CLUSTER_SEEDS_OLD.getConcreteSettingForNamespace("foo").get(settings),
equalTo(Collections.singletonList("localhost:9200")));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
"Add transient remote cluster in simple mode with invalid sniff settings":
"Add transient remote cluster in proxy mode with invalid sniff settings":
- do:
cluster.get_settings:
include_defaults: true
Expand All @@ -12,32 +12,32 @@
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
cluster.remote.test_remote_cluster.mode: "proxy"
cluster.remote.test_remote_cluster.node_connections: "5"
cluster.remote.test_remote_cluster.proxy_address: $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]" }
- match: { error.root_cause.0.reason: "Setting \"cluster.remote.test_remote_cluster.node_connections\" cannot be
used with the configured \"cluster.remote.test_remote_cluster.mode\" [required=SNIFF, configured=PROXY]" }

- 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
cluster.remote.test_remote_cluster.mode: "proxy"
cluster.remote.test_remote_cluster.seeds: $remote_ip
cluster.remote.test_remote_cluster.proxy_address: $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]" }
- match: { error.root_cause.0.reason: "Setting \"cluster.remote.test_remote_cluster.seeds\" cannot be
used with the configured \"cluster.remote.test_remote_cluster.mode\" [required=SNIFF, configured=PROXY]" }

---
"Add transient remote cluster in sniff mode with invalid simple settings":
"Add transient remote cluster in sniff mode with invalid proxy settings":
- do:
cluster.get_settings:
include_defaults: true
Expand All @@ -50,30 +50,30 @@
flat_settings: true
body:
transient:
cluster.remote.test_remote_cluster.simple.socket_connections: "20"
cluster.remote.test_remote_cluster.sniff.seeds: $remote_ip
cluster.remote.test_remote_cluster.proxy_socket_connections: "20"
cluster.remote.test_remote_cluster.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]" }
- match: { error.root_cause.0.reason: "Setting \"cluster.remote.test_remote_cluster.proxy_socket_connections\" cannot be
used with the configured \"cluster.remote.test_remote_cluster.mode\" [required=PROXY, 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
cluster.remote.test_remote_cluster.proxy_address: $remote_ip
cluster.remote.test_remote_cluster.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]" }
- match: { error.root_cause.0.reason: "Setting \"cluster.remote.test_remote_cluster.proxy_address\" cannot be
used with the configured \"cluster.remote.test_remote_cluster.mode\" [required=PROXY, configured=SNIFF]" }

---
"Add transient remote cluster using simple connection mode using valid settings":
"Add transient remote cluster using proxy connection mode using valid settings":
- do:
cluster.get_settings:
include_defaults: true
Expand All @@ -85,13 +85,13 @@
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
cluster.remote.test_remote_cluster.mode: "proxy"
cluster.remote.test_remote_cluster.proxy_socket_connections: "3"
cluster.remote.test_remote_cluster.proxy_address: $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}
- match: {transient.cluster\.remote\.test_remote_cluster\.mode: "proxy"}
- match: {transient.cluster\.remote\.test_remote_cluster\.proxy_socket_connections: "3"}
- match: {transient.cluster\.remote\.test_remote_cluster\.proxy_address: $remote_ip}

- do:
search:
Expand Down Expand Up @@ -120,12 +120,12 @@
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
cluster.remote.test_remote_cluster.node_connections: "3"
cluster.remote.test_remote_cluster.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}
- match: {transient.cluster\.remote\.test_remote_cluster\.node_connections: "3"}
- match: {transient.cluster\.remote\.test_remote_cluster\.seeds: $remote_ip}

- do:
search:
Expand Down Expand Up @@ -154,10 +154,10 @@
body:
transient:
cluster.remote.test_remote_cluster.mode: "sniff"
cluster.remote.test_remote_cluster.sniff.seeds: $remote_ip
cluster.remote.test_remote_cluster.seeds: $remote_ip

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

- do:
search:
Expand All @@ -178,25 +178,25 @@
flat_settings: true
body:
transient:
cluster.remote.test_remote_cluster.mode: "simple"
cluster.remote.test_remote_cluster.simple.addresses: $remote_ip
cluster.remote.test_remote_cluster.mode: "proxy"
cluster.remote.test_remote_cluster.proxy_address: $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]" }
- match: { error.root_cause.0.reason: "Setting \"cluster.remote.test_remote_cluster.seeds\" cannot be
used with the configured \"cluster.remote.test_remote_cluster.mode\" [required=SNIFF, configured=PROXY]" }

- 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
cluster.remote.test_remote_cluster.mode: "proxy"
cluster.remote.test_remote_cluster.seeds: null
cluster.remote.test_remote_cluster.proxy_address: $remote_ip

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

- do:
search:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
---
"Fetch remote cluster info for existing cluster":
"Fetch remote cluster sniff info for existing cluster":

- do:
cluster.remote_info: {}
- match: { my_remote_cluster.connected: true }
- match: { my_remote_cluster.num_nodes_connected: 1}
- match: { my_remote_cluster.max_connections_per_cluster: 1}
- match: { my_remote_cluster.initial_connect_timeout: "30s" }
- match: { my_remote_cluster.mode: "sniff" }

---
"Add transient remote cluster based on the preset cluster and check remote info":
Expand All @@ -21,9 +22,13 @@
flat_settings: true
body:
transient:
cluster.remote.test_remote_cluster.mode: "sniff"
cluster.remote.test_remote_cluster.node_connections: "2"
cluster.remote.test_remote_cluster.seeds: $remote_ip

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

# we do another search here since this will enforce the connection to be established
# otherwise the cluster might not have been connected yet.
Expand All @@ -45,19 +50,49 @@
- match: { my_remote_cluster.seeds.0: $remote_ip }

- match: { my_remote_cluster.num_nodes_connected: 1}
- match: { test_remote_cluster.num_nodes_connected: 1}
- gt: { test_remote_cluster.num_nodes_connected: 0}

- match: { my_remote_cluster.max_connections_per_cluster: 1}
- match: { test_remote_cluster.max_connections_per_cluster: 1}
- match: { test_remote_cluster.max_connections_per_cluster: 2}

- match: { my_remote_cluster.initial_connect_timeout: "30s" }
- match: { test_remote_cluster.initial_connect_timeout: "30s" }

- match: { my_remote_cluster.mode: "sniff" }
- match: { test_remote_cluster.mode: "sniff" }

- do:
cluster.put_settings:
flat_settings: true
body:
transient:
cluster.remote.test_remote_cluster.mode: "proxy"
cluster.remote.test_remote_cluster.seeds: null
cluster.remote.test_remote_cluster.node_connections: null
cluster.remote.test_remote_cluster.proxy_socket_connections: "10"
cluster.remote.test_remote_cluster.proxy_address: $remote_ip

- match: {transient.cluster\.remote\.test_remote_cluster\.mode: "proxy"}
- match: {transient.cluster\.remote\.test_remote_cluster\.proxy_socket_connections: "10"}
- match: {transient.cluster\.remote\.test_remote_cluster\.proxy_address: $remote_ip}

- do:
cluster.remote_info: {}

- match: { test_remote_cluster.connected: true }
- match: { test_remote_cluster.address: $remote_ip }
- gt: { test_remote_cluster.num_sockets_connected: 0}
- match: { test_remote_cluster.max_socket_connections: 10}
- match: { test_remote_cluster.initial_connect_timeout: "30s" }
- match: { test_remote_cluster.mode: "proxy" }

- do:
cluster.put_settings:
body:
transient:
cluster.remote.test_remote_cluster.mode: null
cluster.remote.test_remote_cluster.proxy_socket_connections: null
cluster.remote.test_remote_cluster.proxy_address: null

---
"skip_unavailable is returned as part of _remote/info response":
Expand Down
Loading