Skip to content

Handle new mongot config schema #230

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: search/public-preview
Choose a base branch
from
Draft
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
4 changes: 2 additions & 2 deletions config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -392,9 +392,9 @@ spec:
- name: RELATED_IMAGE_MONGODB_IMAGE_8_0_0_ubi9
value: "quay.io/mongodb/mongodb-enterprise-server:8.0.0-ubi9"
- name: RELATED_IMAGE_MDB_SEARCH_IMAGE_1_47_0
value: "quay.io/mongodb/mongodb-search-community:1.47.0"
value: "268558157000.dkr.ecr.us-east-1.amazonaws.com/dev/mongodb-search-community:1.47.0"
- name: MDB_SEARCH_COMMUNITY_REPO_URL
value: "quay.io/mongodb"
value: "268558157000.dkr.ecr.us-east-1.amazonaws.com/dev"
- name: MDB_SEARCH_COMMUNITY_NAME
value: "mongodb-search-community"
- name: MDB_SEARCH_COMMUNITY_VERSION
Expand Down
39 changes: 31 additions & 8 deletions controllers/search_controller/mongodbsearch_reconcile_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,19 +207,42 @@ func buildSearchHeadlessService(search *searchv1.MongoDBSearch) corev1.Service {
}

func createMongotConfig(search *searchv1.MongoDBSearch, db SearchSourceDBResource) mongot.Config {
return mongot.Config{CommunityPrivatePreview: mongot.CommunityPrivatePreview{
MongodHostAndPort: fmt.Sprintf("%s.%s.svc.cluster.local:%d", db.DatabaseServiceName(), db.GetNamespace(), db.DatabasePort()),
QueryServerAddress: fmt.Sprintf("localhost:%d", search.GetMongotPort()),
KeyFilePath: "/mongot/keyfile/keyfile",
DataPath: "/mongot/data/config.yml",
Metrics: mongot.Metrics{
return mongot.Config{
SyncSource: mongot.ConfigSyncSource{
ReplicaSet: mongot.ConfigReplicaSet{
HostAndPort: fmt.Sprintf("%s.%s.svc.cluster.local:%d", db.DatabaseServiceName(), db.GetNamespace(), db.DatabasePort()),
Username: "__system",
PasswordFile: "/tmp/keyfile",
TLS: false,
// TODO check
ReadPreference: "secondaryPreferred",
},
},
Storage: mongot.ConfigStorage{
DataPath: "/mongot/data/config.yml",
},
Server: mongot.ConfigServer{
Wireproto: mongot.ConfigWireproto{
Address: "0.0.0.0:27027",
Authentication: mongot.ConfigAuthentication{
Mode: "keyfile",
KeyFile: "/tmp/keyfile",
},
TLS: mongot.ConfigTLS{Mode: "disabled"},
},
},
Metrics: mongot.ConfigMetrics{
Enabled: true,
Address: fmt.Sprintf("localhost:%d", search.GetMongotMetricsPort()),
},
Logging: mongot.Logging{
HealthCheck: mongot.ConfigHealthCheck{
Address: "0.0.0.0:8080",
},
Logging: mongot.ConfigLogging{
Verbosity: "DEBUG",
LogPath: nil,
},
}}
}
}

func GetMongodConfigParameters(search *searchv1.MongoDBSearch) map[string]interface{} {
Expand Down
7 changes: 6 additions & 1 deletion controllers/search_controller/search_construction.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,12 @@ func mongodbSearchContainer(mdbSearch *searchv1.MongoDBSearch, volumeMounts []co
container.WithCommand([]string{"sh"}),
container.WithArgs([]string{
"-c",
"/mongot-community/mongot --config /mongot/config/config.yml",
`
cp /mongot/keyfile/keyfile /tmp/keyfile
chown 2000:2000 /tmp/keyfile
chmod 0600 /tmp/keyfile
/mongot-community/mongot --config /mongot/config/config.yml
`,
}),
containerSecurityContext,
)
Expand Down
6 changes: 5 additions & 1 deletion helm_chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,11 @@ community:
search:
community:
# Full Search container image url used for the MongoDB Community Search container will be constructed as {search.community.repo}/{search.community.name}:{search.community.version}
repo: quay.io/mongodb
# repo: quay.io/mongodb
# name: mongodb-search-community
# # default MongoDB Search version used; can be overridden by setting MongoDBSearch.spec.version field.
# version: 1.47.0
repo: 268558157000.dkr.ecr.us-east-1.amazonaws.com/dev
name: mongodb-search-community
# default MongoDB Search version used; can be overridden by setting MongoDBSearch.spec.version field.
version: 1.47.0
66 changes: 42 additions & 24 deletions mongodb-community-operator/pkg/mongot/mongot_config.go
Original file line number Diff line number Diff line change
@@ -1,41 +1,59 @@
package mongot

type Config struct {
CommunityPrivatePreview CommunityPrivatePreview `json:"communityPrivatePreview"`
SyncSource ConfigSyncSource `json:"syncSource"`
Storage ConfigStorage `json:"storage"`
Server ConfigServer `json:"server"`
Metrics ConfigMetrics `json:"metrics"`
HealthCheck ConfigHealthCheck `json:"healthCheck"`
Logging ConfigLogging `json:"logging"`
}

// CommunityPrivatePreview structure reflects private preview configuration from mongot:
// https://github.com/10gen/mongot/blob/060ec179af062ac2639678f4a613b8ab02c21597/src/main/java/com/xgen/mongot/config/provider/community/CommunityConfig.java#L100
// Comments are from the default config file: https://github.com/10gen/mongot/blob/375379e56a580916695a2f53e12fd4a99aa24f0b/deploy/community-resources/config.default.yml#L1-L0
type CommunityPrivatePreview struct {
// Socket (IPv4/6) address of the sync source mongod
MongodHostAndPort string `json:"mongodHostAndPort"`

// Socket (IPv4/6) address on which to listen for wire protocol connections
QueryServerAddress string `json:"queryServerAddress"`
type ConfigSyncSource struct {
ReplicaSet ConfigReplicaSet `json:"replicaSet"`
}

// Keyfile used for mongod -> mongot authentication
KeyFilePath string `json:"keyFilePath"`
type ConfigReplicaSet struct {
HostAndPort string `json:"hostAndPort"`
Username string `json:"username"`
PasswordFile string `json:"passwordFile"`
TLS bool `json:"tls"`
ReadPreference string `json:"readPreference"`
}

// Filesystem path that all mongot data will be stored at
type ConfigStorage struct {
DataPath string `json:"dataPath"`
}

// Options for metrics
Metrics Metrics `json:"metrics,omitempty"`
type ConfigServer struct {
Wireproto ConfigWireproto `json:"wireproto"`
}

// Options for logging
Logging Logging `json:"logging,omitempty"`
type ConfigWireproto struct {
Address string `json:"address"`
Authentication ConfigAuthentication `json:"authentication"`
TLS ConfigTLS `json:"tls"`
}

type Metrics struct {
// Whether to enable the Prometheus metrics endpoint
Enabled bool `json:"enabled"`
type ConfigAuthentication struct {
Mode string `json:"mode"`
KeyFile string `json:"keyFile"`
}

type ConfigTLS struct {
Mode string `json:"mode"`
}

type ConfigMetrics struct {
Enabled bool `json:"enabled"`
Address string `json:"address"`
}

// Socket address (IPv4/6) on which the Prometheus /metrics endpoint will be exposed
type ConfigHealthCheck struct {
Address string `json:"address"`
}

type Logging struct {
// Log level
Verbosity string `json:"verbosity"`
type ConfigLogging struct {
Verbosity string `json:"verbosity"`
LogPath *string `json:"logPath,omitempty"`
}
2 changes: 1 addition & 1 deletion public/mongodb-kubernetes-multi-cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ spec:
value: "ubi8"
# Community Env Vars End
- name: MDB_SEARCH_COMMUNITY_REPO_URL
value: "quay.io/mongodb"
value: "268558157000.dkr.ecr.us-east-1.amazonaws.com/dev"
- name: MDB_SEARCH_COMMUNITY_NAME
value: "mongodb-search-community"
- name: MDB_SEARCH_COMMUNITY_VERSION
Expand Down
4 changes: 2 additions & 2 deletions public/mongodb-kubernetes-openshift.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -674,9 +674,9 @@ spec:
- name: RELATED_IMAGE_MONGODB_IMAGE_8_0_0_ubi9
value: "quay.io/mongodb/mongodb-enterprise-server:8.0.0-ubi9"
- name: RELATED_IMAGE_MDB_SEARCH_IMAGE_1_47_0
value: "quay.io/mongodb/mongodb-search-community:1.47.0"
value: "268558157000.dkr.ecr.us-east-1.amazonaws.com/dev/mongodb-search-community:1.47.0"
- name: MDB_SEARCH_COMMUNITY_REPO_URL
value: "quay.io/mongodb"
value: "268558157000.dkr.ecr.us-east-1.amazonaws.com/dev"
- name: MDB_SEARCH_COMMUNITY_NAME
value: "mongodb-search-community"
- name: MDB_SEARCH_COMMUNITY_VERSION
Expand Down
2 changes: 1 addition & 1 deletion public/mongodb-kubernetes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ spec:
value: "ubi8"
# Community Env Vars End
- name: MDB_SEARCH_COMMUNITY_REPO_URL
value: "quay.io/mongodb"
value: "268558157000.dkr.ecr.us-east-1.amazonaws.com/dev"
- name: MDB_SEARCH_COMMUNITY_NAME
value: "mongodb-search-community"
- name: MDB_SEARCH_COMMUNITY_VERSION
Expand Down
5 changes: 5 additions & 0 deletions scripts/dev/contexts/e2e_mdb_community
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,8 @@ source "${script_dir}/variables/mongodb_latest"

# This variable is needed otherwise the `fetch_om_information.sh` script is called and fails the test
export OM_EXTERNALLY_CONFIGURED="true"

# Temporary development images built from mongot master
export MDB_SEARCH_COMMUNITY_VERSION="776d43523d185b6b234289e17c191712a3e6569b"
export MDB_SEARCH_COMMUNITY_NAME="mongot/community"
export MDB_SEARCH_COMMUNITY_REPO_URL="268558157000.dkr.ecr.eu-west-1.amazonaws.com"