diff --git a/bcs-common/pkg/odm/drivers/mongo/mongo.go b/bcs-common/pkg/odm/drivers/mongo/mongo.go index 85db5e5e0b..a84055c0a1 100644 --- a/bcs-common/pkg/odm/drivers/mongo/mongo.go +++ b/bcs-common/pkg/odm/drivers/mongo/mongo.go @@ -40,6 +40,7 @@ type Options struct { MaxPoolSize uint64 MinPoolSize uint64 Hosts []string + Replicaset string Monitor *event.CommandMonitor } @@ -67,6 +68,9 @@ func NewDB(opt *Options) (*DB, error) { Hosts: opt.Hosts, Monitor: opt.Monitor, } + if opt.Replicaset != "" { + mCliOpt.ReplicaSet = &opt.Replicaset + } if opt.MaxPoolSize != 0 { mCliOpt.MaxPoolSize = &opt.MaxPoolSize }