Skip to content

Commit

Permalink
chore: update KB_LEAVE_MEMBER_POD_IP to KB_LEAVE_MEMBER_POD_FQDN (#1314)
Browse files Browse the repository at this point in the history
  • Loading branch information
Y-Rookie authored Dec 13, 2024
1 parent 88ea9d0 commit 2e44434
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
12 changes: 6 additions & 6 deletions addons/qdrant/scripts-ut-spec/qdrant_member_leave_spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Describe "Qdrant Member Leave Script Tests"

un_setup() {
# Reset environment variables before each test
unset KB_LEAVE_MEMBER_POD_IP
unset KB_LEAVE_MEMBER_POD_FQDN
leave_peer_uri="http://test-ip:6333"
}

Expand Down Expand Up @@ -69,7 +69,7 @@ Describe "Qdrant Member Leave Script Tests"
Describe "move_shards()"
It "moves shards from leave peer to leader"
un_setup
KB_LEAVE_MEMBER_POD_IP="test-ip"
KB_LEAVE_MEMBER_POD_FQDN="test-ip"
cluster_info='{"result":{"peer_id":"leave-peer-id","raft_info":{"leader":"leader-peer-id"}}}'
leave_peer_id="leave-peer-id"
leader_peer_id="leader-peer-id"
Expand Down Expand Up @@ -99,7 +99,7 @@ Describe "Qdrant Member Leave Script Tests"

It "handles no collections found"
un_setup
KB_LEAVE_MEMBER_POD_IP="test-ip"
KB_LEAVE_MEMBER_POD_FQDN="test-ip"
curl() {
echo '{"result":{"collections":[]}}'
return 0
Expand All @@ -123,7 +123,7 @@ Describe "Qdrant Member Leave Script Tests"

It "handles no shards found in a collection"
un_setup
KB_LEAVE_MEMBER_POD_IP="test-ip"
KB_LEAVE_MEMBER_POD_FQDN="test-ip"
curl() {
if [[ $1 == *"/collections"* ]]; then
echo '{"result":{"collections":[{"name":"collection1"}]}}'
Expand Down Expand Up @@ -166,7 +166,7 @@ Describe "Qdrant Member Leave Script Tests"
Describe "remove_peer()"
It "removes the peer from the cluster"
un_setup
KB_LEAVE_MEMBER_POD_IP="test-ip"
KB_LEAVE_MEMBER_POD_FQDN="test-ip"
leave_peer_id="leave-peer-id"

curl() {
Expand All @@ -182,7 +182,7 @@ Describe "Qdrant Member Leave Script Tests"
Describe "leave_member()"
It "executes the leave member process"
un_setup
KB_LEAVE_MEMBER_POD_IP="test-ip"
KB_LEAVE_MEMBER_POD_FQDN="test-ip"
cluster_info='{"result":{"peer_id":"leave-peer-id","raft_info":{"leader":"leader-peer-id"}}}'
leave_peer_id="leave-peer-id"
leader_peer_id="leader-peer-id"
Expand Down
2 changes: 1 addition & 1 deletion addons/qdrant/scripts/qdrant-member-leave.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ test || __() {
}

init_cluster_info() {
leave_peer_uri="http://${KB_LEAVE_MEMBER_POD_IP}:6333"
leave_peer_uri="http://${KB_LEAVE_MEMBER_POD_FQDN}:6333"
cluster_info=$(curl -s "${leave_peer_uri}/cluster")
leave_peer_id=$(echo "${cluster_info}" | jq -r .result.peer_id)
leader_peer_id=$(echo "${cluster_info}" | jq -r .result.raft_info.leader)
Expand Down
2 changes: 1 addition & 1 deletion addons/qdrant/templates/componentdefinition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ spec:
command:
- /bin/sh
- -c
- /qdrant/scripts/qdrant-member-leave.sh
- /qdrant/scripts/member-leave.sh
targetPodSelector: Any
container: qdrant
runtime:
Expand Down
10 changes: 5 additions & 5 deletions addons/redis/scripts-ut-spec/redis_sentinel_member_leave_spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,25 @@ Describe "Redis Sentinel Member Leave Script Tests"
Include $common_library_file

setup() {
export KB_LEAVE_MEMBER_POD_IP="127.0.0.3"
export KB_LEAVE_MEMBER_POD_FQDN="127.0.0.3"
export KB_LEAVE_MEMBER_POD_NAME="sentinel-2"
export KB_MEMBER_ADDRESSES="sentinel-0.redis-sentinel-headless:26379,sentinel-1.redis-sentinel-headless:26379,sentinel-2.redis-sentinel-headless:26379"
export SENTINEL_PASSWORD="sentinel_password"
sentinel_leave_member_name=""
sentinel_leave_member_ip=""
sentinel_leave_member_fqdn=""
sentinel_pod_list=()
# set ut_mode to true to hack control flow in the script
ut_mode="true"
}
BeforeAll "setup"

cleanup() {
unset KB_LEAVE_MEMBER_POD_IP
unset KB_LEAVE_MEMBER_POD_FQDN
unset KB_LEAVE_MEMBER_POD_NAME
unset KB_MEMBER_ADDRESSES
unset SENTINEL_PASSWORD
unset sentinel_leave_member_name
unset sentinel_leave_member_ip
unset sentinel_leave_member_fqdn
unset sentinel_pod_list
rm -f $common_library_file;
}
Expand All @@ -48,7 +48,7 @@ Describe "Redis Sentinel Member Leave Script Tests"
It "correctly sets the sentinel leave member details and populates the sentinel pod list"
When call redis_sentinel_member_get
The variable sentinel_leave_member_name should eq "sentinel-2"
The variable sentinel_leave_member_ip should eq "127.0.0.3"
The variable sentinel_leave_member_fqdn should eq "127.0.0.3"

The variable sentinel_pod_list[0] should eq "sentinel-0.redis-sentinel-headless:26379"
The variable sentinel_pod_list[1] should eq "sentinel-1.redis-sentinel-headless:26379"
Expand Down
12 changes: 6 additions & 6 deletions addons/redis/scripts/redis-sentinel-member-leave.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ load_common_library() {
declare -g redis_default_service_port=${SENTINEL_SERVICE_PORT:-26379}
declare -A master_slave_counts
declare -g sentinel_leave_member_name
declare -g sentinel_leave_member_ip
declare -g sentinel_leave_member_fqdn
declare -a sentinel_pod_list

redis_sentinel_member_get() {
if [ -z "$KB_LEAVE_MEMBER_POD_IP" ]; then
echo "Error: Required environment variable KB_LEAVE_MEMBER_POD_IP is not set."
if [ -z "$KB_LEAVE_MEMBER_POD_FQDN" ]; then
echo "Error: Required environment variable KB_LEAVE_MEMBER_POD_FQDN is not set."
exit 1
fi

Expand All @@ -49,7 +49,7 @@ redis_sentinel_member_get() {
fi

sentinel_leave_member_name=$KB_LEAVE_MEMBER_POD_NAME
sentinel_leave_member_ip=$KB_LEAVE_MEMBER_POD_IP
sentinel_leave_member_fqdn=$KB_LEAVE_MEMBER_POD_FQDN
sentinel_pod_list=($(split "$KB_MEMBER_ADDRESSES" ","))
}

Expand All @@ -70,7 +70,7 @@ redis_sentinel_remove_monitor() {
local success=false
local output=""
while [ $retry_count -lt $max_retries ]; do
redis_sentinel_get_masters "$sentinel_leave_member_ip" "$redis_default_service_port"
redis_sentinel_get_masters "$sentinel_leave_member_fqdn" "$redis_default_service_port"
if [ -n "$temp_output" ]; then
disconnected=false
while read -r line; do
Expand Down Expand Up @@ -114,7 +114,7 @@ redis_sentinel_remove_monitor() {
esac
if [[ -n "$master_name" ]]; then
echo "master name: $master_name"
redis-cli -h "$sentinel_leave_member_ip" -p "$redis_default_service_port" -a "$SENTINEL_PASSWORD" SENTINEL REMOVE "$master_name"
redis-cli -h "$sentinel_leave_member_fqdn" -p "$redis_default_service_port" -a "$SENTINEL_PASSWORD" SENTINEL REMOVE "$master_name"
echo "sentinel no longer monitors $master_name"
master_name=""
fi
Expand Down

0 comments on commit 2e44434

Please sign in to comment.