fix: Handle /proc/1/sched missing error
Reviewed-By: Rob Crittenden <rcritten@redhat.com> Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
This commit is contained in:
1 parent
0ce3ab36b4
commit
d33a2523ee
1 file changed
+14
-8
@@ -1044,18 +1044,24 @@ def in_container():
|
||||
systemd-detect-virt requires the whole systemd subsystem which
|
||||
isn't a reasonable require in a container.
|
||||
"""
|
||||
data_sched = None
|
||||
if not is_hidepid():
|
||||
with open('/proc/1/sched', 'r') as sched:
|
||||
data_sched = sched.readline()
|
||||
else:
|
||||
data_sched = []
|
||||
try:
|
||||
with open('/proc/1/sched', 'r') as sched:
|
||||
data_sched = sched.readline()
|
||||
except (FileNotFoundError, PermissionError):
|
||||
pass
|
||||
|
||||
with open('/proc/self/cgroup', 'r') as cgroup:
|
||||
data_cgroup = cgroup.readline()
|
||||
data_cgroup = None
|
||||
try:
|
||||
with open('/proc/self/cgroup', 'r') as cgroup:
|
||||
data_cgroup = cgroup.readline()
|
||||
except (FileNotFoundError, PermissionError):
|
||||
pass
|
||||
|
||||
checks = [
|
||||
data_sched.split()[0] not in ('systemd', 'init',),
|
||||
data_cgroup.split()[0] in ('libpod'),
|
||||
data_sched and data_sched.split()[0] not in ('systemd', 'init',),
|
||||
data_cgroup and data_cgroup.split()[0] in ('libpod'),
|
||||
os.path.exists('/.dockerenv'),
|
||||
os.path.exists('/.dockerinit'),
|
||||
os.getenv('container', None) is not None
|
||||
|
||||
Reference in new issue
Block a user