Skip to content

Commit 6d31aca

Browse files
committed
CLOUDSTACK-6075: Increase the ram size for router service offering
Increased the ram size of Internal load balancer vm service offering also Backported from fix by Harikrishna Patnala <harikrishna.patnala@citrix.com> https://reviews.apache.org/r/17941/ Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
1 parent 2aa9bb6 commit 6d31aca

4 files changed

Lines changed: 111 additions & 3 deletions

File tree

‎engine/schema/src/com/cloud/upgrade/dao/Upgrade431to432.java‎

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
import java.util.Map;
2929
import java.util.Set;
3030

31+
import com.cloud.utils.exception.CloudRuntimeException;
32+
3133
import org.apache.log4j.Logger;
3234

3335
public class Upgrade431to432 implements DbUpgrade {
@@ -55,6 +57,112 @@ public File[] getPrepareScripts() {
5557

5658
@Override
5759
public void performDataMigration(Connection conn) {
60+
updateMaxRouterSizeConfig(conn);
61+
upgradeMemoryOfVirtualRoutervmOffering(conn);
62+
upgradeMemoryOfInternalLoadBalancervmOffering(conn);
63+
}
64+
65+
private void updateMaxRouterSizeConfig(Connection conn) {
66+
PreparedStatement updatePstmt = null;
67+
try {
68+
updatePstmt = conn.prepareStatement("UPDATE `cloud`.`configuration` SET value='256' WHERE name='router.ram.size'");
69+
updatePstmt.executeUpdate();
70+
} catch (SQLException e) {
71+
throw new CloudRuntimeException("Unable to upgrade max ram size of router in config.", e);
72+
} finally {
73+
try {
74+
if (updatePstmt != null) {
75+
updatePstmt.close();
76+
}
77+
} catch (SQLException e) {
78+
}
79+
}
80+
s_logger.debug("Done updating router.ram.size config to 256");
81+
}
82+
83+
private void upgradeMemoryOfInternalLoadBalancervmOffering(Connection conn) {
84+
PreparedStatement updatePstmt = null;
85+
PreparedStatement selectPstmt = null;
86+
ResultSet selectResultSet = null;
87+
int newRamSize = 256; //256MB
88+
long serviceOfferingId = 0;
89+
90+
/**
91+
* Pick first row in service_offering table which has system vm type as internalloadbalancervm. User added offerings would start from 2nd row onwards.
92+
* We should not update/modify any user-defined offering.
93+
*/
94+
95+
try {
96+
selectPstmt = conn.prepareStatement("SELECT id FROM `cloud`.`service_offering` WHERE vm_type='internalloadbalancervm'");
97+
updatePstmt = conn.prepareStatement("UPDATE `cloud`.`service_offering` SET ram_size=? WHERE id=?");
98+
selectResultSet = selectPstmt.executeQuery();
99+
if(selectResultSet.next()) {
100+
serviceOfferingId = selectResultSet.getLong("id");
101+
}
102+
103+
updatePstmt.setInt(1, newRamSize);
104+
updatePstmt.setLong(2, serviceOfferingId);
105+
updatePstmt.executeUpdate();
106+
} catch (SQLException e) {
107+
throw new CloudRuntimeException("Unable to upgrade ram_size of service offering for internal loadbalancer vm. ", e);
108+
} finally {
109+
try {
110+
if (selectPstmt != null) {
111+
selectPstmt.close();
112+
}
113+
if (selectResultSet != null) {
114+
selectResultSet.close();
115+
}
116+
if (updatePstmt != null) {
117+
updatePstmt.close();
118+
}
119+
} catch (SQLException e) {
120+
}
121+
}
122+
s_logger.debug("Done upgrading RAM for service offering of internal loadbalancer vm to " + newRamSize);
123+
}
124+
125+
126+
private void upgradeMemoryOfVirtualRoutervmOffering(Connection conn) {
127+
PreparedStatement updatePstmt = null;
128+
PreparedStatement selectPstmt = null;
129+
ResultSet selectResultSet = null;
130+
int newRamSize = 256; //256MB
131+
long serviceOfferingId = 0;
132+
133+
/**
134+
* Pick first row in service_offering table which has system vm type as domainrouter. User added offerings would start from 2nd row onwards.
135+
* We should not update/modify any user-defined offering.
136+
*/
137+
138+
try {
139+
selectPstmt = conn.prepareStatement("SELECT id FROM `cloud`.`service_offering` WHERE vm_type='domainrouter'");
140+
updatePstmt = conn.prepareStatement("UPDATE `cloud`.`service_offering` SET ram_size=? WHERE id=?");
141+
selectResultSet = selectPstmt.executeQuery();
142+
if(selectResultSet.next()) {
143+
serviceOfferingId = selectResultSet.getLong("id");
144+
}
145+
146+
updatePstmt.setInt(1, newRamSize);
147+
updatePstmt.setLong(2, serviceOfferingId);
148+
updatePstmt.executeUpdate();
149+
} catch (SQLException e) {
150+
throw new CloudRuntimeException("Unable to upgrade ram_size of service offering for domain router. ", e);
151+
} finally {
152+
try {
153+
if (selectPstmt != null) {
154+
selectPstmt.close();
155+
}
156+
if (selectResultSet != null) {
157+
selectResultSet.close();
158+
}
159+
if (updatePstmt != null) {
160+
updatePstmt.close();
161+
}
162+
} catch (SQLException e) {
163+
}
164+
}
165+
s_logger.debug("Done upgrading RAM for service offering of domain router to " + newRamSize);
58166
}
59167

60168
@Override

‎plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMManager.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
public interface InternalLoadBalancerVMManager {
3434
//RAM/CPU for the system offering used by Internal LB VMs
35-
public static final int DEFAULT_INTERNALLB_VM_RAMSIZE = 128; // 128 MB
35+
public static final int DEFAULT_INTERNALLB_VM_RAMSIZE = 256; // 256 MB
3636
public static final int DEFAULT_INTERNALLB_VM_CPU_MHZ = 256; // 256 MHz
3737

3838
/**

‎server/src/com/cloud/configuration/Config.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ public enum Config {
306306
HashKey("Hidden", ManagementServer.class, String.class, "security.hash.key", null, "for generic key-ed hash", null),
307307
EncryptionKey("Hidden", ManagementServer.class, String.class, "security.encryption.key", null, "base64 encoded key data", null),
308308
EncryptionIV("Hidden", ManagementServer.class, String.class, "security.encryption.iv", null, "base64 encoded IV data", null),
309-
RouterRamSize("Hidden", NetworkOrchestrationService.class, Integer.class, "router.ram.size", "128", "Default RAM for router VM (in MB).", null),
309+
RouterRamSize("Hidden", NetworkOrchestrationService.class, Integer.class, "router.ram.size", "256", "Default RAM for router VM (in MB).", null),
310310

311311
DefaultPageSize("Advanced", ManagementServer.class, Long.class, "default.page.size", "500", "Default page size for API list* commands", null),
312312

‎server/src/com/cloud/network/router/VirtualNetworkApplianceManager.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public interface VirtualNetworkApplianceManager extends Manager, VirtualNetworkA
6262
static final ConfigKey<String> RouterTemplateLxc = new ConfigKey<String>(String.class, RouterTemplateLxcCK, "Advanced", "SystemVM Template (LXC)",
6363
"Name of the default router template on LXC.", true, ConfigKey.Scope.Zone, null);
6464

65-
public static final int DEFAULT_ROUTER_VM_RAMSIZE = 128; // 128M
65+
public static final int DEFAULT_ROUTER_VM_RAMSIZE = 256; // 256M
6666
public static final int DEFAULT_ROUTER_CPU_MHZ = 500; // 500 MHz
6767
public static final boolean USE_POD_VLAN = false;
6868
/**

0 commit comments

Comments
 (0)