From 56fc01f3480e80040a11e5abfb5850130ba7a446 Mon Sep 17 00:00:00 2001 From: themanforfree Date: Tue, 12 Dec 2023 10:03:37 +0800 Subject: [PATCH 1/2] chore: upload xline logs if validation failed Signed-off-by: themanforfree --- .github/workflows/validation.yml | 8 +++++++- scripts/quick_start.sh | 33 +++++++++++++++++++++----------- scripts/start_xline.sh | 7 +++++++ scripts/validation_test.sh | 4 +++- 4 files changed, 39 insertions(+), 13 deletions(-) diff --git a/.github/workflows/validation.yml b/.github/workflows/validation.yml index 66df9cc12..eb6eedb5a 100644 --- a/.github/workflows/validation.yml +++ b/.github/workflows/validation.yml @@ -42,4 +42,10 @@ jobs: cp ../xline-test-utils/{private,public}.pem . docker build . -t ghcr.io/xline-kv/xline:latest docker pull gcr.io/etcd-development/etcd:v3.5.5 - bash ./validation_test.sh \ No newline at end of file + bash ./validation_test.sh + - name: upload logs + if: failure() + uses: actions/upload-artifact@v1 + with: + name: Xline logs + path: scripts/logs diff --git a/scripts/quick_start.sh b/scripts/quick_start.sh index 5d124d3c2..f5798a8b4 100755 --- a/scripts/quick_start.sh +++ b/scripts/quick_start.sh @@ -27,12 +27,15 @@ run_container() { size=${1} image="ghcr.io/xline-kv/xline:latest" for ((i = 1; i <= ${size}; i++)); do - docker run \ - -e RUST_LOG=debug -e HOSTNAME=node${i} -e MEMBERS=${MEMBERS} -e INIT_LEADER=node1\ - -e AUTH_PUBLIC_KEY=/mnt/public.pem -e AUTH_PRIVATE_KEY=/mnt/private.pem \ - -d -it --rm --name=node${i} \ - --net=xline_net --ip=${SERVERS[$i]} --cap-add=NET_ADMIN \ - --cpu-shares=1024 -m=512M -v ${DIR}:/mnt ${image} & + command_str="docker run -e RUST_LOG=debug -e HOSTNAME=node${i} -e MEMBERS=${MEMBERS} -e INIT_LEADER=node1" + command_str="${command_str} -e AUTH_PUBLIC_KEY=/mnt/public.pem -e AUTH_PRIVATE_KEY=/mnt/private.pem" + if [ -n "$LOG_PATH" ]; then + command_str="${command_str} -e LOG_FILE=${LOG_PATH}/node${i}" + fi + command_str="${command_str} -d -it --rm --name=node${i}" + command_str="${command_str} --net=xline_net --ip=${SERVERS[$i]} --cap-add=NET_ADMIN" + command_str="${command_str} --cpu-shares=1024 -m=512M -v ${DIR}:/mnt ${image}" + eval ${command_str} done docker run -d -it --rm --name=client \ --net=xline_net --ip=${SERVERS[0]} --cap-add=NET_ADMIN \ @@ -41,8 +44,16 @@ run_container() { echo container started } -stop_all -docker network create --subnet=172.20.0.0/24 xline_net >/dev/null 2>&1 -echo "A Docker network named 'xline_net' is created for communication among various xline nodes. You can use the command 'docker network rm xline_net' to remove it after use." - -run_container 3 +if [ -z "$1" ]; then + stop_all + docker network create --subnet=172.20.0.0/24 xline_net >/dev/null 2>&1 + echo "A Docker network named 'xline_net' is created for communication among various xline nodes. You can use the command 'docker network rm xline_net' to remove it after use." + run_container 3 + exit 0 +elif [ "$1" == "stop" ]; then + stop_all + exit 0 +else + echo "Unexpected argument: $1" + exit 1 +fi diff --git a/scripts/start_xline.sh b/scripts/start_xline.sh index 1a7a2b611..80b8b67b3 100755 --- a/scripts/start_xline.sh +++ b/scripts/start_xline.sh @@ -33,4 +33,11 @@ if [ "$HOSTNAME" = "$INIT_LEADER" ]; then cmd="${cmd} --is-leader" fi +if [ -n "$LOG_FILE"]; then + cmd="${cmd} \ + --log-file $LOG_FILE \ + --log-level $RUST_LOG \ + " +fi + RUST_LOG=$RUST_LOG ${cmd} diff --git a/scripts/validation_test.sh b/scripts/validation_test.sh index debfb45a9..1c22ff005 100755 --- a/scripts/validation_test.sh +++ b/scripts/validation_test.sh @@ -1,7 +1,7 @@ #!/bin/bash DIR="$(dirname $0)" QUICK_START="${DIR}/quick_start.sh" -bash ${QUICK_START} +LOG_PATH=/mnt/logs bash ${QUICK_START} ETCDCTL="docker exec -i client etcdctl --endpoints=http://172.20.0.3:2379,http://172.20.0.4:2380" LOCK_CLIENT="docker exec -i client /mnt/validation_lock_client --endpoints=http://172.20.0.3:2379" @@ -21,6 +21,7 @@ run_with_expect() { echo "command: ${cmd}" echo "expect: ${expect}" echo "result: ${res}" + bash ${QUICK_START} stop exit 1 fi } @@ -40,6 +41,7 @@ run_with_match() { echo "command: ${cmd}" echo "expect: ${expect}" echo "result: ${res}" + bash ${QUICK_START} stop exit 1 fi } From e0a388c61770156aebf33371b0af4dd83753c570 Mon Sep 17 00:00:00 2001 From: themanforfree Date: Tue, 19 Dec 2023 10:34:52 +0800 Subject: [PATCH 2/2] chore: fix hakari Signed-off-by: themanforfree --- Cargo.lock | 2 -- workspace-hack/Cargo.toml | 2 -- 2 files changed, 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f4a45ac18..9f61d1b61 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3556,7 +3556,6 @@ dependencies = [ "bytes", "clap 4.4.8", "clap_builder", - "crypto-common", "digest", "either", "futures-channel", @@ -3578,7 +3577,6 @@ dependencies = [ "opentelemetry_sdk", "rand", "serde", - "sha2", "syn 2.0.39", "time", "tokio", diff --git a/workspace-hack/Cargo.toml b/workspace-hack/Cargo.toml index 488ad583b..9ab98214e 100644 --- a/workspace-hack/Cargo.toml +++ b/workspace-hack/Cargo.toml @@ -16,7 +16,6 @@ publish = false bytes = { version = "1" } clap = { version = "4", features = ["derive", "string"] } clap_builder = { version = "4", default-features = false, features = ["color", "help", "std", "string", "suggestions", "usage"] } -crypto-common = { version = "0.1", default-features = false, features = ["std"] } digest = { version = "0.10", features = ["mac", "std"] } either = { version = "1" } futures-channel = { version = "0.3", features = ["sink"] } @@ -38,7 +37,6 @@ opentelemetry-jaeger = { version = "0.17", features = ["rt-tokio"] } opentelemetry_sdk = { version = "0.18", features = ["metrics", "rt-tokio"] } rand = { version = "0.8", features = ["small_rng"] } serde = { version = "1", features = ["derive", "rc"] } -sha2 = { version = "0.10" } time = { version = "0.3", features = ["formatting", "macros", "parsing"] } tokio = { version = "1", features = ["fs", "io-std", "io-util", "macros", "net", "rt-multi-thread", "signal", "sync", "time"] } tokio-util = { version = "0.7", features = ["codec", "io"] }