From 94969f4e97be3ffaff7f381277a472e81758ba76 Mon Sep 17 00:00:00 2001 From: usmannasir Date: Tue, 11 Nov 2025 22:36:15 +0500 Subject: [PATCH] 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 --- plogical/resourceLimits.py | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/plogical/resourceLimits.py b/plogical/resourceLimits.py index b0db3263a..0ca630497 100644 --- a/plogical/resourceLimits.py +++ b/plogical/resourceLimits.py @@ -141,14 +141,36 @@ class ResourceLimitsManager: logging.writeToFile("For RHEL 8 family, see instructions above to enable cgroups v2") return False - # Check if lscgctl exists + # Check if lscgctl exists and is properly configured + needs_setup = False + if not os.path.exists(self.LSCGCTL_PATH): logging.writeToFile("lscgctl not found, attempting to run lssetup...") + needs_setup = True + else: + # lscgctl exists, but check if LiteSpeed Containers is actually configured + # by testing a simple command + try: + test_result = subprocess.run( + [self.LSCGCTL_PATH, 'version'], + capture_output=True, + text=True, + timeout=10 + ) - # Try to run lssetup + # Check for the error message that indicates setup is needed + if "You must configure LiteSpeed for LiteSpeed Containers" in test_result.stderr: + logging.writeToFile("LiteSpeed Containers not configured, attempting to run lssetup...") + needs_setup = True + except Exception as e: + logging.writeToFile(f"Error testing lscgctl: {str(e)}, attempting to run lssetup...") + needs_setup = True + + # Run lssetup if needed + if needs_setup: if os.path.exists(self.LSSETUP_PATH): result = subprocess.run( - [self.LSSETUP_PATH], + [self.LSSETUP_PATH, '-c', '2', '-n', '0', '-s', '/usr/local/lsws'], capture_output=True, text=True, timeout=30