Skip to content

Commit

Permalink
Set RAFT_BOOTSTRAP_EXPECT variable automatically based on cluster size
Browse files Browse the repository at this point in the history
  • Loading branch information
antas-marcin committed Apr 19, 2024
1 parent ba8d329 commit cd44f5d
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 4 deletions.
31 changes: 31 additions & 0 deletions .cicd/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,44 @@ function check_creates_template() {
check_string_existence "--set modules.text2vec-voyageai.enabled=true --set modules.text2vec-voyageai.apiKey=voyageaiApiKey --set modules.reranker-voyageai.enabled=true --set modules.reranker-voyageai.apiKey=voyageaiApiKey" "name: VOYAGEAI_APIKEY"

check_setting_has_value "--set replicas=3 --set env.RAFT_BOOTSTRAP_EXPECT=3" "name: RAFT_JOIN" "value: \"weaviate-0,weaviate-1,weaviate-2\""
check_setting_has_value "--set replicas=3 --set env.RAFT_BOOTSTRAP_EXPECT=3" "name: RAFT_BOOTSTRAP_EXPECT" "value: \"3\""
check_setting_has_value "--set replicas=8 --set env.RAFT_BOOTSTRAP_EXPECT=3" "name: RAFT_JOIN" "value: \"weaviate-0,weaviate-1,weaviate-2\""
check_setting_has_value "--set replicas=8 --set env.RAFT_BOOTSTRAP_EXPECT=3" "name: RAFT_BOOTSTRAP_EXPECT" "value: \"3\""
check_setting_has_value "--set replicas=1 --set env.RAFT_BOOTSTRAP_EXPECT=1" "name: RAFT_JOIN" "value: \"weaviate-0\""
check_setting_has_value "--set replicas=1 --set env.RAFT_BOOTSTRAP_EXPECT=1" "name: RAFT_BOOTSTRAP_EXPECT" "value: \"1\""
check_setting_has_value "--set replicas=4 --set env.RAFT_BOOTSTRAP_EXPECT=4" "name: RAFT_BOOTSTRAP_EXPECT" "value: \"4\""
check_setting_has_value "--set replicas=4 --set env.RAFT_BOOTSTRAP_EXPECT=4" "name: RAFT_JOIN" "value: \"weaviate-0,weaviate-1,weaviate-2,weaviate-3\""
check_setting_has_value "--set replicas=10 --set env.RAFT_BOOTSTRAP_EXPECT=4" "name: RAFT_JOIN" "value: \"weaviate-0,weaviate-1,weaviate-2,weaviate-3\""
check_setting_has_value "--set replicas=10 --set env.RAFT_JOIN=weaviate-100" "name: RAFT_JOIN" "value: \"weaviate-100\""
check_setting_has_value "--set replicas=10 --set env.RAFT_JOIN=weaviate-100" "name: RAFT_BOOTSTRAP_EXPECT" "value: \"1\""
check_setting_has_value "--set replicas=10 --set env.RAFT_JOIN=weaviate-100 --set env.RAFT_BOOTSTRAP_EXPECT=1" "name: RAFT_JOIN" "value: \"weaviate-100\""
check_setting_has_value "--set replicas=100 --set env.RAFT_JOIN=weaviate-100\,weaviate-200" "name: RAFT_JOIN" "value: \"weaviate-100,weaviate-200\""
check_setting_has_value "--set replicas=100 --set env.RAFT_JOIN=weaviate-100\,weaviate-200" "name: RAFT_BOOTSTRAP_EXPECT" "value: \"2\""

check_setting_has_value "--set replicas=1" "name: RAFT_JOIN" "value: \"weaviate-0\""
check_setting_has_value "--set replicas=1" "name: RAFT_BOOTSTRAP_EXPECT" "value: \"1\""
check_setting_has_value "--set replicas=2" "name: RAFT_JOIN" "value: \"weaviate-0\""
check_setting_has_value "--set replicas=2" "name: RAFT_BOOTSTRAP_EXPECT" "value: \"1\""
check_setting_has_value "--set replicas=3" "name: RAFT_JOIN" "value: \"weaviate-0\""
check_setting_has_value "--set replicas=3" "name: RAFT_BOOTSTRAP_EXPECT" "value: \"1\""
check_setting_has_value "--set replicas=4" "name: RAFT_JOIN" "value: \"weaviate-0,weaviate-1,weaviate-2\""
check_setting_has_value "--set replicas=4" "name: RAFT_BOOTSTRAP_EXPECT" "value: \"3\""
check_setting_has_value "--set replicas=5" "name: RAFT_JOIN" "value: \"weaviate-0,weaviate-1,weaviate-2\""
check_setting_has_value "--set replicas=5" "name: RAFT_BOOTSTRAP_EXPECT" "value: \"3\""
check_setting_has_value "--set replicas=6" "name: RAFT_JOIN" "value: \"weaviate-0,weaviate-1,weaviate-2\""
check_setting_has_value "--set replicas=6" "name: RAFT_BOOTSTRAP_EXPECT" "value: \"3\""
check_setting_has_value "--set replicas=7" "name: RAFT_JOIN" "value: \"weaviate-0,weaviate-1,weaviate-2\""
check_setting_has_value "--set replicas=7" "name: RAFT_BOOTSTRAP_EXPECT" "value: \"3\""
check_setting_has_value "--set replicas=8" "name: RAFT_JOIN" "value: \"weaviate-0,weaviate-1,weaviate-2\""
check_setting_has_value "--set replicas=8" "name: RAFT_BOOTSTRAP_EXPECT" "value: \"3\""
check_setting_has_value "--set replicas=9" "name: RAFT_JOIN" "value: \"weaviate-0,weaviate-1,weaviate-2\""
check_setting_has_value "--set replicas=9" "name: RAFT_BOOTSTRAP_EXPECT" "value: \"3\""
check_setting_has_value "--set replicas=10" "name: RAFT_JOIN" "value: \"weaviate-0,weaviate-1,weaviate-2,weaviate-3,weaviate-4\""
check_setting_has_value "--set replicas=10" "name: RAFT_BOOTSTRAP_EXPECT" "value: \"5\""
check_setting_has_value "--set replicas=11" "name: RAFT_JOIN" "value: \"weaviate-0,weaviate-1,weaviate-2,weaviate-3,weaviate-4\""
check_setting_has_value "--set replicas=11" "name: RAFT_BOOTSTRAP_EXPECT" "value: \"5\""
check_setting_has_value "--set replicas=100" "name: RAFT_JOIN" "value: \"weaviate-0,weaviate-1,weaviate-2,weaviate-3,weaviate-4\""
check_setting_has_value "--set replicas=100" "name: RAFT_BOOTSTRAP_EXPECT" "value: \"5\""

_settingPassageQueryOn="--set modules.text2vec-contextionary.enabled=false --set modules.text2vec-transformers.passageQueryServices.passage.enabled=true --set modules.text2vec-transformers.passageQueryServices.query.enabled=true"
check_setting_has_value "$_settingPassageQueryOn" "name: TRANSFORMERS_PASSAGE_INFERENCE_API" "value: http://transformers-inference-passage.default.svc.cluster.local.:8080"
Expand Down
16 changes: 16 additions & 0 deletions weaviate/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,15 @@ Raft cluster configuration settings
{{- define "raft_configuration" -}}
{{- $replicas := .Values.replicas | int -}}
{{- $voters := .Values.env.RAFT_BOOTSTRAP_EXPECT | int -}}
{{- if empty .Values.env.RAFT_BOOTSTRAP_EXPECT -}}
{{- if ge $replicas 10 -}}
{{- $voters = 5 -}}
{{- else if ge $replicas 4 -}}
{{- $voters = 3 -}}
{{- else -}}
{{- $voters = 1 -}}
{{- end -}}
{{- end -}}
{{- if gt $voters $replicas -}}
{{- fail "env.RAFT_BOOTSTRAP_EXPECT value cannot be greater than replicas value" -}}
{{- end -}}
Expand All @@ -196,8 +205,15 @@ Raft cluster configuration settings
value: "{{ join "," $nodes }}"
{{- else -}}
{{- $votersCount := len (split "," .Values.env.RAFT_JOIN) -}}
{{- if empty .Values.env.RAFT_BOOTSTRAP_EXPECT }}
{{- $voters = $votersCount -}}
{{- end -}}
{{- if not (eq $votersCount $voters) -}}
{{- fail "env.RAFT_BOOTSTRAP_EXPECT value needs to be equal to number of env.RAFT_JOIN nodes" -}}
{{- end -}}
{{- end -}}
{{- if empty .Values.env.RAFT_BOOTSTRAP_EXPECT }}
- name: RAFT_BOOTSTRAP_EXPECT
value: "{{ $voters }}"
{{- end -}}
{{- end -}}
9 changes: 5 additions & 4 deletions weaviate/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -259,11 +259,12 @@ env:
CLUSTER_GOSSIP_BIND_PORT: 7000
CLUSTER_DATA_BIND_PORT: 7001

# Set RAFT cluster expected number of voter nodes at bootstrap
RAFT_BOOTSTRAP_EXPECT: 1
# Set RAFT cluster expected number of voter nodes at bootstrap.
# By default helm automatically sets this value based on the cluster size.
# RAFT_BOOTSTRAP_EXPECT: 1

# Set RAFT cluster bootstrap timeout (in seconds), default is 10 (seconds)
# RAFT_BOOTSTRAP_TIMEOUT: 10
# Set RAFT cluster bootstrap timeout (in seconds), default is 90 (seconds)
# RAFT_BOOTSTRAP_TIMEOUT: 90

# Set manually RAFT voter nodes.
# RAFT_JOIN value is automatically generated by "raft_configuration"
Expand Down

0 comments on commit cd44f5d

Please sign in to comment.