Skip to content

Commit

Permalink
[COMMON] enable to set release-version to kraft
Browse files Browse the repository at this point in the history
  • Loading branch information
chia7712 committed Jul 11, 2024
1 parent 0d08ced commit 7d3d39c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
9 changes: 8 additions & 1 deletion docker/start_broker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ declare -r JMX_OPTS="-Dcom.sun.management.jmxremote \
declare -r HEAP_OPTS="${HEAP_OPTS:-"-Xmx2G -Xms2G"}"
declare -r BROKER_PROPERTIES="/tmp/server-${BROKER_PORT}.properties"
declare -r IMAGE_NAME="ghcr.io/${ACCOUNT}/astraea/broker:$VERSION"
declare -r METADATA_VERSION=${METADATA_VERSION:-""}
# cleanup the file if it is existent
[[ -f "$BROKER_PROPERTIES" ]] && rm -f "$BROKER_PROPERTIES"

Expand Down Expand Up @@ -307,14 +308,20 @@ setLogDirs
command="./bin/kafka-server-start.sh /tmp/broker.properties"
if [[ "$quorum" == "kraft" ]]; then
if [[ "$migration" == "false" ]]; then

release_version=""
if [[ -n "$METADATA_VERSION" ]]; then
release_version="--release-version $METADATA_VERSION"
fi

if [[ -z "$CLUSTER_ID" ]]; then
echo "please set CLUSTER_ID for krafe mode"
exit 2
fi
setPropertyIfEmpty "node.id" "$NODE_ID"
setPropertyIfEmpty "process.roles" "broker"
setPropertyIfEmpty "controller.listener.names" "CONTROLLER"
command="./bin/kafka-storage.sh format -t $CLUSTER_ID -c /tmp/broker.properties --ignore-formatted && ./bin/kafka-server-start.sh /tmp/broker.properties"
command="./bin/kafka-storage.sh format -t $CLUSTER_ID $release_version -c /tmp/broker.properties --ignore-formatted && ./bin/kafka-server-start.sh /tmp/broker.properties"
else
setPropertyIfEmpty "broker.id" "$NODE_ID"
setPropertyIfEmpty "broker.id.generation.enable" "false"
Expand Down
8 changes: 7 additions & 1 deletion docker/start_controller.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ declare -r JMX_OPTS="-Dcom.sun.management.jmxremote \
declare -r HEAP_OPTS="${HEAP_OPTS:-"-Xmx2G -Xms2G"}"
declare -r CONTROLLER_PROPERTIES="/tmp/controller-${CONTROLLER_PORT}.properties"
declare -r IMAGE_NAME="ghcr.io/${ACCOUNT}/astraea/controller:$VERSION"
declare -r METADATA_VERSION=${METADATA_VERSION:-""}
# cleanup the file if it is existent
[[ -f "$CONTROLLER_PROPERTIES" ]] && rm -f "$CONTROLLER_PROPERTIES"

Expand Down Expand Up @@ -244,6 +245,11 @@ if [[ -n "$META_FOLDER" ]]; then
metaMountCommand="-v $META_FOLDER:/tmp/kafka-meta"
fi

release_version=""
if [[ -n "$METADATA_VERSION" ]]; then
release_version="--release-version $METADATA_VERSION"
fi

docker run -d --init \
--name $CONTAINER_NAME \
-e KAFKA_HEAP_OPTS="$HEAP_OPTS" \
Expand All @@ -256,7 +262,7 @@ docker run -d --init \
-p $CONTROLLER_PORT:$CONTROLLER_PORT \
-p $CONTROLLER_JMX_PORT:$CONTROLLER_JMX_PORT \
-p $EXPORTER_PORT:$EXPORTER_PORT \
"$IMAGE_NAME" sh -c "./bin/kafka-storage.sh format -t $CLUSTER_ID -c /tmp/controller.properties --ignore-formatted && ./bin/kafka-server-start.sh /tmp/controller.properties"
"$IMAGE_NAME" sh -c "./bin/kafka-storage.sh format -t $CLUSTER_ID $release_version -c /tmp/controller.properties --ignore-formatted && ./bin/kafka-server-start.sh /tmp/controller.properties"

echo "================================================="
[[ -n "$META_FOLDER" ]] && echo "mount $META_FOLDER to container: $CONTAINER_NAME"
Expand Down

0 comments on commit 7d3d39c

Please sign in to comment.