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.
This commit is contained in:
Remi Bergsma 2015-08-20 22:31:55 +02:00
parent 6d57a86cb9
commit 87fdb521f0
4 changed files with 0 additions and 95 deletions

View File

@ -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

View File

@ -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(),

View File

@ -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\"")

View File

@ -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