Skip to content

Commit

Permalink
Merge pull request #799 from EnterpriseDB/validate-repmgr-options
Browse files Browse the repository at this point in the history
Validate repmgr options
  • Loading branch information
martinmarques authored Mar 8, 2023
2 parents 4021037 + 167d166 commit 02d8e0c
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pgbackupapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ size_t receive_operations_cb(void *content, size_t size, size_t nmemb, char *buf
}

char * define_base_url(operation_task *task) {
char *format = "http://%s:80/servers/%s/operations";
char *format = "http://%s:7480/servers/%s/operations";
char *url = malloc(MAX_BUFFER_LENGTH);

snprintf(url, MAX_BUFFER_LENGTH-1, format, task->host, task->node_name);
Expand Down
31 changes: 31 additions & 0 deletions repmgr-action-standby.c
Original file line number Diff line number Diff line change
Expand Up @@ -7795,6 +7795,7 @@ run_pg_backupapi(t_node_info *local_node_record)
CURL *curl = curl_easy_init();
CURLcode ret;

check_pg_backupapi_standby_clone_options();

task->host = malloc(strlen(config_file_options.pg_backupapi_host)+1);
task->remote_ssh_command = malloc(strlen(config_file_options.pg_backupapi_remote_ssh_command)+1);
Expand Down Expand Up @@ -7858,6 +7859,36 @@ run_pg_backupapi(t_node_info *local_node_record)
return r;
}

/*
* pg_backupapi mode is enabled when config_file_options.pg_backupapi_host is set hence, we
* should also check the other required variables too.
*/

void check_pg_backupapi_standby_clone_options() {

bool error = false;

if (*config_file_options.pg_backupapi_remote_ssh_command == '\0') {
log_hint("Check config: remote ssh command is required");
error = true;
}
if (*config_file_options.pg_backupapi_node_name == '\0') {
log_hint("Check config: node name is required");
error = true;
}
if (*config_file_options.pg_backupapi_backup_id == '\0') {
log_hint("Check config: backup_id is required");
error = true;
}

if (error == true) {
log_error("Please fix the errors and try again");
exit(ERR_BAD_CONFIG);
}

}



static char *
make_barman_ssh_command(char *buf)
Expand Down
2 changes: 1 addition & 1 deletion repmgr-action-standby.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ extern void do_standby_help(void);

extern bool do_standby_follow_internal(PGconn *primary_conn, PGconn *follow_target_conn, t_node_info *follow_target_node_record, PQExpBufferData *output, int general_error_code, int *error_code);


void check_pg_backupapi_standby_clone_options(void);

#endif /* _REPMGR_ACTION_STANDBY_H_ */

0 comments on commit 02d8e0c

Please sign in to comment.