Skip to content

Commit

Permalink
feat(ddl_client): add failure logs when backup or restore command fai…
Browse files Browse the repository at this point in the history
…led (apache#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.
  • Loading branch information
acelyc111 authored Nov 29, 2023
1 parent 432499f commit 2ff8c02
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/client/replication_ddl_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 2ff8c02

Please sign in to comment.