Skip to content

Commit 78186c3

Browse files
Prachi Damlechipchilders
authored andcommitted
CLOUDSTACK-2568: ACS41 regression in storage subsystem (seen with local storage and 2 or more hosts)
Patch for 4.1, changes: - In VolumeReservationVO, the getter method of a column had a typo, causing us to create a wrong searchbuilder. It was searching over the 'id' column instead of 'vm_reservation_id' causing - This bug was causing the vm deployment to choose a wrong pool during deployment since the search was choosing incorrectly - This bug in the GenericSearchBuilder is also fixed - if the getter method does not use the standard 'get' or 'is' prefix, one should annotate that method using @column(name = "<column_name>") and indicate which column this method refers to. This will cause the GenericSearchBuilder to identify the field correctly. - Also, let planner search for pools instead of selecting the one reserved - because there is no way currently to pass multiple pool information to the planner and this may cause issues when a VM has multiple disks. Signed-off-by: Chip Childers <chip.childers@gmail.com>
1 parent c342fa6 commit 78186c3

5 files changed

Lines changed: 23 additions & 36 deletions

File tree

‎engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/VMEntityManagerImpl.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ public void deployVirtualMachine(String reservationId, String caller, Map<Virtua
207207
}
208208

209209
DataCenterDeployment plan = new DataCenterDeployment(vm.getDataCenterId(), vmReservation.getPodId(), vmReservation.getClusterId(),
210-
vmReservation.getHostId(), poolId , null);
210+
vmReservation.getHostId(), null , null);
211211

212212
VMInstanceVO vmDeployed = _itMgr.start(vm, params, _userDao.findById(new Long(caller)), _accountDao.findById(vm.getAccountId()), plan);
213213

‎engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/VolumeReservationVO.java‎

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,14 @@
1616
// under the License.
1717
package org.apache.cloudstack.engine.cloud.entity.api.db;
1818

19-
import java.util.Date;
20-
import java.util.Map;
21-
2219
import javax.persistence.Column;
2320
import javax.persistence.Entity;
2421
import javax.persistence.GeneratedValue;
2522
import javax.persistence.GenerationType;
2623
import javax.persistence.Id;
2724
import javax.persistence.Table;
28-
import javax.persistence.Transient;
29-
30-
import org.apache.cloudstack.api.Identity;
3125
import org.apache.cloudstack.api.InternalIdentity;
3226

33-
import com.cloud.utils.db.GenericDao;
34-
3527
@Entity
3628
@Table(name = "volume_reservation")
3729
public class VolumeReservationVO implements InternalIdentity{
@@ -42,36 +34,32 @@ public class VolumeReservationVO implements InternalIdentity{
4234
private long id;
4335

4436
@Column(name = "vm_reservation_id")
45-
private Long vmReservationId;
46-
37+
private long vmReservationId;
38+
4739
@Column(name = "vm_id")
4840
private long vmId;
49-
41+
5042
@Column(name="volume_id")
5143
private long volumeId;
5244

5345
@Column(name="pool_id")
5446
private long poolId;
55-
56-
// VolumeId -> poolId
57-
@Transient
58-
Map<String, String> volumeReservationMap;
59-
47+
6048
/**
6149
* There should never be a public constructor for this class. Since it's
6250
* only here to define the table for the DAO class.
6351
*/
6452
protected VolumeReservationVO() {
6553
}
6654

67-
public VolumeReservationVO(long vmId, long volumeId, long poolId, Long vmReservationId) {
55+
public VolumeReservationVO(long vmId, long volumeId, long poolId, long vmReservationId) {
6856
this.vmId = vmId;
6957
this.volumeId = volumeId;
7058
this.poolId = poolId;
7159
this.vmReservationId = vmReservationId;
7260
}
73-
74-
61+
62+
7563
public long getId() {
7664
return id;
7765
}
@@ -80,10 +68,10 @@ public long getVmId() {
8068
return vmId;
8169
}
8270

83-
public Long geVmReservationId() {
71+
public long getVmReservationId() {
8472
return vmReservationId;
8573
}
86-
74+
8775
public long getVolumeId() {
8876
return volumeId;
8977
}
@@ -92,9 +80,4 @@ public Long getPoolId() {
9280
return poolId;
9381
}
9482

95-
96-
public Map<String,String> getVolumeReservation(){
97-
return volumeReservationMap;
98-
}
99-
10083
}

‎engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/dao/VolumeReservationDaoImpl.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public void init() {
4949
VmIdSearch.done();
5050

5151
VmReservationIdSearch = createSearchBuilder();
52-
VmReservationIdSearch.and("vmReservationId", VmReservationIdSearch.entity().geVmReservationId(), SearchCriteria.Op.EQ);
52+
VmReservationIdSearch.and("vmReservationId", VmReservationIdSearch.entity().getVmReservationId(), SearchCriteria.Op.EQ);
5353
VmReservationIdSearch.done();
5454
}
5555

‎server/src/com/cloud/deploy/FirstFitPlanner.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ public DeployDestination plan(VirtualMachineProfile<? extends VirtualMachine> vm
157157
if(plan.getHostId() != null && haVmTag == null){
158158
Long hostIdSpecified = plan.getHostId();
159159
if (s_logger.isDebugEnabled()){
160-
s_logger.debug("DeploymentPlan has host_id specified, making no checks on this host, looks like admin test: "+hostIdSpecified);
160+
s_logger.debug("DeploymentPlan has host_id specified, choosing this host and making no checks on this host: "+hostIdSpecified);
161161
}
162162
HostVO host = _hostDao.findById(hostIdSpecified);
163163
if (s_logger.isDebugEnabled()) {

‎utils/src/com/cloud/utils/db/GenericSearchBuilder.java‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import java.util.List;
2424
import java.util.Map;
2525

26+
import javax.persistence.Column;
2627
import javax.persistence.Transient;
2728

2829
import net.sf.cglib.proxy.Factory;
@@ -163,13 +164,16 @@ public Object intercept(Object object, Method method, Object[] args, MethodProxy
163164
set(fieldName);
164165
return null;
165166
} else {
166-
name = name.toLowerCase();
167-
for (String fieldName : _attrs.keySet()) {
168-
if (name.endsWith(fieldName.toLowerCase())) {
169-
set(fieldName);
170-
return null;
171-
}
172-
}
167+
Column ann = method.getAnnotation(Column.class);
168+
if (ann != null) {
169+
String colName = ann.name();
170+
for (Map.Entry<String, Attribute> attr : _attrs.entrySet()) {
171+
if (colName.equals(attr.getValue().columnName)) {
172+
set(attr.getKey());
173+
return null;
174+
}
175+
}
176+
}
173177
assert false : "Perhaps you need to make the method start with get or is?";
174178
}
175179
}

0 commit comments

Comments
 (0)