Skip to content

Commit

Permalink
use mixcoord & enable active standby & enable rolling update by defau…
Browse files Browse the repository at this point in the history
…lt (#151)

* default: use mixcoord by default for new cluster

Signed-off-by: haorenfsa <[email protected]>

* enable active standby & rolling update by default

Signed-off-by: haorenfsa <[email protected]>

* Remove pulsar image in sit to save disk space

Signed-off-by: haorenfsa <[email protected]>

---------

Signed-off-by: haorenfsa <[email protected]>
  • Loading branch information
haorenfsa authored Jul 19, 2024
1 parent 9fa8cc5 commit 05736a5
Show file tree
Hide file tree
Showing 11 changed files with 101 additions and 90 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ sit-prepare-images: sit-prepare-operator-images
@echo "Preparing images"
docker pull milvusdb/milvus:v2.4.6

docker pull -q apachepulsar/pulsar:2.8.2
# docker pull -q apachepulsar/pulsar:2.8.2
docker pull -q bitnami/kafka:3.1.0-debian-10-r52
docker pull -q milvusdb/etcd:3.5.5-r4
docker pull -q minio/minio:RELEASE.2023-03-20T20-16-18Z
Expand All @@ -250,7 +250,7 @@ sit-load-operator-images:
sit-load-images: sit-load-operator-images
@echo "Loading images"
kind load docker-image milvusdb/milvus:v2.4.6
kind load docker-image apachepulsar/pulsar:2.8.2 --name ${KIND_CLUSTER}
# kind load docker-image apachepulsar/pulsar:2.8.2 --name ${KIND_CLUSTER}
kind load docker-image bitnami/kafka:3.1.0-debian-10-r52 --name ${KIND_CLUSTER}
kind load docker-image milvusdb/etcd:3.5.5-r4 --name ${KIND_CLUSTER}
kind load docker-image minio/minio:RELEASE.2023-03-20T20-16-18Z --name ${KIND_CLUSTER}
Expand All @@ -259,7 +259,7 @@ sit-load-images: sit-load-operator-images
sit-load-and-cleanup-images: sit-load-images
@echo "Clean up some big images to save disk space in github action"
docker rmi milvusdb/milvus:v2.4.6
docker rmi apachepulsar/pulsar:2.8.2
# docker rmi apachepulsar/pulsar:2.8.2
docker rmi bitnami/kafka:3.1.0-debian-10-r52
docker rmi milvusdb/etcd:3.5.5-r4
docker rmi minio/minio:RELEASE.2023-03-20T20-16-18Z
Expand Down
1 change: 1 addition & 0 deletions apis/milvus.io/v1beta1/milvus_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ func TestMilvusSpec_IsStopping(t *testing.T) {
})

