Skip to content

Commit 3ad2484

Browse files
Yinwei-Yugroobyming
authored andcommitted
feat(dbs): 支持 qdrant 缩容,shard 自动迁移 #16365
1 parent ad062be commit 3ad2484

File tree

3 files changed

+29
-7
lines changed

3 files changed

+29
-7
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,5 @@ package-lock.json
2626
.history/
2727
dbm-services/.history/
2828
dbm-ui/.history/
29+
# trellis
30+
.trellis

dbm-services/k8s-dbs/k8s-utils/helm/storageAddon/qdrant/scripts/qdrant-member-leave.sh

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#!/usr/bin/env sh
22

3+
# Add qdrant tools (curl, jq) to PATH
4+
export PATH="/qdrant/tools:$PATH"
5+
36
# shellcheck disable=SC2034
47
ut_mode="false"
58
test || __() {
@@ -8,7 +11,24 @@ test || __() {
811
}
912

1013
init_cluster_info() {
11-
leave_peer_uri="http://${KB_LEAVE_MEMBER_POD_FQDN}:6333"
14+
# KB_LEAVE_MEMBER_POD_FQDN is not a standard KubeBlocks env var in 0.9.x
15+
# Fall back to KB_LEAVE_MEMBER_POD_IP (standard), or construct FQDN from KB_LEAVE_MEMBER_POD_NAME
16+
if [ -n "${KB_LEAVE_MEMBER_POD_FQDN}" ]; then
17+
leave_peer_uri="http://${KB_LEAVE_MEMBER_POD_FQDN}:6333"
18+
elif [ -n "${KB_LEAVE_MEMBER_POD_IP}" ]; then
19+
leave_peer_uri="http://${KB_LEAVE_MEMBER_POD_IP}:6333"
20+
elif [ -n "${KB_LEAVE_MEMBER_POD_NAME}" ]; then
21+
# Construct FQDN: <pod-name>.<headless-svc>.<namespace>.svc.cluster.local
22+
headless_svc=$(echo "${KB_LEAVE_MEMBER_POD_NAME}" | sed 's/-[0-9]*$//')-headless
23+
namespace=$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace 2>/dev/null || echo "default")
24+
leave_peer_uri="http://${KB_LEAVE_MEMBER_POD_NAME}.${headless_svc}.${namespace}.svc.cluster.local:6333"
25+
else
26+
echo "ERROR: no leave member pod info available. KB_LEAVE_MEMBER_POD_FQDN, KB_LEAVE_MEMBER_POD_IP, KB_LEAVE_MEMBER_POD_NAME are all empty"
27+
echo "Available KB_ env vars:"
28+
env | grep -i "^KB_" || echo "(none)"
29+
exit 1
30+
fi
31+
echo "leave_peer_uri: ${leave_peer_uri}"
1232
cluster_info=$(curl -s "${leave_peer_uri}/cluster")
1333
leave_peer_id=$(echo "${cluster_info}" | jq -r .result.peer_id)
1434
leader_peer_id=$(echo "${cluster_info}" | jq -r .result.raft_info.leader)

dbm-services/k8s-dbs/k8s-utils/helm/storageAddon/qdrant/templates/cmpd.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ spec:
4545
podFQDNs: Required
4646
lifecycleActions:
4747
memberLeave:
48-
exec:
49-
image: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.tools.repository }}:{{ .Values.image.tools.tag | default "latest" }}
50-
command:
51-
- /bin/sh
52-
- -c
53-
- /qdrant/scripts/member-leave.sh
48+
customHandler:
49+
exec:
50+
command:
51+
- /bin/sh
52+
- -c
53+
- /qdrant/scripts/member-leave.sh
5454
targetPodSelector: Any
5555
container: qdrant
5656
runtime:

0 commit comments

Comments
 (0)