File tree Expand file tree Collapse file tree 2 files changed +25
-20
lines changed
SingularityExecutor/src/main/java/com/hubspot/singularity/executor Expand file tree Collapse file tree 2 files changed +25
-20
lines changed Original file line number Diff line number Diff line change @@ -66,11 +66,16 @@ private static Path getCpuCgroupDirectory(SingularityExecutorTask task)
6666 )
6767 );
6868 for (String cgroup : cgroups ) {
69- if (cgroup .contains (":cpu:" )) {
70- String [] segments = cgroup .split (":" );
71- String cgroupPath = getBaseCgroupPath () + segments [segments .length - 1 ];
72- LOG .info ("Will start watcher for directory {}" , cgroupPath );
73- return Paths .get (cgroupPath );
69+ String [] segments = cgroup .split (":" , 3 );
70+ if (segments .length == 3 ) {
71+ String [] subsystems = segments [1 ].split ("," );
72+ for (String subsystem : subsystems ) {
73+ if (subsystem .equals ("cpu" )) {
74+ String cgroupPath = getBaseCgroupPath () + segments [2 ];
75+ LOG .info ("Will start watcher for directory {}" , cgroupPath );
76+ return Paths .get (cgroupPath );
77+ }
78+ }
7479 }
7580 }
7681 throw new RuntimeException (
Original file line number Diff line number Diff line change @@ -394,21 +394,21 @@ private Optional<Integer> getNumThreadsFromCgroup(
394394 );
395395 if (Files .exists (procCgroupPath )) {
396396 for (String line : Files .readAllLines (procCgroupPath , Charsets .UTF_8 )) {
397- final Matcher matcher = CGROUP_CPU_REGEX . matcher ( line );
398- if (matcher . matches () ) {
399- return Optional . of (
400- Files
401- . readAllLines (
402- Paths . get (
403- String .format (
404- configuration .getCgroupsMesosCpuTasksFormat (),
405- matcher . group ( 1 )
406- )
407- ),
408- Charsets .UTF_8
409- )
410- . size ()
411- );
397+ String [] segments = line . split ( ":" , 3 );
398+ if (segments . length == 3 ) {
399+ String [] subsystems = segments [ 1 ]. split ( "," );
400+ String cgroup = segments [ 2 ];
401+ for ( String subsystem : subsystems ) {
402+ if ( subsystem . equals ( "cpu" )) {
403+ String tasksPath = String .format (
404+ configuration .getCgroupsMesosCpuTasksFormat (),
405+ cgroup
406+ );
407+ return Optional . of (
408+ Files . readAllLines ( Paths . get ( tasksPath ), Charsets .UTF_8 ). size ()
409+ );
410+ }
411+ }
412412 }
413413 }
414414 LOG .warn ("Unable to parse cgroup container from {}" , procCgroupPath .toString ());
You can’t perform that action at this time.
0 commit comments