Skip to content

Commit

Permalink
remove authArgs from probes cmd
Browse files Browse the repository at this point in the history
Signed-off-by: sayedppqq <[email protected]>
  • Loading branch information
sayedppqq committed Nov 13, 2024
1 parent 9d9ab0b commit 8163d17
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions apis/kubedb/v1/mongodb_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -900,7 +900,7 @@ func (m *MongoDB) GetEntryCommand(mgVersion *v1alpha1.MongoDBVersion) string {
return "mongo"
}

func (m *MongoDB) getCmdForProbes(mgVersion *v1alpha1.MongoDBVersion, isArbiter ...bool) []string {
func (m *MongoDB) getCmdForProbes(mgVersion *v1alpha1.MongoDBVersion) []string {
var sslArgs string
if m.Spec.SSLMode == SSLModeRequireSSL {
sslArgs = fmt.Sprintf("--tls --tlsCAFile=%v/%v --tlsCertificateKeyFile=%v/%v",
Expand All @@ -919,25 +919,21 @@ func (m *MongoDB) getCmdForProbes(mgVersion *v1alpha1.MongoDBVersion, isArbiter
}
}

var authArgs string
if len(isArbiter) == 0 { // not arbiter
authArgs = "--username=$MONGO_INITDB_ROOT_USERNAME --password=$MONGO_INITDB_ROOT_PASSWORD --authenticationDatabase=admin"
}
return []string{
"bash",
"-c",
fmt.Sprintf(`set -x; if [[ $(%s admin --host=localhost %v %v --quiet --eval "db.adminCommand('ping').ok" ) -eq "1" ]]; then
fmt.Sprintf(`set -x; if [[ $(%s admin --host=localhost %v --quiet --eval "db.adminCommand('ping').ok" ) -eq "1" ]]; then
exit 0
fi
exit 1`, m.GetEntryCommand(mgVersion), sslArgs, authArgs),
exit 1`, m.GetEntryCommand(mgVersion), sslArgs),
}
}

func (m *MongoDB) GetDefaultLivenessProbeSpec(mgVersion *v1alpha1.MongoDBVersion, isArbiter ...bool) *core.Probe {
return &core.Probe{
ProbeHandler: core.ProbeHandler{
Exec: &core.ExecAction{
Command: m.getCmdForProbes(mgVersion, isArbiter...),
Command: m.getCmdForProbes(mgVersion),
},
},
FailureThreshold: 3,
Expand All @@ -951,7 +947,7 @@ func (m *MongoDB) GetDefaultReadinessProbeSpec(mgVersion *v1alpha1.MongoDBVersio
return &core.Probe{
ProbeHandler: core.ProbeHandler{
Exec: &core.ExecAction{
Command: m.getCmdForProbes(mgVersion, isArbiter...),
Command: m.getCmdForProbes(mgVersion),
},
},
FailureThreshold: 3,
Expand Down

0 comments on commit 8163d17

Please sign in to comment.