This is an automated email from the ASF dual-hosted git repository. dataroaring pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push: new df11c8c1e13 [enhance](Cloud) Unify s3 and hdfs vault's check existence logic (#34060) df11c8c1e13 is described below commit df11c8c1e13a69fa20ec4d5d7a55e2edd5b357be Author: AlexYue <yj976240...@gmail.com> AuthorDate: Thu Apr 25 11:24:21 2024 +0800 [enhance](Cloud) Unify s3 and hdfs vault's check existence logic (#34060) --- cloud/src/meta-service/meta_service_resource.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/cloud/src/meta-service/meta_service_resource.cpp b/cloud/src/meta-service/meta_service_resource.cpp index 57220e50c5e..1dd04617cc4 100644 --- a/cloud/src/meta-service/meta_service_resource.cpp +++ b/cloud/src/meta-service/meta_service_resource.cpp @@ -374,13 +374,6 @@ static int add_hdfs_storage_vault(InstanceInfoPB& instance, Transaction* txn, msg = fmt::format("vault_name={} passed invalid argument", hdfs_param.name()); return -1; } - if (std::find_if(instance.storage_vault_names().begin(), instance.storage_vault_names().end(), - [&hdfs_param](const auto& name) { return name == hdfs_param.name(); }) != - instance.storage_vault_names().end()) { - code = MetaServiceCode::ALREADY_EXISTED; - msg = fmt::format("vault_name={} already created", hdfs_param.name()); - return -1; - } using namespace detail; // Check and normalize hdfs conf @@ -472,13 +465,23 @@ static void create_object_info_with_encrypt(const InstanceInfoPB& instance, Obje static int add_vault_into_instance(InstanceInfoPB& instance, Transaction* txn, StorageVaultPB& vault_param, MetaServiceCode& code, std::string& msg) { + if (std::find_if(instance.storage_vault_names().begin(), instance.storage_vault_names().end(), + [&vault_param](const auto& name) { return name == vault_param.name(); }) != + instance.storage_vault_names().end()) { + code = MetaServiceCode::ALREADY_EXISTED; + msg = fmt::format("vault_name={} already created", vault_param.name()); + return -1; + } + if (vault_param.has_hdfs_info()) { return add_hdfs_storage_vault(instance, txn, vault_param, code, msg); } + create_object_info_with_encrypt(instance, vault_param.mutable_obj_info(), true, code, msg); if (code != MetaServiceCode::OK) { return -1; } + vault_param.mutable_obj_info()->CopyFrom(vault_param.obj_info()); vault_param.set_id(vault_param.obj_info().id()); auto vault_key = storage_vault_key({instance.instance_id(), vault_param.obj_info().id()}); @@ -757,7 +760,7 @@ void MetaServiceImpl::alter_obj_store_info(google::protobuf::RpcController* cont } } break; case AlterObjStoreInfoRequest::ADD_HDFS_INFO: { - if (auto ret = add_hdfs_storage_vault( + if (auto ret = add_vault_into_instance( instance, txn.get(), const_cast<StorageVaultPB&>(request->vault()), code, msg); ret != 0) { return; @@ -773,7 +776,7 @@ void MetaServiceImpl::alter_obj_store_info(google::protobuf::RpcController* cont msg = ss.str(); return; } - if (auto ret = add_hdfs_storage_vault( + if (auto ret = add_vault_into_instance( instance, txn.get(), const_cast<StorageVaultPB&>(request->vault()), code, msg); ret != 0) { return; --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org