Skip to content

Commit

Permalink
work in progress for idaholab#473, install.py is broken here
Browse files Browse the repository at this point in the history
  • Loading branch information
mmguero committed Jul 18, 2024
1 parent 98ee0ed commit c97c7dd
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 19 deletions.
4 changes: 2 additions & 2 deletions scripts/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,7 @@ def stop(wipe=False):
localPath = LocalPathForContainerBindMount(
boundPath.service,
dockerComposeYaml,
boundPath.container_dir,
boundPath.target,
MalcolmPath,
)
if localPath and os.path.isdir(localPath):
Expand Down Expand Up @@ -1035,7 +1035,7 @@ def start():
localPath = LocalPathForContainerBindMount(
boundPath.service,
dockerComposeYaml,
boundPath.container_dir,
boundPath.target,
MalcolmPath,
)
if localPath:
Expand Down
49 changes: 34 additions & 15 deletions scripts/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -2153,17 +2153,21 @@ def tweak_malcolm_runtime(self, malcolm_install_path):
os.chown(envFile, int(puid), int(pgid))

if self.orchMode is OrchestrationFramework.DOCKER_COMPOSE:

# modify docker-compose specific values (port mappings, volume bind mounts, etc.) in-place in docker-compose files
for composeFile in configFiles:

# save off owner of original files
composeFileStat = os.stat(composeFile)
origUid, origGuid = composeFileStat[4], composeFileStat[5]
try:

# load the docker-compose file
data = LoadYaml(composeFile)

if 'services' in data:

###################################
# stuff for all services
for service in data['services']:

Expand All @@ -2184,7 +2188,12 @@ def tweak_malcolm_runtime(self, malcolm_install_path):
imageLineSpit[-1] = imageLineSpit[-1].split("-", 1)[0] + args.imageArch
deep_set(data, ['services', service, 'image'], ":".join(imageLineSpit))

###################################
# stuff for specific services

###################################
# for "large' storage locations (pcap, logs, opensearch, etc.) replace
# bind mount sources with user-specified locations
boundPathsToAdjust = (
BoundPathReplacer("arkime", "/data/pcap", pcapDir),
BoundPathReplacer("arkime-live", "/data/pcap", pcapDir),
Expand Down Expand Up @@ -2214,23 +2223,30 @@ def tweak_malcolm_runtime(self, malcolm_install_path):
),
)
for boundPath in boundPathsToAdjust:
if (boundPath.service in data['services']) and (
'volumes' in data['services'][boundPath.service]
if (
(boundPath.service in data['services'])
and ('volumes' in data['services'][boundPath.service])
and os.path.isdir(boundPath.source)
):
for volIdx, volVal in enumerate(data['services'][boundPath.service]['volumes']):
eprint(volVal)

# TODO
# ##################################################################################################
# def ReplaceBindMountLocation(line, location, linePrefix):
# # TODO: switch to ruamel
# if os.path.isdir(location):
# volumeParts = line.strip().lstrip('-').lstrip().split(':')
# volumeParts[0] = location
# return "{}- {}".format(linePrefix, ':'.join(volumeParts))
# else:
# return line

if (
isinstance(volVal, dict)
and ('source' in volVal)
and ('target' in volVal)
and (volVal['target'] == boundPath.target)
):
data['services'][boundPath.service]['volumes'][volIdx][
'source'
] = boundPath.source
elif isinstance(volVal, str) and re.match(
fr'^.+:{boundPath.target}(:.+)?\s*$', volVal
):
volumeParts = volVal.strip().split(':')
volumeParts[0] = boundPath.source
data['services'][boundPath.service]['volumes'][volIdx] = ':'.join(volumeParts)
###################################

###################################
# filebeat/logstash/upload port bind IPs (0.0.0.0 vs. 127.0.0.1)
# set bind IPs based on whether it should be externally exposed or not
for service, portInfo in {
Expand All @@ -2242,7 +2258,9 @@ def tweak_malcolm_runtime(self, malcolm_install_path):
data['services'][service]['ports'] = [
f"{'0.0.0.0' if portInfo[0] is True else '127.0.0.1'}:{portInfo[1]}:{portInfo[2]}"
]
###################################

###################################
# nginx-proxy has got a lot going on
if 'nginx-proxy' in data['services']:

Expand Down Expand Up @@ -2316,6 +2334,7 @@ def tweak_malcolm_runtime(self, malcolm_install_path):
data['services']['nginx-proxy']['labels'][
'traefik.http.services.osmalcolm.loadbalancer.server.port'
] = '9200'
###################################

# re-write the network definition from scratch
if 'networks' in data:
Expand Down
4 changes: 2 additions & 2 deletions scripts/malcolm_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,13 @@ class UserInterfaceMode(IntFlag):

BoundPath = namedtuple(
"BoundPath",
["service", "container_dir", "files", "relative_dirs", "clean_empty_dirs"],
["service", "target", "files", "relative_dirs", "clean_empty_dirs"],
rename=False,
)

BoundPathReplacer = namedtuple(
"BoundPathReplacer",
["service", "container_dir", "host_dir"],
["service", "target", "source"],
rename=False,
)

Expand Down

0 comments on commit c97c7dd

Please sign in to comment.