com.MixCoord = nil
com.RootCoord = &MilvusRootCoord{}
m.Default()
t.Run("cluster not stopping", func(t *testing.T) {
assert.False(t, m.Spec.IsStopping())
Expand Down
80 changes: 42 additions & 38 deletions apis/milvus.io/v1beta1/milvus_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,13 @@ func (r *Milvus) DefaultMode() {
}
}

func (r *Milvus) noCoordSpecifiedByUser() bool {
return r.Spec.Com.RootCoord == nil &&
r.Spec.Com.DataCoord == nil &&
r.Spec.Com.IndexCoord == nil &&
r.Spec.Com.QueryCoord == nil
}

func (r *Milvus) DefaultComponents() {
spec := &r.Spec
setDefaultStr(&spec.Com.Image, config.DefaultMilvusImage)
Expand All @@ -257,17 +264,22 @@ func (r *Milvus) DefaultComponents() {
spec.Com.Proxy = &MilvusProxy{}
}
if spec.Com.MixCoord == nil {
if spec.Com.RootCoord == nil {
spec.Com.RootCoord = &MilvusRootCoord{}
}
if spec.Com.DataCoord == nil {
spec.Com.DataCoord = &MilvusDataCoord{}
}
if spec.Com.IndexCoord == nil {
spec.Com.IndexCoord = &MilvusIndexCoord{}
}
if spec.Com.QueryCoord == nil {
spec.Com.QueryCoord = &MilvusQueryCoord{}
if r.noCoordSpecifiedByUser() {
// default to use mixcoord
spec.Com.MixCoord = &MilvusMixCoord{}
} else {
if spec.Com.RootCoord == nil {
spec.Com.RootCoord = &MilvusRootCoord{}
}
if spec.Com.DataCoord == nil {
spec.Com.DataCoord = &MilvusDataCoord{}
}
if spec.Com.IndexCoord == nil {
spec.Com.IndexCoord = &MilvusIndexCoord{}
}
if spec.Com.QueryCoord == nil {
spec.Com.QueryCoord = &MilvusQueryCoord{}
}
}
}
if spec.Com.DataNode == nil {
Expand Down Expand Up @@ -296,9 +308,6 @@ func (r *Milvus) defaultComponentsReplicas() {
spec.Com.MixCoord.Replicas = &defaultReplicas
}
} else {
if spec.Com.Proxy.Replicas == nil {
spec.Com.Proxy.Replicas = &defaultReplicas
}
if spec.Com.RootCoord.Replicas == nil {
spec.Com.RootCoord.Replicas = &defaultReplicas
}
Expand All @@ -311,15 +320,18 @@ func (r *Milvus) defaultComponentsReplicas() {
if spec.Com.QueryCoord.Replicas == nil {
spec.Com.QueryCoord.Replicas = &defaultReplicas
}
if spec.Com.DataNode.Replicas == nil {
spec.Com.DataNode.Replicas = &defaultReplicas
}
if spec.Com.IndexNode.Replicas == nil {
spec.Com.IndexNode.Replicas = &defaultReplicas
}
if spec.Com.QueryNode.Replicas == nil {
spec.Com.QueryNode.Replicas = &defaultReplicas
}
}
if spec.Com.Proxy.Replicas == nil {
spec.Com.Proxy.Replicas = &defaultReplicas
}
if spec.Com.DataNode.Replicas == nil {
spec.Com.DataNode.Replicas = &defaultReplicas
}
if spec.Com.IndexNode.Replicas == nil {
spec.Com.IndexNode.Replicas = &defaultReplicas
}
if spec.Com.QueryNode.Replicas == nil {
spec.Com.QueryNode.Replicas = &defaultReplicas
}
} else {
if spec.Com.Standalone.Replicas == nil {
Expand Down Expand Up @@ -470,14 +482,12 @@ func (r *Milvus) DefaultConf() {
}

if r.Spec.Com.EnableRollingUpdate == nil {
if r.isRollingUpdateEnabledByConfig() {
r.Spec.Com.EnableRollingUpdate = util.BoolPtr(true)
}
r.Spec.Com.EnableRollingUpdate = util.BoolPtr(true)
}
if r.Spec.Com.EnableRollingUpdate != nil &&
*r.Spec.Com.EnableRollingUpdate {
r.setRollingUpdate(true)
if !r.isRollingUpdateSupportedByConfig() {
r.Spec.Com.EnableRollingUpdate = util.BoolPtr(false)
}
setEnableActiveStandby(&r.Spec, true)
}

var rollingUpdateConfigFields = []string{
Expand All @@ -490,24 +500,18 @@ var rollingUpdateConfigFields = []string{
// EnableActiveStandByConfig is a config in coordinators to determine whether a coordinator can be rolling updated
const EnableActiveStandByConfig = "enableActiveStandby"

func (r *Milvus) isRollingUpdateEnabledByConfig() bool {
func (r *Milvus) isRollingUpdateSupportedByConfig() bool {
if r.Spec.Mode != MilvusModeCluster {
switch r.Spec.Dep.MsgStreamType {
case MsgStreamTypeRocksMQ, MsgStreamTypeNatsMQ:
return false
}
}
for _, configFieldName := range rollingUpdateConfigFields {
enableActiveStandBy, _ := util.GetBoolValue(r.Spec.Conf.Data, configFieldName, EnableActiveStandByConfig)
if !enableActiveStandBy {
return false
}
}
return true
}

func (r *Milvus) setRollingUpdate(enabled bool) {
func setEnableActiveStandby(spec *MilvusSpec, enabled bool) {
for _, configFieldName := range rollingUpdateConfigFields {
util.SetValue(r.Spec.Conf.Data, enabled, configFieldName, EnableActiveStandByConfig)
util.SetValue(spec.Conf.Data, enabled, configFieldName, EnableActiveStandByConfig)
}
}
38 changes: 11 additions & 27 deletions apis/milvus.io/v1beta1/milvus_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,14 @@ func TestMilvus_Default_NotExternal(t *testing.T) {
Component: defaultComponent,
},
},
RollingMode: RollingModeV2,
EnableRollingUpdate: util.BoolPtr(false),
RollingMode: RollingModeV2,
},
Conf: Values{
Data: map[string]interface{}{},
},
}
setEnableActiveStandby(&standaloneDefault, true)

t.Run("standalone not external ok", func(t *testing.T) {
mc := Milvus{ObjectMeta: metav1.ObjectMeta{Name: crName}}
Expand Down Expand Up @@ -105,16 +107,8 @@ func TestMilvus_Default_NotExternal(t *testing.T) {
Component: defaultComponent,
},
},
RootCoord: &MilvusRootCoord{
Component: defaultComponent,
},
DataCoord: &MilvusDataCoord{
Component: defaultComponent,
},
IndexCoord: &MilvusIndexCoord{
Component: defaultComponent,
},
QueryCoord: &MilvusQueryCoord{
EnableRollingUpdate: util.BoolPtr(true),
MixCoord: &MilvusMixCoord{
Component: defaultComponent,
},
DataNode: &MilvusDataNode{
Expand All @@ -132,7 +126,7 @@ func TestMilvus_Default_NotExternal(t *testing.T) {
},
},
}
t.Run("cluster not external ok", func(t *testing.T) {
t.Run("cluster not external dep ok", func(t *testing.T) {
mc := Milvus{ObjectMeta: metav1.ObjectMeta{Name: crName}}
mc.Spec.Mode = MilvusModeCluster
mc.Default()
Expand Down Expand Up @@ -216,7 +210,7 @@ func TestMilvus_Default_DeleteUnSetableOK(t *testing.T) {
},
}
mc.Default()
assert.Equal(t, conf, mc.Spec.Conf)
assert.Equal(t, conf.Data["minio"], mc.Spec.Conf.Data["minio"])
}

func TestMilvus_ValidateCreate_NoError(t *testing.T) {
Expand Down Expand Up @@ -297,17 +291,8 @@ func Test_DefaultLabels_Legacy(t *testing.T) {
}

func Test_DefaultConf_EnableRollingUpdate(t *testing.T) {

t.Run("default nil", func(t *testing.T) {
m := Milvus{}
m.DefaultConf()
assert.Nil(t, m.Spec.Com.EnableRollingUpdate)
})

t.Run("enable by config", func(t *testing.T) {
t.Run("default enable", func(t *testing.T) {
m := Milvus{}
m.Spec.Conf.Data = map[string]interface{}{}
m.setRollingUpdate(true)
m.DefaultConf()
assert.True(t, *m.Spec.Com.EnableRollingUpdate)
})
Expand All @@ -316,24 +301,23 @@ func Test_DefaultConf_EnableRollingUpdate(t *testing.T) {
m := Milvus{}
m.Spec.Com.EnableRollingUpdate = util.BoolPtr(true)
m.DefaultConf()
assert.True(t, m.isRollingUpdateEnabledByConfig())
assert.True(t, *m.Spec.Com.EnableRollingUpdate)
})

t.Run("set false", func(t *testing.T) {
m := Milvus{}
m.Spec.Com.EnableRollingUpdate = util.BoolPtr(false)
m.DefaultConf()
assert.False(t, m.isRollingUpdateEnabledByConfig())
assert.False(t, *m.Spec.Com.EnableRollingUpdate)
})

t.Run("rocksmq false", func(t *testing.T) {
m := Milvus{}
m.DefaultConf()
m.setRollingUpdate(true)
m.Spec.Com.EnableRollingUpdate = util.BoolPtr(true)
m.Spec.Dep.MsgStreamType = MsgStreamTypeRocksMQ
m.DefaultConf()
assert.False(t, m.isRollingUpdateEnabledByConfig())
assert.False(t, *m.Spec.Com.EnableRollingUpdate)
})
}

Expand Down
16 changes: 16 additions & 0 deletions config/samples/milvus_cluster_4coords.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# This is a sample to deploy a milvus cluster using
# rootCoord, indexCoord, dataCoord and queryCoord instead of mixCoord.

apiVersion: milvus.io/v1beta1
kind: Milvus
metadata:
name: my-release
labels:
app: milvus
spec:
mode: cluster
dependencies: {}
components:
rootCoord:
replicas: 1
config: {}
1 change: 1 addition & 0 deletions config/samples/milvus_cluster_mixcoord.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ spec:
mode: cluster
dependencies: {}
components:
# now mixCoord is used by default
# mixCoord deploys all coordinators in one 'mixture' deployment
mixCoord:
replicas: 1
Expand Down
1 change: 1 addition & 0 deletions pkg/controllers/component_condition_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ func TestComponentConditionGetter_GetMilvusInstanceCondition(t *testing.T) {
})

milvus.Spec.Mode = v1beta1.MilvusModeCluster
milvus.Spec.Com.RootCoord = &v1beta1.MilvusRootCoord{}
milvus.Default()
t.Run(("cluster all ok"), func(t *testing.T) {
mockClient.EXPECT().List(gomock.Any(), gomock.Any(), gomock.Any()).
Expand Down
2 changes: 2 additions & 0 deletions pkg/controllers/components_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,7 @@ func TestMilvusComponent_GetDependencies(t *testing.T) {
m := v1beta1.Milvus{}
m.Spec.Mode = v1beta1.MilvusModeCluster
m.Spec.Com.Image = "milvusdb/milvus:v2.3.0"
m.Spec.Com.RootCoord = &v1beta1.MilvusRootCoord{}
m.Default()
assert.Len(t, IndexNode.GetDependencies(m.Spec), 0)
assert.Equal(t, IndexNode, RootCoord.GetDependencies(m.Spec)[0])
Expand All @@ -597,6 +598,7 @@ func TestMilvusComponent_GetDependencies(t *testing.T) {
t.Run("clusterModeDowngrade", func(t *testing.T) {
m := v1beta1.Milvus{}
m.Spec.Com.Image = "milvusdb/milvus:2.3.0"
m.Spec.Com.RootCoord = &v1beta1.MilvusRootCoord{}
m.Spec.Mode = v1beta1.MilvusModeCluster
m.Spec.Com.ImageUpdateMode = v1beta1.ImageUpdateModeRollingDowngrade
m.Default()
Expand Down
Loading

0 comments on commit 05736a5

Please sign in to comment.