From 933ee23104a6e5e080c780874629ec84a6a5e72d Mon Sep 17 00:00:00 2001 From: Rohit Yadav Date: Tue, 16 Oct 2018 10:29:48 +0530 Subject: [PATCH 1/2] 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 --- .../BaremetalKickStartServiceImpl.java | 7 ++++++- systemvm/debian/etc/sysctl.conf | 3 +++ systemvm/debian/etc/systemd/journald.conf | 5 +++++ .../debian/etc/systemd/system/baremetal-vr.service | 12 ++++++++++++ .../debian/etc/systemd/system/cloud-postinit.service | 2 +- systemvm/debian/opt/cloud/bin/setup/postinit.sh | 8 +++----- 6 files changed, 30 insertions(+), 7 deletions(-) create mode 100644 systemvm/debian/etc/systemd/journald.conf create mode 100644 systemvm/debian/etc/systemd/system/baremetal-vr.service diff --git a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalKickStartServiceImpl.java b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalKickStartServiceImpl.java index 1bbf1322b1c..8fe3d827ed4 100644 --- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalKickStartServiceImpl.java +++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalKickStartServiceImpl.java @@ -226,11 +226,16 @@ public class BaremetalKickStartServiceImpl extends BareMetalPxeServiceBase imple 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")); } + Pair ret = SshHelper.sshExecute(mgmtNic.getIPv4Address(), 3922, "root", getSystemVMKeyFile(), null, "systemctl start baremetal-vr"); + if (!ret.first()) { + throw new CloudRuntimeException(String.format("failed to start baremetal agent in virtual router[id:%s]", vr.getId())); + } + List tuple = parseKickstartUrl(profile); 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(), String.format("01-%s", nic.getMacAddress().replaceAll(":", "-")).toLowerCase(), tuple.get(0), nic.getMacAddress().toLowerCase()); s_logger.debug(String.format("prepare pxe on virtual router[ip:%s], cmd: %s", mgmtNic.getIPv4Address(), cmd)); - Pair ret = SshHelper.sshExecute(mgmtNic.getIPv4Address(), 3922, "root", getSystemVMKeyFile(), null, cmd); + ret = SshHelper.sshExecute(mgmtNic.getIPv4Address(), 3922, "root", getSystemVMKeyFile(), null, cmd); if (!ret.first()) { throw new CloudRuntimeException(String.format("failed preparing PXE in virtual router[id:%s], because %s", vr.getId(), ret.second())); } diff --git a/systemvm/debian/etc/sysctl.conf b/systemvm/debian/etc/sysctl.conf index 8e6d7520006..5b5f818e76d 100644 --- a/systemvm/debian/etc/sysctl.conf +++ b/systemvm/debian/etc/sysctl.conf @@ -60,3 +60,6 @@ net.ipv6.conf.all.forwarding = 0 net.ipv6.conf.all.accept_ra = 0 net.ipv6.conf.all.accept_redirects = 0 net.ipv6.conf.all.autoconf = 0 + +# Minimum swappiness without disabling it +vm.swappiness=1 diff --git a/systemvm/debian/etc/systemd/journald.conf b/systemvm/debian/etc/systemd/journald.conf new file mode 100644 index 00000000000..224f375d6b6 --- /dev/null +++ b/systemvm/debian/etc/systemd/journald.conf @@ -0,0 +1,5 @@ +[Journal] +Compress=yes +SystemMaxUse=40M +SystemMaxFileSize=10M +RuntimeMaxUse=20M diff --git a/systemvm/debian/etc/systemd/system/baremetal-vr.service b/systemvm/debian/etc/systemd/system/baremetal-vr.service new file mode 100644 index 00000000000..f880f0ca18a --- /dev/null +++ b/systemvm/debian/etc/systemd/system/baremetal-vr.service @@ -0,0 +1,12 @@ +[Unit] +Description=CloudStack Baremetal VR service +After=network.target local-fs.target + +[Install] +WantedBy=multi-user.target + +[Service] +Type=simple +WorkingDirectory=/opt/cloud/bin +ExecStart=/usr/bin/python /opt/cloud/bin/baremetal-vr.py +Restart=on-failure diff --git a/systemvm/debian/etc/systemd/system/cloud-postinit.service b/systemvm/debian/etc/systemd/system/cloud-postinit.service index c23516e67ff..a9abff443fa 100644 --- a/systemvm/debian/etc/systemd/system/cloud-postinit.service +++ b/systemvm/debian/etc/systemd/system/cloud-postinit.service @@ -2,7 +2,7 @@ Description=CloudStack post-patching init script After=cloud-early-config.service network.target local-fs.target Before=ssh.service -Requires=network.service +Requires=networking.service [Install] WantedBy=multi-user.target diff --git a/systemvm/debian/opt/cloud/bin/setup/postinit.sh b/systemvm/debian/opt/cloud/bin/setup/postinit.sh index f0ae5e89f0c..fc92b7e97cd 100755 --- a/systemvm/debian/opt/cloud/bin/setup/postinit.sh +++ b/systemvm/debian/opt/cloud/bin/setup/postinit.sh @@ -21,6 +21,9 @@ # Eject cdrom if any eject || true +# Restart journald for setting changes to apply +systemctl restart systemd-journald + TYPE=$(grep -Po 'type=\K[a-zA-Z]*' /var/cache/cloud/cmdline) if [ "$TYPE" == "router" ] || [ "$TYPE" == "vpcrouter" ] || [ "$TYPE" == "dhcpsrvr" ] then @@ -59,8 +62,3 @@ fi systemctl enable --now --no-block ssh date > /var/cache/cloud/boot_up_done - -if [ "$TYPE" == "router" ] -then - python /opt/cloud/bin/baremetal-vr.py & -fi From 11d83fab43bbb6322eee5eb9dc132649ab02b68b Mon Sep 17 00:00:00 2001 From: Nicolas Vazquez Date: Tue, 16 Oct 2018 02:02:03 -0300 Subject: [PATCH 2/2] agent: set log level to INFO as default for http wire (#2903) Avoid logging bytes on direct download on KVM. --- agent/conf/log4j-cloud.xml.in | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/agent/conf/log4j-cloud.xml.in b/agent/conf/log4j-cloud.xml.in index 6bc80f08473..9ed43e083e0 100644 --- a/agent/conf/log4j-cloud.xml.in +++ b/agent/conf/log4j-cloud.xml.in @@ -90,6 +90,10 @@ under the License. + + + +