Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Force Choosing First Local IP For Cassandra #383

Merged
merged 1 commit into from
Sep 24, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Handle cases when we have multiple IPs.
  • Loading branch information
xusine committed Sep 24, 2022
commit 5c9f740af6c81e901349893f7fbd2dae486e803a
13 changes: 9 additions & 4 deletions benchmarks/data-serving/server/files/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
#!/bin/bash
set -e

echo Server IP
hostname --ip-address
# It's possible that one machine has multiple ip addresses mapped to the hostname
# For instance, ARM image inside QEMU has this problem.
# Therefore, we will only keep the first IP address where the Cassandra server is also listened.

LISTEN_IP=$(cut --delimiter=" " -f1 <<< $(hostname --ip-address))

echo Server will listen on IP: $LISTEN_IP

if [ -z "$CASSANDRA_SEEDS" ]; then
NEED_INIT=1
Expand All @@ -22,13 +27,13 @@ if [ "$1" = 'cassandra' ] || [ "$1" = 'bash' ]; then

: ${CASSANDRA_LISTEN_ADDRESS='auto'}
if [ "$CASSANDRA_LISTEN_ADDRESS" = 'auto' ]; then
CASSANDRA_LISTEN_ADDRESS="$(hostname --ip-address)"
CASSANDRA_LISTEN_ADDRESS="$LISTEN_IP"
fi

: ${CASSANDRA_BROADCAST_ADDRESS="$CASSANDRA_LISTEN_ADDRESS"}

if [ "$CASSANDRA_BROADCAST_ADDRESS" = 'auto' ]; then
CASSANDRA_BROADCAST_ADDRESS="$(hostname --ip-address)"
CASSANDRA_BROADCAST_ADDRESS="$LISTEN_IP"
fi
: ${CASSANDRA_BROADCAST_RPC_ADDRESS:=$CASSANDRA_BROADCAST_ADDRESS}

Expand Down