Skip to content

Updated code snippets #296

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

Merged
merged 11 commits into from
Jul 29, 2025
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
9 changes: 8 additions & 1 deletion api/v1/search/mongodbsearch_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,31 @@ const (
MongotDefaultPort = 27027
MongotDefaultMetricsPort = 9946
MongotDefautHealthCheckPort = 8080
MongotDefaultSyncSourceUsername = "mongot-user"
MongotDefaultSyncSourceUsername = "search-sync-source"
)

func init() {
v1.SchemeBuilder.Register(&MongoDBSearch{}, &MongoDBSearchList{})
}

type MongoDBSearchSpec struct {
// Optional version of MongoDB Search component (mongot). If not set, then the operator will set the most appropriate version of MongoDB Search.
// +optional
Version string `json:"version"`
// MongoDB database connection details from which MongoDB Search will synchronize data to build indexes.
// +optional
Source *MongoDBSource `json:"source"`
// StatefulSetSpec which the operator will apply to the MongoDB Search StatefulSet at the end of the reconcile loop. Use to provide necessary customizations,
// which aren't exposed as fields in the MongoDBSearch.spec.
// +optional
StatefulSetConfiguration *common.StatefulSetConfiguration `json:"statefulSet,omitempty"`
// Configure MongoDB Search's persistent volume. If not defined, the operator will request 10GB of storage.
// +optional
Persistence *common.Persistence `json:"persistence,omitempty"`
// Configure resource requests and limits for the MongoDB Search pods.
// +optional
ResourceRequirements *corev1.ResourceRequirements `json:"resourceRequirements,omitempty"`
// Configure security settings of the MongoDB Search server that MongoDB database is connecting to when performing search queries.
// +optional
Security Security `json:"security"`
}
Expand Down
2 changes: 1 addition & 1 deletion controllers/operator/mongodbsearch_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func buildExpectedMongotConfig(search *searchv1.MongoDBSearch, mdbc *mdbcv1.Mong
SyncSource: mongot.ConfigSyncSource{
ReplicaSet: mongot.ConfigReplicaSet{
HostAndPort: hostAndPorts,
Username: "mongot-user",
Username: searchv1.MongotDefaultSyncSourceUsername,
PasswordFile: "/tmp/sourceUserPassword",
TLS: ptr.To(false),
ReadPreference: ptr.To("secondaryPreferred"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func readLinesFromFile(name string) ([]string, error) {
func writeLinesToFile(name string, lines []string) error {
output := strings.Join(lines, lineBreak)

err := os.WriteFile(name, []byte(output), 0o775)
err := os.WriteFile(name, []byte(output), 0o644)
if err != nil {
return xerrors.Errorf("error writing to file %s: %w", name, err)
}
Expand All @@ -168,7 +168,7 @@ func appendLinesToFile(name string, lines string) error {

func getOmPropertiesFromEnvVars() map[string]string {
props := map[string]string{}
for _, pair := range os.Environ() {
for _, pair := range os.Environ() { // nolint:forbidigo
if !strings.HasPrefix(pair, omPropertyPrefix) {
continue
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,59 +4,66 @@ kind: MongoDBCommunity
metadata:
name: mdbc-rs
spec:
members: 3
version: 8.0.10
type: ReplicaSet
version: "8.0.10"
members: 3
security:
authentication:
modes: ["SCRAM-SHA-1"]
ignoreUnknownUsers: true
modes:
- SCRAM
agent:
logLevel: DEBUG
statefulSet:
spec:
template:
spec:
containers:
- name: mongod
resources:
limits:
cpu: "2"
memory: 2Gi
requests:
cpu: "1"
memory: 1Gi
- name: mongodb-agent
resources:
limits:
cpu: "1"
memory: 2Gi
requests:
cpu: "0.5"
memory: 1Gi
users:
# admin user with root role
- name: mdb-admin
db: admin
passwordSecretRef: # a reference to the secret that will be used to generate the user's password
passwordSecretRef: # a reference to the secret containing user password
name: mdb-admin-user-password
scramCredentialsSecretName: mdb-admin-user
roles:
- name: root
db: admin
scramCredentialsSecretName: mdb-admin-user-scram
# user performing search queries
- name: mdb-user
db: admin
passwordSecretRef: # a reference to the secret that will be used to generate the user's password
passwordSecretRef: # a reference to the secret containing user password
name: mdb-user-password
scramCredentialsSecretName: mdb-user-scram
roles:
- name: restore
db: sample_mflix
- name: readWrite
db: sample_mflix
scramCredentialsSecretName: mdb-user-scram
- name: mongot-user
# user used by MongoDB Search to connect to MongoDB database to synchronize data from
# For MongoDB <8.2, the operator will be creating the searchCoordinator custom role automatically
# From MongoDB 8.2, searchCoordinator role will be a built-in role.
- name: search-sync-source
db: admin
passwordSecretRef: # a reference to the secret that will be used to generate the user's password
name: mdbc-rs-mongot-user-password
name: mdbc-rs-search-sync-source-password
scramCredentialsSecretName: mdbc-rs-search-sync-source
roles:
- name: searchCoordinator
db: admin
scramCredentialsSecretName: mongot-user-scram
statefulSet:
spec:
template:
spec:
containers:
- name: mongod
resources:
limits:
cpu: "3"
memory: 5Gi
requests:
cpu: "2"
memory: 5Gi
- name: mongodb-agent
resources:
limits:
cpu: "3"
memory: 5Gi
requests:
cpu: "2"
memory: 5Gi
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
ADMIN_USER_NAME = "mdb-admin-user"
ADMIN_USER_PASSWORD = "mdb-admin-user-pass"

MONGOT_USER_NAME = "mongot-user"
MONGOT_USER_PASSWORD = "mongot-user-password"
MONGOT_USER_NAME = "search-sync-source"
MONGOT_USER_PASSWORD = "search-sync-source-user-password"

USER_NAME = "mdb-user"
USER_PASSWORD = "mdb-user-pass"
Expand All @@ -32,8 +32,8 @@ def mdbc(namespace: str) -> MongoDBCommunity:
namespace=namespace,
)

# if try_load(resource):
# return resource
if try_load(resource):
return resource

return resource

Expand All @@ -45,8 +45,8 @@ def mdbs(namespace: str) -> MongoDBSearch:
namespace=namespace,
)

# if try_load(resource):
# return resource
if try_load(resource):
return resource

return resource

Expand Down Expand Up @@ -75,7 +75,7 @@ def test_create_database_resource(mdbc: MongoDBCommunity):


@mark.e2e_search_community_basic
def test_create_search_resource(mdbs: MongoDBSearch, mdbc: MongoDBCommunity):
def test_create_search_resource(mdbs: MongoDBSearch):
mdbs.update()
mdbs.assert_reaches_phase(Phase.Running, timeout=300)

Expand All @@ -102,11 +102,6 @@ def test_search_create_search_index(sample_movies_helper: SampleMoviesSearchHelp
sample_movies_helper.create_search_index()


# @mark.e2e_search_community_basic
# def test_search_wait_for_search_indexes(sample_movies_helper: SampleMoviesSearchHelper):
# sample_movies_helper.wait_for_search_indexes()


@mark.e2e_search_community_basic
def test_search_assert_search_query(sample_movies_helper: SampleMoviesSearchHelper):
sample_movies_helper.assert_search_query(retry_timeout=60)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
ADMIN_USER_NAME = "mdb-admin-user"
ADMIN_USER_PASSWORD = "mdb-admin-user-pass"

MONGOT_USER_NAME = "mongot-user"
MONGOT_USER_PASSWORD = "mongot-user-password"
MONGOT_USER_NAME = "search-sync-source"
MONGOT_USER_PASSWORD = "search-sync-source-user-password"

USER_NAME = "mdb-user"
USER_PASSWORD = "mdb-user-pass"
Expand Down
Loading