From 87fdb521f0339c7bda7cbad979365988a14e9fd1 Mon Sep 17 00:00:00 2001 From: Remi Bergsma Date: Thu, 20 Aug 2015 22:31:55 +0200 Subject: [PATCH] CLOUDSTACK-8443: don't try to fix co-mounted cgroups This setting works on CentOS 6 / RHEL 6 but does nothing, as "cpu" cgroup is not mounted. On CentOS 7 / RHEL 7 systemd does mount cgroups and "cpu" is co-mounted with "cpuacc". Hence, if we specify "cpu" then this results in an error because it can only use them both, or none. By removing the setting, we rely on the default of qemu, which is: cgroup_controllers = ["cpu", "devices", "memory", "blkio", "cpuacct", "net_cls"] Only if they are really mounted, they will be used. So, this will work on both version 6 and 7. The 'fix script' didn't work well, as after a reboot you'd still have qemu throwing errors. Now we can handle the co-mountedcgroups. --- .../resource/LibvirtComputingResource.java | 23 -------- python/lib/cloud_utils.py | 19 ------- python/lib/cloudutils/serviceConfig.py | 1 - scripts/vm/hypervisor/kvm/setup-cgroups.sh | 52 ------------------- 4 files changed, 95 deletions(-) delete mode 100755 scripts/vm/hypervisor/kvm/setup-cgroups.sh diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java index 6bf5ccd42c3..ee5f2971756 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java @@ -180,7 +180,6 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv private String _ovsPvlanVmPath; private String _routerProxyPath; private String _ovsTunnelPath; - private String _setupCgroupPath; private String _host; private String _dcId; private String _pod; @@ -699,17 +698,6 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv _hypervisorType = HypervisorType.KVM; } - //Verify that cpu,cpuacct cgroups are not co-mounted - if(HypervisorType.LXC.equals(getHypervisorType())){ - _setupCgroupPath = Script.findScript(kvmScriptsDir, "setup-cgroups.sh"); - if (_setupCgroupPath == null) { - throw new ConfigurationException("Unable to find the setup-cgroups.sh"); - } - if(!checkCgroups()){ - throw new ConfigurationException("cpu,cpuacct cgroups are co-mounted"); - } - } - _hypervisorURI = (String)params.get("hypervisor.uri"); if (_hypervisorURI == null) { _hypervisorURI = LibvirtConnection.getHypervisorURI(_hypervisorType.toString()); @@ -3332,17 +3320,6 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv return _hypervisorType; } - private boolean checkCgroups(){ - final Script command = new Script(_setupCgroupPath, 5 * 1000, s_logger); - String result; - result = command.execute(); - if (result != null) { - s_logger.debug("cgroup check failed:" + result); - return false; - } - return true; - } - public String mapRbdDevice(final KVMPhysicalDisk disk){ final KVMStoragePool pool = disk.getPool(); //Check if rbd image is already mapped diff --git a/python/lib/cloud_utils.py b/python/lib/cloud_utils.py index 243bb408d41..a98d1c6d58c 100644 --- a/python/lib/cloud_utils.py +++ b/python/lib/cloud_utils.py @@ -685,24 +685,6 @@ class SetupCgRules(ConfigTask): enable_service("cgred") -class SetupCgroupControllers(ConfigTask): - name = "qemu cgroup controllers setup" - cfgline = "cgroup_controllers = [ \"cpu\" ]" - filename = "/etc/libvirt/qemu.conf" - - def done(self): - try: - return self.cfgline in file(self.filename,"r").read(-1) - except IOError,e: - if e.errno is 2: raise TaskFailed("qemu has not been properly installed on this system") - raise - - def execute(self): - libvirtqemu = file(self.filename,"r").read(-1) - libvirtqemu = libvirtqemu + "\n" + self.cfgline + "\n" - file("/etc/libvirt/qemu.conf","w").write(libvirtqemu) - - class SetupSecurityDriver(ConfigTask): name = "security driver setup" cfgline = "security_driver = \"none\"" @@ -887,7 +869,6 @@ def config_tasks(brname, pubNic, prvNic): SetupNetworking(brname, pubNic, prvNic), SetupCgConfig(), SetupCgRules(), - SetupCgroupControllers(), SetupSecurityDriver(), SetupLibvirt(), SetupLiveMigration(), diff --git a/python/lib/cloudutils/serviceConfig.py b/python/lib/cloudutils/serviceConfig.py index b2adc315ad4..54bfe2624c9 100755 --- a/python/lib/cloudutils/serviceConfig.py +++ b/python/lib/cloudutils/serviceConfig.py @@ -493,7 +493,6 @@ class libvirtConfigRedhat(serviceCfgBase): filename = "/etc/libvirt/qemu.conf" cfo = configFileOps(filename, self) - cfo.addEntry("cgroup_controllers", "[\"cpu\"]") cfo.addEntry("security_driver", "\"none\"") cfo.addEntry("user", "\"root\"") cfo.addEntry("group", "\"root\"") diff --git a/scripts/vm/hypervisor/kvm/setup-cgroups.sh b/scripts/vm/hypervisor/kvm/setup-cgroups.sh deleted file mode 100755 index 6b00b028311..00000000000 --- a/scripts/vm/hypervisor/kvm/setup-cgroups.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/bash -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - - - -# Script to fix cgroups co-mounted issue -# Applies to RHEL 7 versions (and family member CentOS 7) only -# Detect if cpu,cpuacct cgroups are co-mounted -# If co-mounted, unmount and mount them seperately - -#set -x - -# Check distribution version for RHEL -if [ -f '/etc/redhat-release' ]; then - # Check RHEL version for 7 - if grep -E 'Red Hat Enterprise Linux Server release 7|CentOS Linux release 7' /etc/redhat-release > /dev/null; then - # Check if cgroups if co-mounted - if [ -d '/sys/fs/cgroup/cpu,cpuacct' ]; then - # cgroups co-mounted. Requires remount - umount /sys/fs/cgroup/cpu,cpuacct - rm /sys/fs/cgroup/cpu - rm /sys/fs/cgroup/cpuacct - rm -rf /sys/fs/cgroup/cpu,cpuacct - mkdir -p /sys/fs/cgroup/cpu - mkdir -p /sys/fs/cgroup/cpuacct - mount -t cgroup -o cpu cpu "/sys/fs/cgroup/cpu" - mount -t cgroup -o cpuacct cpuacct "/sys/fs/cgroup/cpuacct" - # Verify that cgroups are not co-mounted - if [ -d '/sys/fs/cgroup/cpu,cpuacct' ]; then - echo "cgroups still co-mounted" - exit 1; - fi - fi - fi -fi - -exit 0