Skip to content

Commit

Permalink
for idaholab#539, some containers need resource request specified for…
Browse files Browse the repository at this point in the history
… Kubernetes. parse out opensearch and logstash JAVA_OPTS and create kubernetes resource requests for memory basedon those values to ensure those containers don't start on pods with insufficient memory
  • Loading branch information
mmguero committed Aug 13, 2024
1 parent 9418da0 commit cd305bb
Show file tree
Hide file tree
Showing 2 changed files with 215 additions and 74 deletions.
26 changes: 26 additions & 0 deletions scripts/malcolm_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import importlib
import json
import os
import math
import platform
import re
import string
Expand Down Expand Up @@ -172,6 +173,31 @@ def LocalPathForContainerBindMount(service, dockerComposeContents, containerPath
return localPath


##################################################################################################
def GetMemMegabytesFromJavaOptsLine(val):
resultStr = None
resultMB = 0
for opt in ('Xmx', 'Xms'):
if resultStr is not None:
break
if match := re.search(fr'-{opt}(\d+[kmg])', val, re.IGNORECASE):
resultStr = match.group(1)
if resultStr is not None:
value = int(resultStr[:-1])
unit = resultStr[-1].lower()
if unit == 'g':
resultMB = value * 1024
elif unit == 'm':
resultMB = value
elif unit == 'k':
resultMB = math.ceil(value / 1024)
else:
resultMB = 0
if resultMB < 1:
resultMB = 0
return resultMB


##################################################################################################
def GetUidGidFromEnv(configDir=None):
configDirToCheck = configDir if configDir and os.path.isdir(configDir) else os.path.join(MalcolmPath, 'config')
Expand Down
Loading

0 comments on commit cd305bb

Please sign in to comment.