Skip to content

Commit

Permalink
To enable compactor in docker container (#3551)
Browse files Browse the repository at this point in the history
+Install netifaces in docker
+Modify compactor runner script to resolve correct hostname for docker
  • Loading branch information
SravanthiAshokKumar committed Mar 17, 2023
1 parent 1a33479 commit 6f3a8af
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions infrastructure/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ WORKDIR /app

RUN apt update && apt -y install iptables bash jq python3 sudo iproute2 python3-pip curl
RUN python3 -m pip install pyyaml==5.4.1
RUN python3 -m pip install netifaces==0.11.0

COPY target/${CORFU_JAR} /usr/share/corfu/lib/${CORFU_JAR}
COPY target/${CMDLETS_JAR} /usr/share/corfu/lib/${CMDLETS_JAR}
Expand Down
11 changes: 10 additions & 1 deletion scripts/compactor_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
COMPACTOR_BULK_READ_SIZE = 50
COMPACTOR_JVM_XMX = 1024
FORCE_DISABLE_CHECKPOINTING = "FORCE_DISABLE_CHECKPOINTING"
POD_NAME = "POD_NAME"
POD_NAMESPACE = "POD_NAMESPACE"

logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
Expand Down Expand Up @@ -112,8 +114,15 @@ def append_compactor_config(self, compactor_config):

def _resolve_ip_address(self, ifname):
"""
Get an address of from the network interfaces. IPv6 is preferred over IPv4.
If environment variable is set, resolve using it. Else, get an
address of from the network interfaces. IPv6 is preferred over IPv4.
"""

pod_name = os.environ.get(POD_NAME, "default_name")
pod_namespace = os.environ.get(POD_NAMESPACE, "default_namespace")
if pod_name != "default_name" and pod_namespace != "default_namespace":
return pod_name + ".corfu-headless." + pod_namespace + ".svc.cluster.local"

network_interfaces = netifaces.interfaces()
ip_version = netifaces.AF_INET6 # Default is IPV6
generic_interfaces = ['eth0', 'en0', 'eth', 'en', 'lo']
Expand Down

0 comments on commit 6f3a8af

Please sign in to comment.