mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Cloudstack-5077: reserve cpu and memory only when vmware.reserve.cpu/mem are set to true. Insted of setting the ovecommit values to one on upgrade, we popultate them from the global values.
Conflicts: engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java engine/schema/src/com/cloud/upgrade/dao/Upgrade420to421.java plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
This commit is contained in:
parent
8f1498dc8c
commit
99b4cf788e
@ -739,7 +739,7 @@ public class Upgrade410to420 implements DbUpgrade {
|
|||||||
} else {
|
} else {
|
||||||
//update cluster_details table with the default overcommit ratios.
|
//update cluster_details table with the default overcommit ratios.
|
||||||
pstmt1.setLong(1,id);
|
pstmt1.setLong(1,id);
|
||||||
pstmt1.setString(2, "1");
|
pstmt1.setString(2,global_cpu_overprovisioning_factor);
|
||||||
pstmt1.execute();
|
pstmt1.execute();
|
||||||
pstmt2.setLong(1, id);
|
pstmt2.setLong(1, id);
|
||||||
pstmt2.setString(2, "1");
|
pstmt2.setString(2, "1");
|
||||||
|
|||||||
@ -23,6 +23,7 @@ import java.sql.PreparedStatement;
|
|||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
import com.cloud.hypervisor.Hypervisor;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.cloud.utils.exception.CloudRuntimeException;
|
import com.cloud.utils.exception.CloudRuntimeException;
|
||||||
@ -64,10 +65,12 @@ public class Upgrade420to421 implements DbUpgrade {
|
|||||||
@Override
|
@Override
|
||||||
public void performDataMigration(Connection conn) {
|
public void performDataMigration(Connection conn) {
|
||||||
upgradeResourceCount(conn);
|
upgradeResourceCount(conn);
|
||||||
updateCpuOverprovisioning(conn);
|
updateOverprovisioningPerVm(conn);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateCpuOverprovisioning(Connection conn) {
|
|
||||||
|
|
||||||
|
private void updateOverprovisioningPerVm(Connection conn) {
|
||||||
PreparedStatement pstmt1 = null;
|
PreparedStatement pstmt1 = null;
|
||||||
PreparedStatement pstmt2 = null;
|
PreparedStatement pstmt2 = null;
|
||||||
PreparedStatement pstmt3 = null;
|
PreparedStatement pstmt3 = null;
|
||||||
@ -79,21 +82,41 @@ public class Upgrade420to421 implements DbUpgrade {
|
|||||||
try {
|
try {
|
||||||
pstmt1 = conn.prepareStatement("select value from `cloud`.`configuration` where name='cpu.overprovisioning.factor'");
|
pstmt1 = conn.prepareStatement("select value from `cloud`.`configuration` where name='cpu.overprovisioning.factor'");
|
||||||
result1 = pstmt1.executeQuery();
|
result1 = pstmt1.executeQuery();
|
||||||
String overprov = "1";
|
String cpuoverprov = "1";
|
||||||
if(result1.next()){
|
if(result1.next()){
|
||||||
overprov = result1.getString(1);
|
cpuoverprov = result1.getString(1);
|
||||||
}
|
}
|
||||||
|
pstmt1 = conn.prepareStatement("select value from `cloud`.`configuration` where name='mem.overprovisioning.factor'");
|
||||||
|
result1 = pstmt1.executeQuery();
|
||||||
|
String memoverprov = "1";
|
||||||
|
if(result1.next()){
|
||||||
|
memoverprov = result1.getString(1);
|
||||||
|
}
|
||||||
|
|
||||||
// Need to populate only when overprovisioning factor doesn't pre exist.
|
// Need to populate only when overprovisioning factor doesn't pre exist.
|
||||||
s_logger.debug("Starting updating user_vm_details with cpu/memory overprovisioning factors");
|
s_logger.debug("Starting updating user_vm_details with cpu/memory overprovisioning factors");
|
||||||
pstmt2 =
|
pstmt2 = conn.prepareStatement("select id, hypervisor_type from `cloud`.`vm_instance` where removed is null and id not in (select vm_id from `cloud`.`user_vm_details` where name='cpuOvercommitRatio')");
|
||||||
conn.prepareStatement("select id from `cloud`.`vm_instance` where removed is null and id not in (select vm_id from `cloud`.`user_vm_details` where name='cpuOvercommitRatio')");
|
|
||||||
pstmt3 = conn.prepareStatement("INSERT IGNORE INTO cloud.user_vm_details (vm_id, name, value) VALUES (?, ?, ?)");
|
pstmt3 = conn.prepareStatement("INSERT IGNORE INTO cloud.user_vm_details (vm_id, name, value) VALUES (?, ?, ?)");
|
||||||
result2 = pstmt2.executeQuery();
|
result2 = pstmt2.executeQuery();
|
||||||
while (result2.next()) {
|
while (result2.next()) {
|
||||||
|
String hypervisor_type = result2.getString(2);
|
||||||
|
if (hypervisor_type.equalsIgnoreCase(Hypervisor.HypervisorType.VMware.name())) {
|
||||||
//For cpu
|
//For cpu
|
||||||
pstmt3.setLong(1, result2.getLong(1));
|
pstmt3.setLong(1, result2.getLong(1));
|
||||||
pstmt3.setString(2, "cpuOvercommitRatio");
|
pstmt3.setString(2, "cpuOvercommitRatio");
|
||||||
pstmt3.setString(3, overprov);
|
pstmt3.setString(3, cpuoverprov);
|
||||||
|
pstmt3.executeUpdate();
|
||||||
|
|
||||||
|
// For memory
|
||||||
|
pstmt3.setLong(1, result2.getLong(1));
|
||||||
|
pstmt3.setString(2, "memoryOvercommitRatio");
|
||||||
|
pstmt3.setString(3, memoverprov); // memory overprovisioning was used to reserve memory in case of VMware.
|
||||||
|
pstmt3.executeUpdate();
|
||||||
|
} else {
|
||||||
|
//For cpu
|
||||||
|
pstmt3.setLong(1, result2.getLong(1));
|
||||||
|
pstmt3.setString(2, "cpuOvercommitRatio");
|
||||||
|
pstmt3.setString(3, cpuoverprov);
|
||||||
pstmt3.executeUpdate();
|
pstmt3.executeUpdate();
|
||||||
|
|
||||||
// For memory
|
// For memory
|
||||||
@ -102,19 +125,30 @@ public class Upgrade420to421 implements DbUpgrade {
|
|||||||
pstmt3.setString(3, "1"); // memory overprovisioning didn't exist earlier.
|
pstmt3.setString(3, "1"); // memory overprovisioning didn't exist earlier.
|
||||||
pstmt3.executeUpdate();
|
pstmt3.executeUpdate();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
s_logger.debug("Done updating user_vm_details with cpu/memory overprovisioning factors");
|
s_logger.debug("Done updating user_vm_details with cpu/memory overprovisioning factors");
|
||||||
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw new CloudRuntimeException("Unable to update cpu/memory overprovisioning factors", e);
|
throw new CloudRuntimeException("Unable to update cpu/memory overprovisioning factors", e);
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
if (pstmt1 != null)
|
if (pstmt1 != null && !pstmt1.isClosed()) {
|
||||||
pstmt1.close();
|
pstmt1.close();
|
||||||
if (pstmt2 != null)
|
}
|
||||||
|
if (pstmt2 != null && !pstmt2.isClosed()) {
|
||||||
pstmt2.close();
|
pstmt2.close();
|
||||||
if (pstmt3 != null)
|
}
|
||||||
|
if (pstmt3 != null && !pstmt3.isClosed()) {
|
||||||
pstmt3.close();
|
pstmt3.close();
|
||||||
|
}
|
||||||
|
if (result1 != null) {
|
||||||
|
result1.close();
|
||||||
|
}
|
||||||
|
if (result2 != null) {
|
||||||
|
result2.close();
|
||||||
|
}
|
||||||
}catch (SQLException e){
|
}catch (SQLException e){
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1723,9 +1723,6 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||||||
int getReservedMemoryMb(VirtualMachineTO vmSpec) {
|
int getReservedMemoryMb(VirtualMachineTO vmSpec) {
|
||||||
if (vmSpec.getDetails().get(Config.VmwareReserveMem.key()).equalsIgnoreCase("true")) {
|
if (vmSpec.getDetails().get(Config.VmwareReserveMem.key()).equalsIgnoreCase("true")) {
|
||||||
return (int) (vmSpec.getMinRam() / (1024 * 1024));
|
return (int) (vmSpec.getMinRam() / (1024 * 1024));
|
||||||
} else if (vmSpec.getMinRam() != vmSpec.getMaxRam()) {
|
|
||||||
s_logger.warn("memory overprovisioning factor is set to " + (vmSpec.getMaxRam() / vmSpec.getMinRam()) + " ignoring the flag vmware.reserve.mem");
|
|
||||||
return (int)(vmSpec.getMinRam() / (1024 * 1024));
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -1733,10 +1730,6 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||||||
int getReservedCpuMHZ(VirtualMachineTO vmSpec) {
|
int getReservedCpuMHZ(VirtualMachineTO vmSpec) {
|
||||||
if (vmSpec.getDetails().get(Config.VmwareReserveCpu.key()).equalsIgnoreCase("true")) {
|
if (vmSpec.getDetails().get(Config.VmwareReserveCpu.key()).equalsIgnoreCase("true")) {
|
||||||
return vmSpec.getMinSpeed();
|
return vmSpec.getMinSpeed();
|
||||||
} else if (vmSpec.getMinSpeed().intValue() != vmSpec.getMaxSpeed().intValue()) {
|
|
||||||
s_logger.warn("cpu overprovisioning factor is set to " + (vmSpec.getMaxSpeed().intValue() / vmSpec.getMinSpeed().intValue()) +
|
|
||||||
" ignoring the flag vmware.reserve.cpu");
|
|
||||||
return vmSpec.getMinSpeed();
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,7 +24,8 @@ INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'manag
|
|||||||
'The maximum size limit for S3 single part upload API(in GB). If it is set to 0, then it means always use multi-part upload to upload object to S3. If it is set to -1, then it means always use single-part upload to upload object to S3.');
|
'The maximum size limit for S3 single part upload API(in GB). If it is set to 0, then it means always use multi-part upload to upload object to S3. If it is set to -1, then it means always use single-part upload to upload object to S3.');
|
||||||
|
|
||||||
INSERT IGNORE INTO `cloud`.`configuration` VALUES ("Storage", 'DEFAULT', 'management-server', "enable.ha.storage.migration", "true", "Enable/disable storage migration across primary storage during HA");
|
INSERT IGNORE INTO `cloud`.`configuration` VALUES ("Storage", 'DEFAULT', 'management-server', "enable.ha.storage.migration", "true", "Enable/disable storage migration across primary storage during HA");
|
||||||
|
UPDATE `cloud`.`configuration` SET description="Specify whether or not to reserve CPU based on CPU overprovisioning factor" where name="vmware.reserve.cpu";
|
||||||
|
UPDATE `cloud`.`configuration` SET description="Specify whether or not to reserve memory based on memory overprovisioning factor" where name="vmware.reserve.mem";
|
||||||
-- Remove Windows Server 8 from guest_os_type dropdown to use Windows Server 2012
|
-- Remove Windows Server 8 from guest_os_type dropdown to use Windows Server 2012
|
||||||
DELETE FROM `cloud`.`guest_os_hypervisor` where guest_os_id=168;
|
DELETE FROM `cloud`.`guest_os_hypervisor` where guest_os_id=168;
|
||||||
DELETE FROM `cloud`.`guest_os` where id=168;
|
DELETE FROM `cloud`.`guest_os` where id=168;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user