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 67d6fee385d [fix](cloud) Skip cluster name validation check if it not 
set (#35050)
67d6fee385d is described below

commit 67d6fee385d903340d9a06da46b6741b5bdd65e6
Author: walter <w41te...@gmail.com>
AuthorDate: Tue May 21 13:58:47 2024 +0800

    [fix](cloud) Skip cluster name validation check if it not set (#35050)
---
 cloud/src/common/config.h                       |  2 ++
 cloud/src/resource-manager/resource_manager.cpp |  3 ++-
 cloud/test/fdb_injection_test.cpp               |  6 ++----
 cloud/test/mem_txn_kv_test.cpp                  |  2 --
 cloud/test/meta_service_http_test.cpp           | 12 ++++++++++++
 cloud/test/txn_kv_test.cpp                      |  2 --
 6 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/cloud/src/common/config.h b/cloud/src/common/config.h
index 805cc712c40..66194b51f27 100644
--- a/cloud/src/common/config.h
+++ b/cloud/src/common/config.h
@@ -187,4 +187,6 @@ CONF_mBool(enable_distinguish_hdfs_path, "true");
 // If no IP match this rule, a random IP is used (usually it is the IP binded 
to hostname).
 CONF_String(priority_networks, "");
 
+CONF_Bool(enable_cluster_name_check, "false");
+
 } // namespace doris::cloud::config
diff --git a/cloud/src/resource-manager/resource_manager.cpp 
b/cloud/src/resource-manager/resource_manager.cpp
index 5de14f84a5b..e04c2effeff 100644
--- a/cloud/src/resource-manager/resource_manager.cpp
+++ b/cloud/src/resource-manager/resource_manager.cpp
@@ -148,7 +148,8 @@ bool ResourceManager::check_cluster_params_valid(const 
ClusterPB& cluster, std::
 
     const char* cluster_pattern_str = "^[a-zA-Z][a-zA-Z0-9_]*$";
     std::regex txt_regex(cluster_pattern_str);
-    if (!std::regex_match(cluster.cluster_name(), txt_regex)) {
+    if (config::enable_cluster_name_check && cluster.has_cluster_name() &&
+        !std::regex_match(cluster.cluster_name(), txt_regex)) {
         *err = "cluster name not regex with ^[a-zA-Z][a-zA-Z0-9_]*$, please 
check it";
         return false;
     }
diff --git a/cloud/test/fdb_injection_test.cpp 
b/cloud/test/fdb_injection_test.cpp
index 921ea4fcec6..90db4dbb7e8 100644
--- a/cloud/test/fdb_injection_test.cpp
+++ b/cloud/test/fdb_injection_test.cpp
@@ -70,8 +70,6 @@ int main(int argc, char** argv) {
     cloud::config::txn_store_retry_base_intervals_ms = 1;
     cloud::config::fdb_cluster_file_path = "fdb.cluster";
     cloud::config::write_schema_kv = true;
-    // UT may be run without fdb, it will take unnecessary time with the 
default value
-    cloud::config::fdb_txn_timeout_ms = 500;
 
     auto sp = cloud::SyncPoint::get_instance();
     sp->enable_processing();
@@ -258,7 +256,7 @@ static int add_cluster(MetaService* service, const 
std::string& instance_id) {
         req.set_instance_id(instance_id);
         
req.set_op(cloud::AlterClusterRequest_Operation::AlterClusterRequest_Operation_ADD_CLUSTER);
         auto* cluster = req.mutable_cluster();
-        auto name = fmt::format("instance-{}-cluster", instance_id);
+        auto name = fmt::format("instance_{}_cluster", instance_id);
         cluster->set_cluster_id(name);
         cluster->set_cluster_name(name);
         cluster->set_type(cloud::ClusterPB_Type::ClusterPB_Type_SQL);
@@ -308,7 +306,7 @@ static int drop_cluster(MetaService* service, const 
std::string& instance_id) {
     req.set_instance_id(instance_id);
     req.set_op(AlterClusterRequest_Operation_DROP_CLUSTER);
     auto cluster = req.mutable_cluster();
-    cluster->set_cluster_id(fmt::format("instance-{}-cluster", instance_id));
+    cluster->set_cluster_id(fmt::format("instance_{}_cluster", instance_id));
 
     brpc::Controller ctrl;
     service->alter_cluster(&ctrl, &req, &resp, nullptr);
diff --git a/cloud/test/mem_txn_kv_test.cpp b/cloud/test/mem_txn_kv_test.cpp
index c7ab3c62f08..9db71ba96c8 100644
--- a/cloud/test/mem_txn_kv_test.cpp
+++ b/cloud/test/mem_txn_kv_test.cpp
@@ -35,8 +35,6 @@ std::shared_ptr<cloud::TxnKv> fdb_txn_kv;
 int main(int argc, char** argv) {
     cloud::config::init(nullptr, true);
     cloud::config::fdb_cluster_file_path = "fdb.cluster";
-    // UT may be run without fdb, it will take unnecessary time with the 
default value
-    cloud::config::fdb_txn_timeout_ms = 500;
     fdb_txn_kv = 
std::dynamic_pointer_cast<cloud::TxnKv>(std::make_shared<cloud::FdbTxnKv>());
     if (!fdb_txn_kv.get()) {
         std::cout << "exit get FdbTxnKv error" << std::endl;
diff --git a/cloud/test/meta_service_http_test.cpp 
b/cloud/test/meta_service_http_test.cpp
index 6ff399a27e6..7e612f55780 100644
--- a/cloud/test/meta_service_http_test.cpp
+++ b/cloud/test/meta_service_http_test.cpp
@@ -596,6 +596,8 @@ TEST(MetaServiceHttpTest, InstanceTestWithVersion) {
 }
 
 TEST(MetaServiceHttpTest, AlterClusterTest) {
+    config::enable_cluster_name_check = true;
+
     HttpContext ctx;
     {
         CreateInstanceRequest req;
@@ -685,6 +687,16 @@ TEST(MetaServiceHttpTest, AlterClusterTest) {
         ASSERT_EQ(resp.code(), MetaServiceCode::INVALID_ARGUMENT);
     }
 
+    {
+        AlterClusterRequest req;
+        req.set_instance_id(mock_instance);
+        req.mutable_cluster()->set_type(ClusterPB::COMPUTE);
+        req.mutable_cluster()->set_cluster_id(mock_cluster_id + "1");
+        auto [status_code, resp] = 
ctx.forward<MetaServiceResponseStatus>("add_cluster", req);
+        ASSERT_EQ(status_code, 200);
+        ASSERT_EQ(resp.code(), MetaServiceCode::OK);
+    }
+
     // case: request has invalid argument
     {
         AlterClusterRequest req;
diff --git a/cloud/test/txn_kv_test.cpp b/cloud/test/txn_kv_test.cpp
index b3bfd4f0388..63a89a07434 100644
--- a/cloud/test/txn_kv_test.cpp
+++ b/cloud/test/txn_kv_test.cpp
@@ -42,8 +42,6 @@ std::shared_ptr<TxnKv> txn_kv;
 
 void init_txn_kv() {
     config::fdb_cluster_file_path = "fdb.cluster";
-    // UT may be run without fdb, it will take unnecessary time with the 
default value
-    config::fdb_txn_timeout_ms = 500;
     txn_kv = std::dynamic_pointer_cast<TxnKv>(std::make_shared<FdbTxnKv>());
     ASSERT_NE(txn_kv.get(), nullptr);
     int ret = txn_kv->init();


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to