From 7d3d39c99484c28829b517b0cbdd3c1a187cfd9f Mon Sep 17 00:00:00 2001 From: Chia-Ping Tsai Date: Fri, 12 Jul 2024 04:57:33 +0800 Subject: [PATCH] [COMMON] enable to set release-version to kraft --- docker/start_broker.sh | 9 ++++++++- docker/start_controller.sh | 8 +++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/docker/start_broker.sh b/docker/start_broker.sh index 2dea24cbd7..2ba10762c2 100755 --- a/docker/start_broker.sh +++ b/docker/start_broker.sh @@ -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" @@ -307,6 +308,12 @@ 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 @@ -314,7 +321,7 @@ if [[ "$quorum" == "kraft" ]]; then 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" diff --git a/docker/start_controller.sh b/docker/start_controller.sh index 1281316246..5f09a27e22 100755 --- a/docker/start_controller.sh +++ b/docker/start_controller.sh @@ -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" @@ -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" \ @@ -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"