Skip to content

Commit 933ee23

Browse files
authored
vr: memory and swap optimizations (#2892)
This tries to provide a threshold based fix for #2873 where swappinness of VR is not used until last resort. By limiting swappiness unless actually needed, the VR system degradation can be avoided for most cases. The other change is around not starting baremetal-vr by default on all VRs, according to the spec https://cwiki.apache.org/confluence/display/CLOUDSTACK/Baremetal+Advanced+Networking+Support only vmware VRs need to run it and that too only as the last step of the setup/completion, so we don't need to run it all the time. Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
1 parent 63f4d85 commit 933ee23

6 files changed

Lines changed: 30 additions & 7 deletions

File tree

plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalKickStartServiceImpl.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,11 +226,16 @@ private boolean preparePxeInAdvancedZone(VirtualMachineProfile profile, NicProfi
226226
throw new CloudRuntimeException(String.format("please specify 'baremetal.internal.storage.server.ip', which is the http server/nfs server storing kickstart files and ISO files, in global setting"));
227227
}
228228

229+
Pair<Boolean, String> ret = SshHelper.sshExecute(mgmtNic.getIPv4Address(), 3922, "root", getSystemVMKeyFile(), null, "systemctl start baremetal-vr");
230+
if (!ret.first()) {
231+
throw new CloudRuntimeException(String.format("failed to start baremetal agent in virtual router[id:%s]", vr.getId()));
232+
}
233+
229234
List<String> tuple = parseKickstartUrl(profile);
230235
String cmd = String.format("/opt/cloud/bin/prepare_pxe.sh %s %s %s %s %s %s", tuple.get(1), tuple.get(2), profile.getTemplate().getUuid(),
231236
String.format("01-%s", nic.getMacAddress().replaceAll(":", "-")).toLowerCase(), tuple.get(0), nic.getMacAddress().toLowerCase());
232237
s_logger.debug(String.format("prepare pxe on virtual router[ip:%s], cmd: %s", mgmtNic.getIPv4Address(), cmd));
233-
Pair<Boolean, String> ret = SshHelper.sshExecute(mgmtNic.getIPv4Address(), 3922, "root", getSystemVMKeyFile(), null, cmd);
238+
ret = SshHelper.sshExecute(mgmtNic.getIPv4Address(), 3922, "root", getSystemVMKeyFile(), null, cmd);
234239
if (!ret.first()) {
235240
throw new CloudRuntimeException(String.format("failed preparing PXE in virtual router[id:%s], because %s", vr.getId(), ret.second()));
236241
}

systemvm/debian/etc/sysctl.conf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,6 @@ net.ipv6.conf.all.forwarding = 0
6060
net.ipv6.conf.all.accept_ra = 0
6161
net.ipv6.conf.all.accept_redirects = 0
6262
net.ipv6.conf.all.autoconf = 0
63+
64+
# Minimum swappiness without disabling it
65+
vm.swappiness=1
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[Journal]
2+
Compress=yes
3+
SystemMaxUse=40M
4+
SystemMaxFileSize=10M
5+
RuntimeMaxUse=20M
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[Unit]
2+
Description=CloudStack Baremetal VR service
3+
After=network.target local-fs.target
4+
5+
[Install]
6+
WantedBy=multi-user.target
7+
8+
[Service]
9+
Type=simple
10+
WorkingDirectory=/opt/cloud/bin
11+
ExecStart=/usr/bin/python /opt/cloud/bin/baremetal-vr.py
12+
Restart=on-failure

systemvm/debian/etc/systemd/system/cloud-postinit.service

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Description=CloudStack post-patching init script
33
After=cloud-early-config.service network.target local-fs.target
44
Before=ssh.service
5-
Requires=network.service
5+
Requires=networking.service
66

77
[Install]
88
WantedBy=multi-user.target

systemvm/debian/opt/cloud/bin/setup/postinit.sh

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
# Eject cdrom if any
2222
eject || true
2323

24+
# Restart journald for setting changes to apply
25+
systemctl restart systemd-journald
26+
2427
TYPE=$(grep -Po 'type=\K[a-zA-Z]*' /var/cache/cloud/cmdline)
2528
if [ "$TYPE" == "router" ] || [ "$TYPE" == "vpcrouter" ] || [ "$TYPE" == "dhcpsrvr" ]
2629
then
@@ -59,8 +62,3 @@ fi
5962
systemctl enable --now --no-block ssh
6063

6164
date > /var/cache/cloud/boot_up_done
62-
63-
if [ "$TYPE" == "router" ]
64-
then
65-
python /opt/cloud/bin/baremetal-vr.py &
66-
fi

0 commit comments

Comments
 (0)