You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ni...@apache.org on 2013/11/06 01:36:01 UTC
git commit: updated refs/heads/master to 7a042e2
Updated Branches:
refs/heads/master 2613c0a82 -> 7a042e233
CLOUDSTACK-5038:
used cpu is getting bumped up when the over provisioning factor > 1. This was because we didnt record the overprovisioning factors of the vms which got deployed pre 4.2
Upgrade path will fix that by populating the cpu/mem overprovisioning factors for each of the vms in user_vm_details table using the global overprovisioning factor.
Reviewed by : bharat kumar <bh...@citrix.com>
Signed off by : nitin mehta<ni...@citrix.com>
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/7a042e23
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/7a042e23
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/7a042e23
Branch: refs/heads/master
Commit: 7a042e2330bff528208a5c9aed462180bc520028
Parents: 2613c0a
Author: Nitin Mehta <ni...@citrix.com>
Authored: Tue Nov 5 16:35:07 2013 -0800
Committer: Nitin Mehta <ni...@citrix.com>
Committed: Tue Nov 5 16:35:52 2013 -0800
----------------------------------------------------------------------
.../com/cloud/upgrade/dao/Upgrade420to421.java | 46 ++++++++++++++++++++
1 file changed, 46 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7a042e23/engine/schema/src/com/cloud/upgrade/dao/Upgrade420to421.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/upgrade/dao/Upgrade420to421.java b/engine/schema/src/com/cloud/upgrade/dao/Upgrade420to421.java
index 27704e8..d37c0a1 100644
--- a/engine/schema/src/com/cloud/upgrade/dao/Upgrade420to421.java
+++ b/engine/schema/src/com/cloud/upgrade/dao/Upgrade420to421.java
@@ -65,6 +65,52 @@ public class Upgrade420to421 implements DbUpgrade {
@Override
public void performDataMigration(Connection conn) {
upgradeResourceCount(conn);
+ updateCpuOverprovisioning(conn);
+ }
+
+ private void updateCpuOverprovisioning(Connection conn) {
+ PreparedStatement pstmt1 = null;
+ PreparedStatement pstmt2 = null;
+ PreparedStatement pstmt3 = null;
+ ResultSet result1 = null;
+ ResultSet result2 = null;
+
+ // Get cpu overprovisioning factor from global setting and update user vm details table for all the vms if factor > 1
+
+ try {
+ pstmt1 = conn.prepareStatement("select value from `cloud`.`configuration` where name='cpu.overprovisioning.factor'");
+ result1 = pstmt1.executeQuery();
+ String overprov = "1";
+ if(result1.next()){
+ overprov = result1.getString(1);
+ }
+ // Need to populate only when overprovisioning factor doesn't pre exist.
+ s_logger.debug("Starting updating user_vm_details with cpu/memory overprovisioning factors");
+ pstmt2 = 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 (?, ?, ?)");
+ result2 = pstmt2.executeQuery();
+ while (result2.next()) {
+ //For cpu
+ pstmt3.setLong(1, result2.getLong(1));
+ pstmt3.setString(2, "cpuOvercommitRatio");
+ pstmt3.setString(3, overprov);
+ pstmt3.executeUpdate();
+
+ // For memory
+ pstmt3.setLong(1, result2.getLong(1));
+ pstmt3.setString(2, "memoryOvercommitRatio");
+ pstmt3.setString(3, "1"); // memory overprovisioning didn't exist earlier.
+ pstmt3.executeUpdate();
+ }
+ s_logger.debug("Done updating user_vm_details with cpu/memory overprovisioning factors");
+
+
+ } catch (SQLException e) {
+ throw new CloudRuntimeException("Unable to update cpu/memory overprovisioning factors", e);
+ } finally {
+
+ }
+
}
private void upgradeResourceCount(Connection conn) {