From c8dd6744da8535c5363007989b337d3c906a31af Mon Sep 17 00:00:00 2001 From: Malavan Sotheeswaran <105669860+msotheeswaran@users.noreply.github.com> Date: Wed, 8 Mar 2023 16:00:44 -0500 Subject: [PATCH] Add config for AWS s3 rdb save/load. (#591) * add s3 config * missing include * ignore s3 config in config test * Update introspection.tcl * Update config.cpp --- src/config.cpp | 28 ++++++++++++++++++++++++++++ tests/unit/introspection.tcl | 7 ++++--- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/config.cpp b/src/config.cpp index 110e8ab85..4d5b77706 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -35,6 +35,7 @@ #include #include +#include #ifdef __linux__ #include #endif @@ -2456,6 +2457,32 @@ static int isValidAOFfilename(char *val, const char **err) { return 1; } +static int isValidS3Bucket(char *s3bucket, const char **err) { + int status = EXIT_FAILURE; + pid_t pid = fork(); + if (pid < 0) + { + *err = "couldn't fork to call aws cli"; + return 0; + } + + if (pid == 0) + { + execlp("aws", "aws", "s3", "ls", s3bucket); + exit(EXIT_FAILURE); + } + else + { + waitpid(pid, &status, 0); + } + + if (status != EXIT_SUCCESS) { + *err = "could not access s3 bucket"; + return 0; + } + return 1; +} + /* Validate specified string is a valid proc-title-template */ static int isValidProcTitleTemplate(char *val, const char **err) { if (!validateProcTitleTemplate(val)) { @@ -2803,6 +2830,7 @@ standardConfig configs[] = { createStringConfig("cluster-announce-ip", NULL, MODIFIABLE_CONFIG, EMPTY_STRING_IS_NULL, g_pserver->cluster_announce_ip, NULL, NULL, NULL), createStringConfig("syslog-ident", NULL, IMMUTABLE_CONFIG, ALLOW_EMPTY_STRING, g_pserver->syslog_ident, "redis", NULL, NULL), createStringConfig("dbfilename", NULL, MODIFIABLE_CONFIG, ALLOW_EMPTY_STRING, g_pserver->rdb_filename, CONFIG_DEFAULT_RDB_FILENAME, isValidDBfilename, NULL), + createStringConfig("db-s3-object", NULL, MODIFIABLE_CONFIG, EMPTY_STRING_IS_NULL, g_pserver->rdb_s3bucketpath, NULL, isValidS3Bucket, NULL), createStringConfig("appendfilename", NULL, IMMUTABLE_CONFIG, ALLOW_EMPTY_STRING, g_pserver->aof_filename, "appendonly.aof", isValidAOFfilename, NULL), createStringConfig("server_cpulist", NULL, IMMUTABLE_CONFIG, EMPTY_STRING_IS_NULL, g_pserver->server_cpulist, NULL, NULL, NULL), createStringConfig("bio_cpulist", NULL, IMMUTABLE_CONFIG, EMPTY_STRING_IS_NULL, g_pserver->bio_cpulist, NULL, NULL, NULL), diff --git a/tests/unit/introspection.tcl b/tests/unit/introspection.tcl index 66414c85f..7678a1dd5 100644 --- a/tests/unit/introspection.tcl +++ b/tests/unit/introspection.tcl @@ -162,15 +162,16 @@ start_server {tags {"introspection"}} { aof_rewrite_cpulist time-thread-priority bgsave_cpulist - storage-cache-mode - storage-provider-options - use-fork + storage-cache-mode + storage-provider-options + use-fork multi-master active-replica bind set-proc-title repl-backlog-disk-reserve tls-allowlist + db-s3-object } if {!$::tls} {