cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kis...@apache.org
Subject git commit: updated refs/heads/master to 4f3de02
Date Thu, 11 Sep 2014 09:10:14 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/master f3b5a6ebc -> 4f3de024d


Add script to ensure cgroups are not co-mounted in rhel7/lxc. If required, script will unmount
co-mounted cgroups and remount them seperately


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/4f3de024
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/4f3de024
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/4f3de024

Branch: refs/heads/master
Commit: 4f3de024dea973e912f1f28595126db58f39309e
Parents: f3b5a6e
Author: Kishan Kavala <kishan@apache.org>
Authored: Thu Sep 11 14:34:04 2014 +0530
Committer: Kishan Kavala <kishan@apache.org>
Committed: Thu Sep 11 14:34:40 2014 +0530

----------------------------------------------------------------------
 .../kvm/resource/LibvirtComputingResource.java  | 23 ++++++++
 scripts/vm/hypervisor/kvm/setup-cgroups.sh      | 56 ++++++++++++++++++++
 2 files changed, 79 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4f3de024/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
----------------------------------------------------------------------
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 b6c1364..d608707 100755
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
@@ -309,6 +309,7 @@ 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;
@@ -706,6 +707,17 @@ 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());
@@ -5218,4 +5230,15 @@ 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;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4f3de024/scripts/vm/hypervisor/kvm/setup-cgroups.sh
----------------------------------------------------------------------
diff --git a/scripts/vm/hypervisor/kvm/setup-cgroups.sh b/scripts/vm/hypervisor/kvm/setup-cgroups.sh
new file mode 100755
index 0000000..4d6e755
--- /dev/null
+++ b/scripts/vm/hypervisor/kvm/setup-cgroups.sh
@@ -0,0 +1,56 @@
+#!/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 RHEL7 versions 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 'Red Hat Enterprise Linux Server 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


Mime
View raw message