diff --git a/apis/milvus.io/v1beta1/milvus_webhook.go b/apis/milvus.io/v1beta1/milvus_webhook.go index 9859b4a2..adf2c8a0 100644 --- a/apis/milvus.io/v1beta1/milvus_webhook.go +++ b/apis/milvus.io/v1beta1/milvus_webhook.go @@ -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 { diff --git a/pkg/util/util.go b/pkg/util/util.go index ccb01f53..ed028abd 100644 --- a/pkg/util/util.go +++ b/pkg/util/util.go @@ -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 { diff --git a/test/min-milvus-feature.yaml b/test/min-milvus-feature.yaml index 5c8e835c..6f9ac451 100644 --- a/test/min-milvus-feature.yaml +++ b/test/min-milvus-feature.yaml @@ -65,7 +65,7 @@ spec: deletionPolicy: Delete pvcDeletion: true values: - replicaCount: 1 + replicaCount: 3 storage: inCluster: deletionPolicy: Delete