Skip to content

Commit cd4580e

Browse files
committed
cr: improve custom replset name configuration impl
1 parent 7aef96c commit cd4580e

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

pkg/psmdb/container.go

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -227,25 +227,19 @@ func containerArgs(ctx context.Context, cr *api.PerconaServerMongoDB, replset *a
227227
args = append(args, "--auth")
228228
}
229229

230+
replSetName := replset.Name
231+
if name, err := replset.CustomReplsetName(); err == nil {
232+
replSetName = name
233+
}
234+
230235
args = append(args,
231236
"--dbpath="+config.MongodContainerDataDir,
232237
"--port="+strconv.Itoa(int(replset.GetPort())),
233-
"--replSet="+replset.Name,
238+
"--replSet="+replSetName,
234239
"--storageEngine="+string(replset.Storage.Engine),
235240
"--relaxPermChecks",
236241
)
237242

238-
name, err := replset.CustomReplsetName()
239-
if err == nil {
240-
// given that --auth option is optional, we cannot rely on the fixed hardcoded index.
241-
for i, arg := range args {
242-
if len(arg) >= 9 && arg[:9] == "--replSet" {
243-
args[i] = "--replSet=" + name
244-
break
245-
}
246-
}
247-
}
248-
249243
if *cr.Spec.TLS.AllowInvalidCertificates || cr.CompareVersion("1.16.0") < 0 {
250244
args = append(args, "--sslAllowInvalidCertificates")
251245
}

0 commit comments

Comments
 (0)