Skip to content

Commit 488c178

Browse files
Harikrishna Patnalayadvr
authored andcommitted
CLOUDSTACK-6075: Increase the ram size for router service offering
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
1 parent 612b4ae commit 488c178

5 files changed

Lines changed: 90 additions & 3 deletions

File tree

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

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,93 @@ public void performDataMigration(Connection conn) {
6868
updateSystemVmTemplates(conn);
6969
dropInvalidKeyFromStoragePoolTable(conn);
7070
dropDuplicatedForeignKeyFromAsyncJobTable(conn);
71+
upgradeMemoryOfVirtualRoutervmOffering(conn);
72+
upgradeMemoryOfInternalLoadBalancervmOffering(conn);
7173
}
7274

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

74159
@Override
75160
public File[] getCleanupScripts() {

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
@@ -1452,7 +1452,7 @@ public enum Config {
14521452
"SAML2 IDP Metadata Downloading and parsing etc. activity timeout in milliseconds",
14531453
null),
14541454
//NetworkType("Hidden", ManagementServer.class, String.class, "network.type", "vlan", "The type of network that this deployment will use.", "vlan,direct"),
1455-
RouterRamSize("Hidden", NetworkOrchestrationService.class, Integer.class, "router.ram.size", "128", "Default RAM for router VM (in MB).", null),
1455+
RouterRamSize("Hidden", NetworkOrchestrationService.class, Integer.class, "router.ram.size", "256", "Default RAM for router VM (in MB).", null),
14561456

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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public interface VirtualNetworkApplianceManager extends Manager, VirtualNetworkA
6161
static final ConfigKey<Integer> RouterAlertsCheckInterval = new ConfigKey<Integer>(Integer.class, RouterAlertsCheckIntervalCK, "Advanced", "1800",
6262
"Interval (in seconds) to check for alerts in Virtual Router.", false, ConfigKey.Scope.Global, null);
6363

64-
public static final int DEFAULT_ROUTER_VM_RAMSIZE = 128; // 128M
64+
public static final int DEFAULT_ROUTER_VM_RAMSIZE = 256; // 256M
6565
public static final int DEFAULT_ROUTER_CPU_MHZ = 500; // 500 MHz
6666
public static final boolean USE_POD_VLAN = false;
6767
public static final int DEFAULT_PRIORITY = 100;

setup/db/db/schema-442to450.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,8 @@ UPDATE configuration SET value='KVM,XenServer,VMware,BareMetal,Ovm,LXC,Hyperv' W
439439
UPDATE `cloud`.`configuration` SET description="If set to true, will set guest VM's name as it appears on the hypervisor, to its hostname. The flag is supported for VMware hypervisor only" WHERE name='vm.instancename.flag';
440440
INSERT IGNORE INTO `cloud`.`configuration`(category, instance, component, name, value, description, default_value) VALUES ('Advanced', 'DEFAULT', 'management-server', 'implicit.host.tags', 'GPU', 'Tag hosts at the time of host disovery based on the host properties/capabilities ', 'GPU');
441441

442+
UPDATE `cloud`.`configuration` SET value='256' WHERE name='router.ram.size';
443+
442444
DROP VIEW IF EXISTS `cloud`.`domain_router_view`;
443445
CREATE VIEW `cloud`.`domain_router_view` AS
444446
select

0 commit comments

Comments
 (0)