Skip to content
This repository was archived by the owner on Aug 29, 2018. It is now read-only.

Commit c9ee5b5

Browse files
author
OpenShift Bot
committed
Merge pull request #6347 from thrasher-redhat/bug1067107
Merged by openshift-bot
2 parents ab9d702 + 5c6699e commit c9ee5b5

File tree

1 file changed

+24
-23
lines changed

1 file changed

+24
-23
lines changed

node-util/sbin/oo-accept-node

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -436,12 +436,12 @@ end
436436

437437

438438
#
439-
# Check gear processes belong to cgroups
439+
# Check gear threads belong to cgroups
440440
#
441-
def check_cgroup_procs
442-
verbose("checking cgroups processes")
441+
def check_cgroup_tasks
442+
verbose("checking cgroups tasks")
443443

444-
### Gather current procs running ###
444+
### Gather current threads running ###
445445
min_uid = $CONF.get('GEAR_MIN_UID').to_i
446446
max_uid = $CONF.get('GEAR_MAX_UID').to_i
447447

@@ -455,10 +455,11 @@ def check_cgroup_procs
455455

456456
verbose("determining node uid range: #{min_uid} to #{max_uid}")
457457

458-
all_user_procs = %x[/bin/ps -e -o uid,pid].split("\n")
459-
ps_procs = Hash.new{|hash, key| hash[key] = Array.new}
460-
all_user_procs.each do |line|
461-
uid,pid = line.split[0,2]
458+
# Bug 1067107 - Check tids against tasks instead of pids against cgroup procs
459+
all_user_threads = %x[/bin/ps -e H -o uid,pid,tid].split("\n")
460+
ps_threads = Hash.new{|hash, key| hash[key] = Hash.new}
461+
all_user_threads.each do |line|
462+
uid,pid,tid = line.split[0,3]
462463
uid = uid.to_i
463464

464465
if uid.between?(min_uid, max_uid)
@@ -470,34 +471,34 @@ def check_cgroup_procs
470471
end
471472

472473
uname = passwd_lines[0].name
473-
ps_procs[uname] += [pid]
474-
ps_procs[uname].uniq!
474+
ps_threads[uname][tid] = pid
475475
end
476476
end
477477

478-
### Gather cgroup procs ###
479-
cgroup_procs = Hash.new{|hash, key| hash[key] = Hash.new{|hash, key| hash[key] = Array.new}}
478+
### Gather cgroup tasks ###
479+
tasks = Hash.new{|hash, key| hash[key] = Hash.new{|hash, key| hash[key] = Array.new}}
480480

481481
# Support mounting cgroup controllers under /cgroup/all or
482482
# /cgroup/<controller>
483-
Dir.glob("/cgroup/*/openshift/*/cgroup.procs").each do |file|
483+
Dir.glob("/cgroup/*/openshift/*/tasks").each do |file|
484484
_, _, controller, _, uuid, _ = file.split("/")
485485
lines = []
486486
IO.foreach(file).each { |line| lines << line.strip }
487-
cgroup_procs[controller][uuid] = lines
487+
tasks[controller][uuid] = lines
488488
end
489489

490490
### Compare ###
491-
ps_procs.each do |uuid,procs|
492-
cgroup_procs.each do |controller,controller_procs|
493-
missing = procs - controller_procs[uuid]
494-
missing.each do |pid|
495-
# ensure the process is still running and not defunct before failing
496-
# this fixes both the transient process and the defunct process
491+
ps_threads.each do |uuid,threads|
492+
tasks.each do |controller,controller_tasks|
493+
missing = threads.keys - controller_tasks[uuid]
494+
missing.each do |tid|
495+
# ensure the thread is still running and not defunct before failing
496+
# this fixes both the transient threads and the defunct thread
497497
# detection problems
498498
begin
499-
if File.read("/proc/#{pid}/status") !~ /^State:\s+Z/
500-
user_fail(uuid, "#{uuid} has a process missing from cgroups: #{pid} cgroups controller: #{controller}")
499+
pid = threads[tid]
500+
if File.read("/proc/#{pid}/task/#{tid}/status") !~ /^State:\s+Z/
501+
user_fail(uuid, "#{uuid} has a thread: tid:#{tid}, pid:#{pid} missing from cgroups controller: #{controller}")
501502
end
502503
rescue Errno::ENOENT
503504
end
@@ -970,7 +971,7 @@ if __FILE__ == $0
970971
check_service_contexts
971972
check_semaphores
972973
check_cgroup_config
973-
check_cgroup_procs
974+
check_cgroup_tasks
974975
check_tc_config
975976
check_quotas
976977
check_users

0 commit comments

Comments
 (0)