Skip to content

Commit

Permalink
[Backport 2.2][#7196] Platform: Health check should use appropriate v…
Browse files Browse the repository at this point in the history
…ersion of TLS

Summary: If `ssl_protocols` is added to the tserver gflags, health checks should use the appropriate option when trying to connect with the sample cqlsh command.

Test Plan:
Create tls universe with no gflags and run. Create tls universe with `ssl_protocols` and run.
Jenkins: rebase: 2.2

Reviewers: sanketh, arnav, bogdan, daniel, sb-yb

Reviewed By: sb-yb

Subscribers: yugaware, jenkins-bot

Differential Revision: https://phabricator.dev.yugabyte.com/D10600
  • Loading branch information
WesleyW committed Feb 11, 2021
1 parent ad99b66 commit 2b421e9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
17 changes: 15 additions & 2 deletions managed/devops/bin/cluster_health.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,15 @@ def __init__(self, node_fqdn, config_map):
class NodeChecker():

def __init__(self, node, node_name, identity_file, ssh_port, start_time_ms,
namespace_to_config, ysql_port, ycql_port, redis_port, enable_tls_client):
namespace_to_config, ysql_port, ycql_port, redis_port, enable_tls_client,
ssl_protocol):
self.node = node
self.node_name = node_name
self.identity_file = identity_file
self.ssh_port = ssh_port
self.start_time_ms = start_time_ms
self.enable_tls_client = enable_tls_client
self.ssl_protocol = ssl_protocol
# TODO: best way to do mark that this is a k8s deployment?
self.is_k8s = ssh_port == 0 and not self.identity_file
self.k8s_details = None
Expand Down Expand Up @@ -373,6 +375,16 @@ def check_cqlsh(self):
cert_file = K8S_CERT_FILE_PATH if self.is_k8s else VM_CERT_FILE_PATH

remote_cmd = 'SSL_CERTFILE={} {} {}'.format(cert_file, remote_cmd, '--ssl')
if self.ssl_protocol is not None:
SSL_PROTOCOL_TO_SSL_VERSION = {
"ssl2": "SSLv23",
"ssl3": "SSLv23",
"tls10": "TLSv1",
"tls11": "TLSv1_1",
"tls12": "TLSv1_2"
}
protocol = SSL_PROTOCOL_TO_SSL_VERSION.get(self.ssl_protocol)
remote_cmd = 'SSL_VERSION={} {}'.format(protocol, remote_cmd)

output = self._remote_check_output(remote_cmd).strip()

Expand Down Expand Up @@ -704,6 +716,7 @@ def __init__(self, data):
self.tserver_nodes = data["tserverNodes"]
self.yb_version = data["ybSoftwareVersion"]
self.namespace_to_config = data["namespaceToConfig"]
self.ssl_protocol = data["sslProtocol"]
self.enable_ysql = data["enableYSQL"]
self.ysql_port = data["ysqlPort"]
self.ycql_port = data["ycqlPort"]
Expand Down Expand Up @@ -753,7 +766,7 @@ def main():
checker = NodeChecker(
node, node_name, c.identity_file, c.ssh_port,
args.start_time_ms, c.namespace_to_config, c.ysql_port,
c.ycql_port, c.redis_port, c.enable_tls_client)
c.ycql_port, c.redis_port, c.enable_tls_client, c.ssl_protocol)
# TODO: use paramiko to establish ssh connection to the nodes.
if node in master_nodes:
coordinator.add_check(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,9 @@ public void checkSingleUniverse(Universe u, Customer c, CustomerConfig config,
clusterMetadata.put(cluster.uuid, info);
info.ybSoftwareVersion = cluster.userIntent.ybSoftwareVersion;
info.enableYSQL = cluster.userIntent.enableYSQL;
if (cluster.userIntent.tserverGFlags.containsKey("ssl_protocols")) {
info.sslProtocol = cluster.userIntent.tserverGFlags.get("ssl_protocols");
}
// Since health checker only uses CQLSH, we only care about the
// client to node encryption flag.
info.enableTlsClient = cluster.userIntent.enableClientToNodeEncrypt;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public static class ClusterInfo {
public Map<String, String> tserverNodes = new HashMap<>();
public String ybSoftwareVersion = null;
public boolean enableTlsClient = false;
public String sslProtocol = "";
public boolean enableYSQL = false;
public int ysqlPort = 5433;
public int ycqlPort = 9042;
Expand Down

0 comments on commit 2b421e9

Please sign in to comment.