Skip to content

Commit

Permalink
Fix etcd replicaCount
Browse files Browse the repository at this point in the history
Signed-off-by: haorenfsa <[email protected]>
  • Loading branch information
haorenfsa committed Oct 25, 2024
1 parent 2aa883f commit 5757ca6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
5 changes: 2 additions & 3 deletions apis/milvus.io/v1beta1/milvus_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,10 +360,9 @@ func (r *Milvus) defaultEtcd() {
if r.Spec.Dep.Etcd.InCluster.Values.Data == nil {
r.Spec.Dep.Etcd.InCluster.Values.Data = map[string]interface{}{}
}
etcdReplicaCountRaw, etcdReplicaCountExists := r.Spec.Dep.Etcd.InCluster.Values.Data["replicaCount"]
etcdReplicaCountInt64, etcdReplicaCountValid := etcdReplicaCountRaw.(int64)
etcdReplicaCountInt64, etcdReplicaCountValid := util.GetInt64Value(r.Spec.Dep.Etcd.InCluster.Values.Data, "replicaCount")
var etcdReplicaCount int
if !etcdReplicaCountExists || !etcdReplicaCountValid {
if !etcdReplicaCountValid {
if r.Spec.Mode == MilvusModeStandalone {
etcdReplicaCount = 1
} else {
Expand Down
14 changes: 14 additions & 0 deletions pkg/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,20 @@ import (

const MqTypeConfigKey = "messageQueue"

// GetInt64Value supports int64 / float64 in values
func GetInt64Value(values map[string]interface{}, fields ...string) (int64, bool) {
val, found, err := unstructured.NestedInt64(values, fields...)
if err == nil && found {
return val, true
}

fval, found, err := unstructured.NestedFloat64(values, fields...)
if err == nil && found {
return int64(fval), true
}
return 0, false
}

func GetBoolValue(values map[string]interface{}, fields ...string) (bool, bool) {
val, found, err := unstructured.NestedBool(values, fields...)
if err != nil || !found {
Expand Down
2 changes: 1 addition & 1 deletion test/min-milvus-feature.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ spec:
deletionPolicy: Delete
pvcDeletion: true
values:
replicaCount: 1
replicaCount: 3
storage:
inCluster:
deletionPolicy: Delete
Expand Down

0 comments on commit 5757ca6

Please sign in to comment.