From 2ff8c027c09cba7f059d815beb1d9caec03a7efc Mon Sep 17 00:00:00 2001 From: Yingchun Lai Date: Wed, 29 Nov 2023 19:33:34 +0800 Subject: [PATCH] feat(ddl_client): add failure logs when backup or restore command failed (#1701) - Print `hint_message` when `add_backup_policy`, `disable_backup_policy`, `enable_backup_policy` or `update_backup_policy` failed. The hint messages are currently used in admin-cli only. - Return corresponding error code when `query_restore` failed. --- src/client/replication_ddl_client.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/client/replication_ddl_client.cpp b/src/client/replication_ddl_client.cpp index 32a7809825..e086613050 100644 --- a/src/client/replication_ddl_client.cpp +++ b/src/client/replication_ddl_client.cpp @@ -1048,6 +1048,7 @@ dsn::error_code replication_ddl_client::add_backup_policy(const std::string &pol ::dsn::unmarshall(resp_task->get_response(), resp); if (resp.err != ERR_OK) { + std::cout << "add backup policy failed: " << resp.hint_message << std::endl; return resp.err; } else { std::cout << "add backup policy succeed, policy_name = " << policy_name << std::endl; @@ -1095,6 +1096,7 @@ dsn::error_code replication_ddl_client::disable_backup_policy(const std::string configuration_modify_backup_policy_response resp; ::dsn::unmarshall(resp_task->get_response(), resp); if (resp.err != ERR_OK) { + std::cout << "disable backup policy failed: " << resp.hint_message << std::endl; return resp.err; } else { std::cout << "disable policy result: " << resp.err.to_string() << std::endl; @@ -1123,6 +1125,7 @@ dsn::error_code replication_ddl_client::enable_backup_policy(const std::string & configuration_modify_backup_policy_response resp; ::dsn::unmarshall(resp_task->get_response(), resp); if (resp.err != ERR_OK) { + std::cout << "enable backup policy failed: " << resp.hint_message << std::endl; return resp.err; } else if (resp.err == ERR_BUSY) { std::cout << "policy is under backup, please try disable later" << std::endl; @@ -1274,6 +1277,7 @@ replication_ddl_client::update_backup_policy(const std::string &policy_name, configuration_modify_backup_policy_response resp; ::dsn::unmarshall(resp_task->get_response(), resp); if (resp.err != ERR_OK) { + std::cout << "modify backup policy failed: " << resp.hint_message << std::endl; return resp.err; } else { std::cout << "Modify policy result: " << resp.err.to_string() << std::endl; @@ -1350,6 +1354,8 @@ dsn::error_code replication_ddl_client::query_restore(int32_t restore_app_id, bo } else if (response.err == ERR_APP_DROPPED) { std::cout << "restore failed, because some partition's data is damaged on cold backup media" << std::endl; + } else { + return response.err; } return ERR_OK; }