gavinchou commented on code in PR #38685: URL: https://github.com/apache/doris/pull/38685#discussion_r1711124321
########## cloud/src/meta-service/meta_service_resource.cpp: ########## @@ -510,13 +519,124 @@ static void set_default_vault_log_helper(const InstanceInfoPB& instance, LOG(INFO) << vault_msg; } +static int alter_hdfs_storage_vault(InstanceInfoPB& instance, std::unique_ptr<Transaction> txn, + const StorageVaultPB& vault, MetaServiceCode& code, + std::string& msg) { + if (!vault.has_hdfs_info()) { + code = MetaServiceCode::INVALID_ARGUMENT; + std::stringstream ss; + ss << "There is no hdfs vault provided"; + msg = ss.str(); + return -1; + } + const auto& hdfs_info = vault.hdfs_info(); + if (hdfs_info.has_prefix() || !hdfs_info.has_build_conf() || + hdfs_info.build_conf().has_fs_name()) { + code = MetaServiceCode::INVALID_ARGUMENT; + std::stringstream ss; + ss << "You can not alter prefix or fs name because it might lose previoud written data"; + msg = ss.str(); + return -1; + } + const auto& name = vault.name(); + // Here we try to get mutable iter since we might need to alter the vault name + auto name_itr = std::find_if(instance.mutable_storage_vault_names()->begin(), + instance.mutable_storage_vault_names()->end(), + [&](const auto& vault_name) { return name == vault_name; }); + if (name_itr == instance.storage_vault_names().end()) { + code = MetaServiceCode::INVALID_ARGUMENT; + std::stringstream ss; + ss << "invalid storage vault name, not found, name =" << name; + msg = ss.str(); + return -1; + } + auto pos = name_itr - instance.storage_vault_names().begin(); + std::string vault_id = instance.resource_ids().begin()[pos]; + auto vault_key = storage_vault_key({instance.instance_id(), vault_id}); + std::string val; + + auto err = txn->get(vault_key, &val); + LOG(INFO) << "get vault_key=" << hex(vault_key); Review Comment: print the entire original info. ########## cloud/src/meta-service/meta_service_resource.cpp: ########## @@ -40,6 +41,14 @@ using namespace std::chrono; +namespace { +constexpr char pattern_str[] = "^[a-zA-Z][0-9a-zA-Z_]*$"; +bool isValidStorageVaultName(const std::string& str) { Review Comment: naming and add an UT for it -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org