Skip to content

Commit 8ca459f

Browse files
Tyler WilsonStanislav Datskevych
authored andcommitted
Pull request apache#13: PCS-2364 - Add community PR 10603
Merge in CLOUD/cloudstack from PCS-2364 to 4.20-leaseweb * commit '99f3b780433d78153387e71a9b8fe24f5afaf0a6': PCS-2364 - Add community PR 10603
2 parents 13eef3e + 99f3b78 commit 8ca459f

File tree

2 files changed

+135
-0
lines changed

2 files changed

+135
-0
lines changed
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
From 154743a1b4b141437d7a65250027b5c6c0cb777e Mon Sep 17 00:00:00 2001
2+
From: Pearl Dsilva <[email protected]>
3+
Date: Fri, 21 Mar 2025 07:45:23 -0400
4+
Subject: [PATCH 1/4] Fix issue with allocator not considering subsequent
5+
clusters
6+
7+
---
8+
.../agent/manager/allocator/impl/RandomAllocator.java | 6 +++---
9+
.../agent/manager/allocator/impl/FirstFitAllocator.java | 7 +++----
10+
2 files changed, 6 insertions(+), 7 deletions(-)
11+
12+
diff --git a/plugins/host-allocators/random/src/main/java/com/cloud/agent/manager/allocator/impl/RandomAllocator.java b/plugins/host-allocators/random/src/main/java/com/cloud/agent/manager/allocator/impl/RandomAllocator.java
13+
index 53e44ab5aab7..4005249e648f 100644
14+
--- a/plugins/host-allocators/random/src/main/java/com/cloud/agent/manager/allocator/impl/RandomAllocator.java
15+
+++ b/plugins/host-allocators/random/src/main/java/com/cloud/agent/manager/allocator/impl/RandomAllocator.java
16+
@@ -94,15 +94,15 @@ private List<Host> findSuitableHosts(VirtualMachineProfile vmProfile, Deployment
17+
return suitableHosts;
18+
}
19+
String offeringHostTag = offering.getHostTag();
20+
+
21+
VMTemplateVO template = (VMTemplateVO)vmProfile.getTemplate();
22+
String templateTag = template.getTemplateTag();
23+
String hostTag = null;
24+
if (ObjectUtils.anyNull(offeringHostTag, templateTag)) {
25+
hostTag = offeringHostTag;
26+
- hostTag = hostTag == null ? templateTag : String.format("%s, %s", hostTag, templateTag);
27+
- logger.debug(String.format("Looking for hosts in dc [%s], pod [%s], cluster [%s] and complying with host tag(s): [%s]", dcId, podId, clusterId, hostTag));
28+
+ logger.debug("Looking for hosts in dc [{}], pod [{}], cluster [{}] and complying with host tag(s): [{}]", dcId, podId, clusterId, hostTag);
29+
} else {
30+
- logger.debug("Looking for hosts in dc: " + dcId + " pod:" + podId + " cluster:" + clusterId);
31+
+ logger.debug("Looking for hosts in dc: {} pod: {} cluster: {}", dcId , podId, clusterId);
32+
}
33+
if (hosts != null) {
34+
// retain all computing hosts, regardless of whether they support routing...it's random after all
35+
diff --git a/server/src/main/java/com/cloud/agent/manager/allocator/impl/FirstFitAllocator.java b/server/src/main/java/com/cloud/agent/manager/allocator/impl/FirstFitAllocator.java
36+
index 4a5f80571ae7..89857994b094 100644
37+
--- a/server/src/main/java/com/cloud/agent/manager/allocator/impl/FirstFitAllocator.java
38+
+++ b/server/src/main/java/com/cloud/agent/manager/allocator/impl/FirstFitAllocator.java
39+
@@ -130,8 +130,8 @@ public List<Host> allocateTo(VirtualMachineProfile vmProfile, DeploymentPlan pla
40+
// FirstFitAllocator should be used for user VMs only since it won't care whether the host is capable of routing or not
41+
return new ArrayList<>();
42+
}
43+
-
44+
- logger.debug("Looking for hosts in zone [{}], pod [{}], cluster [{}]", dcId, podId, clusterId);
45+
+ String paramAsStringToLog = String.format("zone [%s], pod [%s], cluster [%s]", dcId, podId, clusterId);
46+
+ logger.debug("Looking for hosts in {}", paramAsStringToLog);
47+
48+
String hostTagOnOffering = offering.getHostTag();
49+
String hostTagOnTemplate = template.getTemplateTag();
50+
@@ -203,8 +203,7 @@ public List<Host> allocateTo(VirtualMachineProfile vmProfile, DeploymentPlan pla
51+
52+
53+
if (clusterHosts.isEmpty()) {
54+
- logger.error("No suitable host found for vm [{}] with tags [{}].", vmProfile, hostTagOnOffering);
55+
- throw new CloudRuntimeException(String.format("No suitable host found for vm [%s].", vmProfile));
56+
+ logger.warn("No suitable host found for VM [{}] with tags {} in {}.", vmProfile, hostTagOnOffering, paramAsStringToLog);
57+
}
58+
// add all hosts that we are not considering to the avoid list
59+
List<HostVO> allhostsInCluster = _hostDao.listAllUpAndEnabledNonHAHosts(type, clusterId, podId, dcId, null);
60+
61+
From 63f659c1084745e99a51a64a2e5a08c922c2843a Mon Sep 17 00:00:00 2001
62+
From: Pearl Dsilva <[email protected]>
63+
Date: Fri, 21 Mar 2025 08:15:33 -0400
64+
Subject: [PATCH 2/4] add missing return
65+
66+
---
67+
.../cloud/agent/manager/allocator/impl/FirstFitAllocator.java | 1 +
68+
1 file changed, 1 insertion(+)
69+
70+
diff --git a/server/src/main/java/com/cloud/agent/manager/allocator/impl/FirstFitAllocator.java b/server/src/main/java/com/cloud/agent/manager/allocator/impl/FirstFitAllocator.java
71+
index 89857994b094..c3858bf0a91a 100644
72+
--- a/server/src/main/java/com/cloud/agent/manager/allocator/impl/FirstFitAllocator.java
73+
+++ b/server/src/main/java/com/cloud/agent/manager/allocator/impl/FirstFitAllocator.java
74+
@@ -204,6 +204,7 @@ public List<Host> allocateTo(VirtualMachineProfile vmProfile, DeploymentPlan pla
75+
76+
if (clusterHosts.isEmpty()) {
77+
logger.warn("No suitable host found for VM [{}] with tags {} in {}.", vmProfile, hostTagOnOffering, paramAsStringToLog);
78+
+ return null;
79+
}
80+
// add all hosts that we are not considering to the avoid list
81+
List<HostVO> allhostsInCluster = _hostDao.listAllUpAndEnabledNonHAHosts(type, clusterId, podId, dcId, null);
82+
83+
From d879560776b29729987658c00541d22203b364c4 Mon Sep 17 00:00:00 2001
84+
From: Pearl Dsilva <[email protected]>
85+
Date: Fri, 21 Mar 2025 08:41:03 -0400
86+
Subject: [PATCH 3/4] remove unused import
87+
88+
---
89+
.../cloud/agent/manager/allocator/impl/FirstFitAllocator.java | 1 -
90+
1 file changed, 1 deletion(-)
91+
92+
diff --git a/server/src/main/java/com/cloud/agent/manager/allocator/impl/FirstFitAllocator.java b/server/src/main/java/com/cloud/agent/manager/allocator/impl/FirstFitAllocator.java
93+
index c3858bf0a91a..590db3406c25 100644
94+
--- a/server/src/main/java/com/cloud/agent/manager/allocator/impl/FirstFitAllocator.java
95+
+++ b/server/src/main/java/com/cloud/agent/manager/allocator/impl/FirstFitAllocator.java
96+
@@ -25,7 +25,6 @@
97+
import javax.inject.Inject;
98+
import javax.naming.ConfigurationException;
99+
100+
-import com.cloud.utils.exception.CloudRuntimeException;
101+
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
102+
import org.apache.cloudstack.utils.reflectiontostringbuilderutils.ReflectionToStringBuilderUtils;
103+
import org.springframework.stereotype.Component;
104+
105+
From 0977c5ca5fd306615e11491de3496abd6d62fd5b Mon Sep 17 00:00:00 2001
106+
From: Pearl Dsilva <[email protected]>
107+
Date: Tue, 25 Mar 2025 16:16:10 -0400
108+
Subject: [PATCH 4/4] update as per inputs
109+
110+
---
111+
.../cloud/agent/manager/allocator/impl/RandomAllocator.java | 6 ++++--
112+
1 file changed, 4 insertions(+), 2 deletions(-)
113+
114+
diff --git a/plugins/host-allocators/random/src/main/java/com/cloud/agent/manager/allocator/impl/RandomAllocator.java b/plugins/host-allocators/random/src/main/java/com/cloud/agent/manager/allocator/impl/RandomAllocator.java
115+
index 4005249e648f..42129944a194 100644
116+
--- a/plugins/host-allocators/random/src/main/java/com/cloud/agent/manager/allocator/impl/RandomAllocator.java
117+
+++ b/plugins/host-allocators/random/src/main/java/com/cloud/agent/manager/allocator/impl/RandomAllocator.java
118+
@@ -98,8 +98,10 @@ private List<Host> findSuitableHosts(VirtualMachineProfile vmProfile, Deployment
119+
VMTemplateVO template = (VMTemplateVO)vmProfile.getTemplate();
120+
String templateTag = template.getTemplateTag();
121+
String hostTag = null;
122+
- if (ObjectUtils.anyNull(offeringHostTag, templateTag)) {
123+
- hostTag = offeringHostTag;
124+
+ if (ObjectUtils.anyNotNull(offeringHostTag, templateTag)) {
125+
+ hostTag = ObjectUtils.allNotNull(offeringHostTag, templateTag) ?
126+
+ String.format("%s, %s", offeringHostTag, templateTag) :
127+
+ ObjectUtils.firstNonNull(offeringHostTag, templateTag);
128+
logger.debug("Looking for hosts in dc [{}], pod [{}], cluster [{}] and complying with host tag(s): [{}]", dcId, podId, clusterId, hostTag);
129+
} else {
130+
logger.debug("Looking for hosts in dc: {} pod: {} cluster: {}", dcId , podId, clusterId);

debian/patches/series

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,8 @@ community-PR10450.patch
2222
# Merged into 4.20.1
2323
# Fixes: PCS-2382
2424
community-PR10613.patch
25+
26+
# https://github.com/apache/cloudstack/pull/10603 -- fix: Fix issue with allocator not considering subsequent clusters
27+
# not merged yet
28+
# Fixes: PCS-2364
29+
community-PR10603.patch

0 commit comments

Comments
 (0)