This is an automated email from the ASF dual-hosted git repository.
dataroaring pushed a commit to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-3.0 by this push:
new aa67fd84ca4 branch-3.0: [fix](cloud) Some resource APIs should not
check if cluster_name is empty #50148 (#51046)
aa67fd84ca4 is described below
commit aa67fd84ca410ab05e6e2c18c0cb1acea24e082c
Author: deardeng <[email protected]>
AuthorDate: Tue May 20 09:27:33 2025 +0800
branch-3.0: [fix](cloud) Some resource APIs should not check if
cluster_name is empty #50148 (#51046)
cherry pick from #50148
---
cloud/src/meta-service/meta_service_resource.cpp | 8 ++++----
cloud/src/resource-manager/resource_manager.cpp | 7 ++++---
cloud/src/resource-manager/resource_manager.h | 22 ++++++++++++++++++++--
3 files changed, 28 insertions(+), 9 deletions(-)
diff --git a/cloud/src/meta-service/meta_service_resource.cpp
b/cloud/src/meta-service/meta_service_resource.cpp
index 96a00a48e97..eb88694ff57 100644
--- a/cloud/src/meta-service/meta_service_resource.cpp
+++ b/cloud/src/meta-service/meta_service_resource.cpp
@@ -2087,7 +2087,7 @@ void
MetaServiceImpl::alter_cluster(google::protobuf::RpcController* controller,
});
} break;
case AlterClusterRequest::ADD_NODE: {
- resource_mgr_->check_cluster_params_valid(request->cluster(), &msg,
false);
+ resource_mgr_->check_cluster_params_valid(request->cluster(), &msg,
false, false);
if (msg != "") {
LOG(WARNING) << msg;
break;
@@ -2111,7 +2111,7 @@ void
MetaServiceImpl::alter_cluster(google::protobuf::RpcController* controller,
msg = resource_mgr_->modify_nodes(instance_id, to_add, to_del);
} break;
case AlterClusterRequest::DROP_NODE: {
- resource_mgr_->check_cluster_params_valid(request->cluster(), &msg,
false);
+ resource_mgr_->check_cluster_params_valid(request->cluster(), &msg,
false, false);
if (msg != "") {
LOG(WARNING) << msg;
break;
@@ -2134,7 +2134,7 @@ void
MetaServiceImpl::alter_cluster(google::protobuf::RpcController* controller,
msg = resource_mgr_->modify_nodes(instance_id, to_add, to_del);
} break;
case AlterClusterRequest::DECOMMISSION_NODE: {
- resource_mgr_->check_cluster_params_valid(request->cluster(), &msg,
false);
+ resource_mgr_->check_cluster_params_valid(request->cluster(), &msg,
false, false);
if (msg != "") {
LOG(WARNING) << msg;
break;
@@ -2196,7 +2196,7 @@ void
MetaServiceImpl::alter_cluster(google::protobuf::RpcController* controller,
}
} break;
case AlterClusterRequest::NOTIFY_DECOMMISSIONED: {
- resource_mgr_->check_cluster_params_valid(request->cluster(), &msg,
false);
+ resource_mgr_->check_cluster_params_valid(request->cluster(), &msg,
false, false);
if (msg != "") {
LOG(WARNING) << msg;
break;
diff --git a/cloud/src/resource-manager/resource_manager.cpp
b/cloud/src/resource-manager/resource_manager.cpp
index d08af6ef4e4..cd0381b7189 100644
--- a/cloud/src/resource-manager/resource_manager.cpp
+++ b/cloud/src/resource-manager/resource_manager.cpp
@@ -140,7 +140,7 @@ std::string ResourceManager::get_node(const std::string&
cloud_unique_id,
}
bool ResourceManager::check_cluster_params_valid(const ClusterPB& cluster,
std::string* err,
- bool check_master_num) {
+ bool check_master_num, bool
check_cluster_name) {
// check
if (!cluster.has_type()) {
*err = "cluster must have type arg";
@@ -155,7 +155,7 @@ bool ResourceManager::check_cluster_params_valid(const
ClusterPB& cluster, std::
return false;
}
- if (!cluster.has_cluster_name() || cluster.cluster_name() == "") {
+ if (check_cluster_name && (!cluster.has_cluster_name() ||
cluster.cluster_name() == "")) {
*err = "not have cluster name";
return false;
}
@@ -315,7 +315,8 @@ std::pair<MetaServiceCode, std::string>
ResourceManager::add_cluster(const std::
std::unique_ptr<int, std::function<void(int*)>> defer(
(int*)0x01, [&msg](int*) { LOG(INFO) << "add_cluster err=" << msg;
});
- if (!check_cluster_params_valid(cluster.cluster, &msg, true)) {
+ // just check cluster_name not empty in add_cluster
+ if (!check_cluster_params_valid(cluster.cluster, &msg, true, true)) {
LOG(WARNING) << msg;
return std::make_pair(MetaServiceCode::INVALID_ARGUMENT, msg);
}
diff --git a/cloud/src/resource-manager/resource_manager.h
b/cloud/src/resource-manager/resource_manager.h
index 21f09d34a37..7d411e9059f 100644
--- a/cloud/src/resource-manager/resource_manager.h
+++ b/cloud/src/resource-manager/resource_manager.h
@@ -108,13 +108,31 @@ public:
virtual std::pair<TxnErrorCode, std::string>
get_instance(std::shared_ptr<Transaction> txn,
const
std::string& instance_id,
InstanceInfoPB*
inst_pb);
- // return err msg
+ /**
+ * Modifies the nodes associated with a given instance.
+ * This function allows adding and removing nodes from the instance.
+ *
+ * @param instance_id The ID of the instance to modify nodes for.
+ * @param to_add A vector of NodeInfo structures representing nodes to be
added.
+ * @param to_del A vector of NodeInfo structures representing nodes to be
removed.
+ * @return An error message if the operation fails, or an empty string for
success.
+ */
virtual std::string modify_nodes(const std::string& instance_id,
const std::vector<NodeInfo>& to_add,
const std::vector<NodeInfo>& to_del);
+ /**
+ * Checks the validity of the parameters for a cluster.
+ * This function verifies if the provided cluster parameters meet the
required conditions.
+ *
+ * @param cluster The ClusterPB structure containing the cluster
parameters to validate.
+ * @param err Output parameter to store any error message if validation
fails.
+ * @param check_master_num Flag indicating whether to check the number of
master nodes.
+ * @param check_cluster_name Flag indicating whether to check the cluster
name is empty, just add_cluster need.
+ * @return True if the parameters are valid, false otherwise.
+ */
bool check_cluster_params_valid(const ClusterPB& cluster, std::string* err,
- bool check_master_num);
+ bool check_master_num, bool
check_cluster_name);
/**
* Check cloud_unique_id is degraded format, and get instance_id from
cloud_unique_id
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]