Skip to content

Commit ba96c8c

Browse files
author
Sateesh Chodapuneedi
committed
CLOUDSTACK-5408 [Automation] Failed to deploy vm in vmware environment with error "due to java.io.IOException: Cannot run program "mount": java.io.IOException: error=12, Cannot allocate memory"
Bump up RAM size of system offering for SSVM to 512MB Signed-off-by: Sateesh Chodapuneedi <sateesh@apache.org>
1 parent ab42946 commit ba96c8c

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

engine/schema/src/com/cloud/upgrade/dao/Upgrade421to430.java

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,49 @@ public File[] getPrepareScripts() {
6363
@Override
6464
public void performDataMigration(Connection conn) {
6565
encryptLdapConfigParams(conn);
66+
upgradeMemoryOfSsvmOffering(conn);
67+
}
68+
69+
private void upgradeMemoryOfSsvmOffering(Connection conn) {
70+
PreparedStatement updatePstmt = null;
71+
PreparedStatement selectPstmt = null;
72+
ResultSet selectResultSet = null;
73+
int newRamSize = 512; //512MB
74+
long serviceOfferingId = 0;
75+
76+
/**
77+
* Pick first row in service_offering table which has system vm type as secondary storage vm. User added offerings would start from 2nd row onwards.
78+
* We should not update/modify any user-defined offering.
79+
*/
80+
81+
try {
82+
selectPstmt = conn.prepareStatement("SELECT id FROM `cloud`.`service_offering` WHERE vm_type='secondarystoragevm'");
83+
updatePstmt = conn.prepareStatement("UPDATE `cloud`.`service_offering` SET ram_size=? WHERE id=?'");
84+
selectResultSet = selectPstmt.executeQuery();
85+
if(selectResultSet.next()) {
86+
serviceOfferingId = selectResultSet.getLong("id");
87+
}
88+
89+
updatePstmt.setInt(1, newRamSize);
90+
updatePstmt.setLong(2, serviceOfferingId);
91+
updatePstmt.executeUpdate();
92+
} catch (SQLException e) {
93+
throw new CloudRuntimeException("Unable to upgrade ram_size of service offering for secondary storage vm. ", e);
94+
} finally {
95+
try {
96+
if (selectPstmt != null) {
97+
selectPstmt.close();
98+
}
99+
if (selectResultSet != null) {
100+
selectResultSet.close();
101+
}
102+
if (updatePstmt != null) {
103+
updatePstmt.close();
104+
}
105+
} catch (SQLException e) {
106+
}
107+
}
108+
s_logger.debug("Done upgrading RAM for service offering of Secondary Storage VM to " + newRamSize);
66109
}
67110

68111
private void encryptLdapConfigParams(Connection conn) {

0 commit comments

Comments
 (0)