Skip to content

Commit 64ce4bc

Browse files
In case of failure of DB sping, retrieve the log and push to S3 (#284)
* [fix] get_final_benchmark_config is error agnostic * Fixed profiler-daemon startup code. Included documentation about perf-daemon * In case of failure of DB sping, retrieve the log and push to S3
1 parent ee0775a commit 64ce4bc

File tree

4 files changed

+51
-14
lines changed

4 files changed

+51
-14
lines changed

redisbench_admin/environments/oss_cluster.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def spin_up_local_redis_cluster(
2828
for master_shard_id in range(1, shard_count + 1):
2929
shard_port = master_shard_id + start_port - 1
3030

31-
command = generate_cluster_redis_server_args(
31+
command, _ = generate_cluster_redis_server_args(
3232
dbdir,
3333
local_module_file,
3434
ip,
@@ -139,14 +139,18 @@ def generate_cluster_redis_server_args(
139139
configuration_parameters=None,
140140
daemonize="yes",
141141
modules_configuration_parameters_map={},
142+
logname_prefix=None,
142143
):
144+
if logname_prefix is None:
145+
logname_prefix = ""
146+
logfile = "{}cluster-node-port-{}.log".format(logname_prefix, port)
143147
# start redis-server
144148
command = [
145149
"redis-server",
146150
"--appendonly",
147151
"no",
148152
"--logfile",
149-
"cluster-node-port-{}.log".format(port),
153+
logfile,
150154
"--cluster-enabled",
151155
"yes",
152156
"--daemonize",
@@ -186,7 +190,7 @@ def generate_cluster_redis_server_args(
186190
redis_server_config_module_part(
187191
command, mod, modules_configuration_parameters_map
188192
)
189-
return command
193+
return command, logfile
190194

191195

192196
def get_cluster_dbfilename(port):

redisbench_admin/run/cluster.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,27 +112,33 @@ def spin_up_redis_cluster_remote_redis(
112112
start_port,
113113
ssh_port,
114114
modules_configuration_parameters_map,
115+
logname,
115116
):
116117
logging.info("Generating the remote redis-server command arguments")
117118
redis_process_commands = []
119+
logfiles = []
120+
logname_prefix = logname[: len(logname) - 4] + "-"
118121
for master_shard_id in range(1, shard_count + 1):
119122
shard_port = master_shard_id + start_port - 1
120123

121-
command = generate_cluster_redis_server_args(
124+
command, logfile = generate_cluster_redis_server_args(
122125
dbdir_folder,
123126
remote_module_files,
124127
server_private_ip,
125128
shard_port,
126129
redis_configuration_parameters,
127130
"yes",
128131
modules_configuration_parameters_map,
132+
logname_prefix,
129133
)
130134
logging.error(
131135
"Remote primary shard {} command: {}".format(
132136
master_shard_id, " ".join(command)
133137
)
134138
)
139+
logfiles.append(logfile)
135140
redis_process_commands.append(" ".join(command))
136141
execute_remote_commands(
137142
server_public_ip, username, private_key, redis_process_commands, ssh_port
138143
)
144+
return logfiles

redisbench_admin/run_remote/remote_db.py

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import datetime
77
import logging
88

9+
import redis
10+
911
from redisbench_admin.environments.oss_cluster import setup_redis_cluster_from_conns
1012
from redisbench_admin.run.cluster import (
1113
spin_up_redis_cluster_remote_redis,
@@ -24,6 +26,7 @@
2426
remote_dataset_folder,
2527
)
2628
from redisbench_admin.run_remote.remote_client import run_remote_client_tool
29+
from redisbench_admin.run_remote.remote_failures import failed_remote_run_artifact_store
2730
from redisbench_admin.run_remote.standalone import (
2831
cp_local_dbdir_to_remote,
2932
remote_module_files_cp,
@@ -84,6 +87,8 @@ def remote_db_spin(
8487
tf_github_sha,
8588
username,
8689
private_key,
90+
s3_bucket_name,
91+
s3_bucket_path,
8792
):
8893
(
8994
_,
@@ -119,7 +124,7 @@ def remote_db_spin(
119124
redis_conns = []
120125
topology_setup_start_time = datetime.datetime.now()
121126
if setup_type == "oss-cluster":
122-
spin_up_redis_cluster_remote_redis(
127+
logfiles = spin_up_redis_cluster_remote_redis(
123128
server_public_ip,
124129
server_private_ip,
125130
username,
@@ -131,19 +136,39 @@ def remote_db_spin(
131136
cluster_start_port,
132137
db_ssh_port,
133138
modules_configuration_parameters_map,
139+
logname,
134140
)
135-
136-
for p in range(cluster_start_port, cluster_start_port + shard_count):
137-
local_redis_conn, ssh_tunnel = ssh_tunnel_redisconn(
138-
p,
139-
server_private_ip,
140-
server_public_ip,
141+
try:
142+
for p in range(cluster_start_port, cluster_start_port + shard_count):
143+
local_redis_conn, ssh_tunnel = ssh_tunnel_redisconn(
144+
p,
145+
server_private_ip,
146+
server_public_ip,
147+
username,
148+
db_ssh_port,
149+
private_key,
150+
)
151+
local_redis_conn.ping()
152+
redis_conns.append(local_redis_conn)
153+
except redis.exceptions.ConnectionError as e:
154+
logging.error("A error occurred while spinning DB: {}".format(e.__str__()))
155+
remote_file = "{}/{}".format(temporary_dir, logfiles[0])
156+
logging.error(
157+
"Trying to fetch DB remote log {} into {}".format(
158+
remote_file, logfiles[0]
159+
)
160+
)
161+
failed_remote_run_artifact_store(
162+
True,
163+
client_public_ip,
164+
dirname,
165+
remote_file,
166+
logfiles[0],
167+
s3_bucket_name,
168+
s3_bucket_path,
141169
username,
142-
db_ssh_port,
143170
private_key,
144171
)
145-
local_redis_conn.ping()
146-
redis_conns.append(local_redis_conn)
147172

148173
if setup_type == "oss-standalone":
149174
full_logfile = spin_up_standalone_remote_redis(

redisbench_admin/run_remote/run_remote.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,8 @@ def run_remote_command_logic(args, project_name, project_version):
317317
tf_github_sha,
318318
username,
319319
private_key,
320+
s3_bucket_name,
321+
s3_bucket_path,
320322
)
321323
if benchmark_type == "read-only":
322324
logging.info(

0 commit comments

Comments
 (0)