Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions controllers/operator/mongodbsearch_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,18 @@ func newSearchReconciler(
}

func buildExpectedMongotConfig(search *searchv1.MongoDBSearch, mdbc *mdbcv1.MongoDBCommunity) mongot.Config {
var hostAndPorts []string
for i := range mdbc.Spec.Members {
hostAndPorts = append(hostAndPorts, fmt.Sprintf("%s-%d.%s.%s.svc.cluster.local:%d", mdbc.Name, i, mdbc.Name+"-svc", search.Namespace, 27017))
}
return mongot.Config{
SyncSource: mongot.ConfigSyncSource{
ReplicaSet: mongot.ConfigReplicaSet{
HostAndPort: fmt.Sprintf("%s.%s.svc.cluster.local:%d", mdbc.Name+"-svc", search.Namespace, 27017),
HostAndPort: hostAndPorts,
Username: "mongot-user",
PasswordFile: "/tmp/sourceUserPassword",
TLS: ptr.To(false),
ReadPreference: ptr.To("secondaryPreferred"),
ReplicaSetName: "mdb",
},
},
Storage: mongot.ConfigStorage{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,15 +208,19 @@ func buildSearchHeadlessService(search *searchv1.MongoDBSearch) corev1.Service {
}

func createMongotConfig(search *searchv1.MongoDBSearch, db SearchSourceDBResource) mongot.Config {
var hostAndPorts []string
for i := range db.Members() {
hostAndPorts = append(hostAndPorts, fmt.Sprintf("%s-%d.%s.%s.svc.cluster.local:%d", db.Name(), i, db.DatabaseServiceName(), db.GetNamespace(), db.DatabasePort()))
}

return mongot.Config{
SyncSource: mongot.ConfigSyncSource{
ReplicaSet: mongot.ConfigReplicaSet{
HostAndPort: fmt.Sprintf("%s.%s.svc.cluster.local:%d", db.DatabaseServiceName(), db.GetNamespace(), db.DatabasePort()),
HostAndPort: hostAndPorts,
Username: search.SourceUsername(),
PasswordFile: "/tmp/sourceUserPassword",
TLS: ptr.To(false),
ReadPreference: ptr.To("secondaryPreferred"),
ReplicaSetName: db.Name(),
},
},
Storage: mongot.ConfigStorage{
Expand Down
5 changes: 5 additions & 0 deletions controllers/search_controller/search_construction.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type SearchSourceDBResource interface {
DatabasePort() int
GetMongoDBVersion() string
IsSecurityTLSConfigEnabled() bool
Members() int
}

func NewSearchSourceDBResourceFromMongoDBCommunity(mdbc *mdbcv1.MongoDBCommunity) SearchSourceDBResource {
Expand All @@ -48,6 +49,10 @@ type mdbcSearchResource struct {
db *mdbcv1.MongoDBCommunity
}

func (r *mdbcSearchResource) Members() int {
return r.db.Spec.Members
}

func (r *mdbcSearchResource) Name() string {
return r.db.Name
}
Expand Down
2 changes: 1 addition & 1 deletion helm_chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -229,4 +229,4 @@ search:
repo: 268558157000.dkr.ecr.eu-west-1.amazonaws.com
name: mongot/community
# default MongoDB Search version used; can be overridden by setting MongoDBSearch.spec.version field.
version: b9b80915f5571bfa5fc2aa70acb20d784e68d79b
version: d6884ae132aab30497af55dbaff05e8274e9775f
11 changes: 5 additions & 6 deletions mongodb-community-operator/pkg/mongot/mongot_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@ type ConfigSyncSource struct {
}

type ConfigReplicaSet struct {
HostAndPort string `json:"hostAndPort"`
Username string `json:"username"`
PasswordFile string `json:"passwordFile"`
ReplicaSetName string `json:"replicaSetName"`
TLS *bool `json:"tls,omitempty"`
ReadPreference *string `json:"readPreference,omitempty"`
HostAndPort []string `json:"hostAndPort"`
Username string `json:"username"`
PasswordFile string `json:"passwordFile"`
TLS *bool `json:"tls,omitempty"`
ReadPreference *string `json:"readPreference,omitempty"`
}

type ConfigStorage struct {
Expand Down
4 changes: 2 additions & 2 deletions scripts/dev/contexts/e2e_mdb_community
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ export OM_EXTERNALLY_CONFIGURED="true"

# Temporary development images built from mongot master
#export MDB_SEARCH_COMMUNITY_VERSION="776d43523d185b6b234289e17c191712a3e6569b" # master
#export MDB_SEARCH_COMMUNITY_VERSION="d6884ae132aab30497af55dbaff05e8274e9775f" # Local->Admin
export MDB_SEARCH_COMMUNITY_VERSION="d6884ae132aab30497af55dbaff05e8274e9775f" # Local->Admin
#export MDB_SEARCH_COMMUNITY_VERSION="ad8acf5c3a045d6e0306ad67d61fcb5be40f57ae" # hardcoded mdbc-rs replicaset name
export MDB_SEARCH_COMMUNITY_VERSION="b9b80915f5571bfa5fc2aa70acb20d784e68d79b" # hardcoded Local->Admin, handled replicaSetName in config
#export MDB_SEARCH_COMMUNITY_VERSION="b9b80915f5571bfa5fc2aa70acb20d784e68d79b" # hardcoded Local->Admin, handled replicaSetName in config
export MDB_SEARCH_COMMUNITY_NAME="mongot/community"
export MDB_SEARCH_COMMUNITY_REPO_URL="268558157000.dkr.ecr.eu-west-1.amazonaws.com"