Skip to content

Commit 9c23164

Browse files
authored
Fixing centos-7 ulimits (#432)
1 parent a0c90e6 commit 9c23164

File tree

2 files changed

+51
-10
lines changed

2 files changed

+51
-10
lines changed

base/centos-7/install.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ echo "
4141
## Allows people in group sudo to run all commands
4242
%sudo ALL=(ALL) ALL" >> /etc/sudoers
4343

44+
# Remove nproc limits
45+
rm -rf /etc/security/limits.d/20-nproc.conf
46+
4447
# Clean
4548
yum clean all
4649
rm -rf /install.sh /anaconda-post.log /var/log/anaconda/*

tests/test_single_splunk_image.py

Lines changed: 48 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,31 @@ def test_splunk_scloud(self):
8181
time.sleep(5)
8282
# If the container is still running, we should be able to exec inside
8383
# Check that the version returns successfully for multiple users
84-
exec_command = self.client.exec_create(cid, "scloud version", user="splunk")
85-
std_out = self.client.exec_start(exec_command)
86-
assert "scloud version " in std_out
87-
exec_command = self.client.exec_create(cid, "scloud version", user="ansible")
84+
for user in ["splunk", "ansible"]:
85+
exec_command = self.client.exec_create(cid, "scloud version", user=user)
86+
std_out = self.client.exec_start(exec_command)
87+
assert "scloud version " in std_out
88+
except Exception as e:
89+
self.logger.error(e)
90+
raise e
91+
finally:
92+
if cid:
93+
self.client.remove_container(cid, v=True, force=True)
94+
95+
def test_splunk_ulimit(self):
96+
cid = None
97+
try:
98+
# Run container
99+
cid = self.client.create_container(self.SPLUNK_IMAGE_NAME, tty=True, command="no-provision")
100+
cid = cid.get("Id")
101+
self.client.start(cid)
102+
# Wait a bit
103+
time.sleep(5)
104+
# If the container is still running, we should be able to exec inside
105+
# Check that nproc limits are unlimited
106+
exec_command = self.client.exec_create(cid, "sudo -u splunk bash -c 'ulimit -u'")
88107
std_out = self.client.exec_start(exec_command)
89-
assert "scloud version " in std_out
108+
assert "unlimited" in std_out
90109
except Exception as e:
91110
self.logger.error(e)
92111
raise e
@@ -2635,12 +2654,31 @@ def test_uf_scloud(self):
26352654
time.sleep(5)
26362655
# If the container is still running, we should be able to exec inside
26372656
# Check that the version returns successfully for multiple users
2638-
exec_command = self.client.exec_create(cid, "scloud version", user="splunk")
2639-
std_out = self.client.exec_start(exec_command)
2640-
assert "scloud version " in std_out
2641-
exec_command = self.client.exec_create(cid, "scloud version", user="ansible")
2657+
for user in ["splunk", "ansible"]:
2658+
exec_command = self.client.exec_create(cid, "scloud version", user=user)
2659+
std_out = self.client.exec_start(exec_command)
2660+
assert "scloud version " in std_out
2661+
except Exception as e:
2662+
self.logger.error(e)
2663+
raise e
2664+
finally:
2665+
if cid:
2666+
self.client.remove_container(cid, v=True, force=True)
2667+
2668+
def test_uf_ulimit(self):
2669+
cid = None
2670+
try:
2671+
# Run container
2672+
cid = self.client.create_container(self.UF_IMAGE_NAME, tty=True, command="no-provision")
2673+
cid = cid.get("Id")
2674+
self.client.start(cid)
2675+
# Wait a bit
2676+
time.sleep(5)
2677+
# If the container is still running, we should be able to exec inside
2678+
# Check that nproc limits are unlimited
2679+
exec_command = self.client.exec_create(cid, "sudo -u splunk bash -c 'ulimit -u'")
26422680
std_out = self.client.exec_start(exec_command)
2643-
assert "scloud version " in std_out
2681+
assert "unlimited" in std_out
26442682
except Exception as e:
26452683
self.logger.error(e)
26462684
raise e

0 commit comments

Comments
 (0)