gavinchou commented on code in PR #46221:
URL: https://github.com/apache/doris/pull/46221#discussion_r1900422299


##########
cloud/src/resource-manager/resource_manager.cpp:
##########
@@ -521,6 +522,31 @@ std::string ResourceManager::update_cluster(
 
     auto& clusters = 
const_cast<std::decay_t<decltype(instance.clusters())>&>(instance.clusters());
 
+    // check cluster_name is empty cluster, if empty and drop_empty_cluster == 
true, drop it
+    if (drop_empty_cluster) {
+        auto it = cluster_names.find(cluster_name);
+        if (it != cluster_names.end()) {
+            // found it, if it's an empty cluster, drop it from instance
+            int idx = -1;
+            for (auto& cluster : instance.clusters()) {
+                idx++;
+                if (cluster.cluster_name() == cluster_name) {
+                    // Check if cluster is empty (has no nodes)
+                    if (cluster.nodes_size() == 0) {
+                        // Remove empty cluster from instance
+                        auto& clusters = 
const_cast<std::decay_t<decltype(instance.clusters())>&>(
+                                instance.clusters());
+                        clusters.DeleteSubrange(idx, 1);
+                        // Remove cluster name from set
+                        cluster_names.erase(cluster_name);
+                        LOG(INFO) << "Removed empty cluster, cluster_name=" << 
cluster_name;

Review Comment:
   suggest log, print the reasone
   "remove empty cluster due to it is the target of a `rename_cluster`, 
cluster_name="



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to