Skip to content

Commit 94969f4

Browse files
committed
Improve lssetup auto-detection for LiteSpeed Containers
- Add test to verify LiteSpeed Containers is actually configured - Check for 'You must configure LiteSpeed' error in lscgctl output - Run lssetup with proper flags when configuration is needed - Fixes issue where lscgctl exists but LiteSpeed Containers not configured
1 parent 6d66e57 commit 94969f4

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

plogical/resourceLimits.py

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,36 @@ def _ensure_cgroups_enabled(self):
141141
logging.writeToFile("For RHEL 8 family, see instructions above to enable cgroups v2")
142142
return False
143143

144-
# Check if lscgctl exists
144+
# Check if lscgctl exists and is properly configured
145+
needs_setup = False
146+
145147
if not os.path.exists(self.LSCGCTL_PATH):
146148
logging.writeToFile("lscgctl not found, attempting to run lssetup...")
149+
needs_setup = True
150+
else:
151+
# lscgctl exists, but check if LiteSpeed Containers is actually configured
152+
# by testing a simple command
153+
try:
154+
test_result = subprocess.run(
155+
[self.LSCGCTL_PATH, 'version'],
156+
capture_output=True,
157+
text=True,
158+
timeout=10
159+
)
160+
161+
# Check for the error message that indicates setup is needed
162+
if "You must configure LiteSpeed for LiteSpeed Containers" in test_result.stderr:
163+
logging.writeToFile("LiteSpeed Containers not configured, attempting to run lssetup...")
164+
needs_setup = True
165+
except Exception as e:
166+
logging.writeToFile(f"Error testing lscgctl: {str(e)}, attempting to run lssetup...")
167+
needs_setup = True
147168

148-
# Try to run lssetup
169+
# Run lssetup if needed
170+
if needs_setup:
149171
if os.path.exists(self.LSSETUP_PATH):
150172
result = subprocess.run(
151-
[self.LSSETUP_PATH],
173+
[self.LSSETUP_PATH, '-c', '2', '-n', '0', '-s', '/usr/local/lsws'],
152174
capture_output=True,
153175
text=True,
154176
timeout=30

0 commit comments

Comments
 (0)