// checks if the required cgroups subsystems are mounted. // As of now, only 'cpu' and 'memory' are required. // cpu quota is a soft requirement. func validateSystemRequirements(mountUtil mount.Interface) (features, error) { const ( cgroupMountType = "cgroup" localErr = "system validation failed" ) var ( cpuMountPoint string f features ) mountPoints, err := mountUtil.List() if err != nil { return f, fmt.Errorf("%s - %v", localErr, err) } expectedCgroups := sets.NewString("cpu", "cpuacct", "cpuset", "memory") for _, mountPoint := range mountPoints { if mountPoint.Type == cgroupMountType { for _, opt := range mountPoint.Opts { if expectedCgroups.Has(opt) { expectedCgroups.Delete(opt) } if opt == "cpu" { cpuMountPoint = mountPoint.Path } } } } if expectedCgroups.Len() > 0 { return f, fmt.Errorf("%s - Following Cgroup subsystem not mounted: %v", localErr, expectedCgroups.List()) } // Check if cpu quota is available. // CPU cgroup is required and so it expected to be mounted at this point. periodExists, err := util.FileExists(path.Join(cpuMountPoint, "cpu.cfs_period_us")) if err != nil { glog.Errorf("failed to detect if CPU cgroup cpu.cfs_period_us is available - %v", err) } quotaExists, err := util.FileExists(path.Join(cpuMountPoint, "cpu.cfs_quota_us")) if err != nil { glog.Errorf("failed to detect if CPU cgroup cpu.cfs_quota_us is available - %v", err) } if quotaExists && periodExists { f.cpuHardcapping = true } return f, nil }