Skip to content

Commit 401a5bb

Browse files
Updated code snippets (#296)
<!-- start git-machete generated --> # Based on PR #229 ## Chain of upstream PRs as of 2025-07-28 * PR #229: `master` ← `search/public-preview` * **PR #296 (THIS ONE)**: `search/public-preview` ← `lsierant/search-snippets-update` <!-- end git-machete generated --> # Summary <!-- Enter your issue summary here.--> ## Proof of Work <!-- Enter your proof that it works here.--> ## Checklist - [ ] Have you linked a jira ticket and/or is the ticket in the title? - [ ] Have you checked whether your jira ticket required DOCSP changes? - [ ] Have you checked for release_note changes? --------- Co-authored-by: Yavor Georgiev <[email protected]> Co-authored-by: Yavor Georgiev <[email protected]>
1 parent 6e11713 commit 401a5bb

File tree

41 files changed

+441
-459
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+441
-459
lines changed

api/v1/search/mongodbsearch_types.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,31 @@ const (
1919
MongotDefaultPort = 27027
2020
MongotDefaultMetricsPort = 9946
2121
MongotDefautHealthCheckPort = 8080
22-
MongotDefaultSyncSourceUsername = "mongot-user"
22+
MongotDefaultSyncSourceUsername = "search-sync-source"
2323
)
2424

2525
func init() {
2626
v1.SchemeBuilder.Register(&MongoDBSearch{}, &MongoDBSearchList{})
2727
}
2828

2929
type MongoDBSearchSpec struct {
30+
// Optional version of MongoDB Search component (mongot). If not set, then the operator will set the most appropriate version of MongoDB Search.
3031
// +optional
3132
Version string `json:"version"`
33+
// MongoDB database connection details from which MongoDB Search will synchronize data to build indexes.
3234
// +optional
3335
Source *MongoDBSource `json:"source"`
36+
// StatefulSetSpec which the operator will apply to the MongoDB Search StatefulSet at the end of the reconcile loop. Use to provide necessary customizations,
37+
// which aren't exposed as fields in the MongoDBSearch.spec.
3438
// +optional
3539
StatefulSetConfiguration *common.StatefulSetConfiguration `json:"statefulSet,omitempty"`
40+
// Configure MongoDB Search's persistent volume. If not defined, the operator will request 10GB of storage.
3641
// +optional
3742
Persistence *common.Persistence `json:"persistence,omitempty"`
43+
// Configure resource requests and limits for the MongoDB Search pods.
3844
// +optional
3945
ResourceRequirements *corev1.ResourceRequirements `json:"resourceRequirements,omitempty"`
46+
// Configure security settings of the MongoDB Search server that MongoDB database is connecting to when performing search queries.
4047
// +optional
4148
Security Security `json:"security"`
4249
}

controllers/operator/mongodbsearch_controller_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func buildExpectedMongotConfig(search *searchv1.MongoDBSearch, mdbc *mdbcv1.Mong
9292
SyncSource: mongot.ConfigSyncSource{
9393
ReplicaSet: mongot.ConfigReplicaSet{
9494
HostAndPort: hostAndPorts,
95-
Username: "mongot-user",
95+
Username: searchv1.MongotDefaultSyncSourceUsername,
9696
PasswordFile: "/tmp/sourceUserPassword",
9797
TLS: ptr.To(false),
9898
ReadPreference: ptr.To("secondaryPreferred"),

docker/mongodb-kubernetes-init-ops-manager/mmsconfiguration/edit_mms_configuration.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ func readLinesFromFile(name string) ([]string, error) {
145145
func writeLinesToFile(name string, lines []string) error {
146146
output := strings.Join(lines, lineBreak)
147147

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

169169
func getOmPropertiesFromEnvVars() map[string]string {
170170
props := map[string]string{}
171-
for _, pair := range os.Environ() {
171+
for _, pair := range os.Environ() { // nolint:forbidigo
172172
if !strings.HasPrefix(pair, omPropertyPrefix) {
173173
continue
174174
}

docker/mongodb-kubernetes-tests/tests/search/fixtures/community-replicaset-sample-mflix.yaml

Lines changed: 38 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,59 +4,66 @@ kind: MongoDBCommunity
44
metadata:
55
name: mdbc-rs
66
spec:
7-
members: 3
7+
version: 8.0.10
88
type: ReplicaSet
9-
version: "8.0.10"
9+
members: 3
1010
security:
1111
authentication:
12-
modes: ["SCRAM-SHA-1"]
12+
ignoreUnknownUsers: true
13+
modes:
14+
- SCRAM
1315
agent:
1416
logLevel: DEBUG
17+
statefulSet:
18+
spec:
19+
template:
20+
spec:
21+
containers:
22+
- name: mongod
23+
resources:
24+
limits:
25+
cpu: "2"
26+
memory: 2Gi
27+
requests:
28+
cpu: "1"
29+
memory: 1Gi
30+
- name: mongodb-agent
31+
resources:
32+
limits:
33+
cpu: "1"
34+
memory: 2Gi
35+
requests:
36+
cpu: "0.5"
37+
memory: 1Gi
1538
users:
39+
# admin user with root role
1640
- name: mdb-admin
1741
db: admin
18-
passwordSecretRef: # a reference to the secret that will be used to generate the user's password
42+
passwordSecretRef: # a reference to the secret containing user password
1943
name: mdb-admin-user-password
44+
scramCredentialsSecretName: mdb-admin-user
2045
roles:
2146
- name: root
2247
db: admin
23-
scramCredentialsSecretName: mdb-admin-user-scram
48+
# user performing search queries
2449
- name: mdb-user
2550
db: admin
26-
passwordSecretRef: # a reference to the secret that will be used to generate the user's password
51+
passwordSecretRef: # a reference to the secret containing user password
2752
name: mdb-user-password
53+
scramCredentialsSecretName: mdb-user-scram
2854
roles:
2955
- name: restore
3056
db: sample_mflix
3157
- name: readWrite
3258
db: sample_mflix
33-
scramCredentialsSecretName: mdb-user-scram
34-
- name: mongot-user
59+
# user used by MongoDB Search to connect to MongoDB database to synchronize data from
60+
# For MongoDB <8.2, the operator will be creating the searchCoordinator custom role automatically
61+
# From MongoDB 8.2, searchCoordinator role will be a built-in role.
62+
- name: search-sync-source
3563
db: admin
3664
passwordSecretRef: # a reference to the secret that will be used to generate the user's password
37-
name: mdbc-rs-mongot-user-password
65+
name: mdbc-rs-search-sync-source-password
66+
scramCredentialsSecretName: mdbc-rs-search-sync-source
3867
roles:
3968
- name: searchCoordinator
4069
db: admin
41-
scramCredentialsSecretName: mongot-user-scram
42-
statefulSet:
43-
spec:
44-
template:
45-
spec:
46-
containers:
47-
- name: mongod
48-
resources:
49-
limits:
50-
cpu: "3"
51-
memory: 5Gi
52-
requests:
53-
cpu: "2"
54-
memory: 5Gi
55-
- name: mongodb-agent
56-
resources:
57-
limits:
58-
cpu: "3"
59-
memory: 5Gi
60-
requests:
61-
cpu: "2"
62-
memory: 5Gi

docker/mongodb-kubernetes-tests/tests/search/search_community_basic.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
ADMIN_USER_NAME = "mdb-admin-user"
1616
ADMIN_USER_PASSWORD = "mdb-admin-user-pass"
1717

18-
MONGOT_USER_NAME = "mongot-user"
19-
MONGOT_USER_PASSWORD = "mongot-user-password"
18+
MONGOT_USER_NAME = "search-sync-source"
19+
MONGOT_USER_PASSWORD = "search-sync-source-user-password"
2020

2121
USER_NAME = "mdb-user"
2222
USER_PASSWORD = "mdb-user-pass"
@@ -32,8 +32,8 @@ def mdbc(namespace: str) -> MongoDBCommunity:
3232
namespace=namespace,
3333
)
3434

35-
# if try_load(resource):
36-
# return resource
35+
if try_load(resource):
36+
return resource
3737

3838
return resource
3939

@@ -45,8 +45,8 @@ def mdbs(namespace: str) -> MongoDBSearch:
4545
namespace=namespace,
4646
)
4747

48-
# if try_load(resource):
49-
# return resource
48+
if try_load(resource):
49+
return resource
5050

5151
return resource
5252

@@ -75,7 +75,7 @@ def test_create_database_resource(mdbc: MongoDBCommunity):
7575

7676

7777
@mark.e2e_search_community_basic
78-
def test_create_search_resource(mdbs: MongoDBSearch, mdbc: MongoDBCommunity):
78+
def test_create_search_resource(mdbs: MongoDBSearch):
7979
mdbs.update()
8080
mdbs.assert_reaches_phase(Phase.Running, timeout=300)
8181

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

104104

105-
# @mark.e2e_search_community_basic
106-
# def test_search_wait_for_search_indexes(sample_movies_helper: SampleMoviesSearchHelper):
107-
# sample_movies_helper.wait_for_search_indexes()
108-
109-
110105
@mark.e2e_search_community_basic
111106
def test_search_assert_search_query(sample_movies_helper: SampleMoviesSearchHelper):
112107
sample_movies_helper.assert_search_query(retry_timeout=60)

docker/mongodb-kubernetes-tests/tests/search/search_community_tls.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
ADMIN_USER_NAME = "mdb-admin-user"
1818
ADMIN_USER_PASSWORD = "mdb-admin-user-pass"
1919

20-
MONGOT_USER_NAME = "mongot-user"
21-
MONGOT_USER_PASSWORD = "mongot-user-password"
20+
MONGOT_USER_NAME = "search-sync-source"
21+
MONGOT_USER_PASSWORD = "search-sync-source-user-password"
2222

2323
USER_NAME = "mdb-user"
2424
USER_PASSWORD = "mdb-user-pass"

0 commit comments

Comments
 (0)