Skip to content
This repository was archived by the owner on Dec 12, 2025. It is now read-only.

Commit f33768e

Browse files
authored
fix confusing error message (#1479)
1 parent a986f2e commit f33768e

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

controllers/construct/mongodbstatefulset.go

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,17 @@ const (
6464
automationAgentLogOptions = " -logFile ${AGENT_LOG_FILE} -maxLogFileDurationHrs ${AGENT_MAX_LOG_FILE_DURATION_HOURS} -logLevel ${AGENT_LOG_LEVEL}"
6565

6666
MongodbUserCommand = `current_uid=$(id -u)
67+
declare -r current_uid
68+
if ! grep -q "${current_uid}" /etc/passwd ; then
69+
sed -e "s/^mongodb:/builder:/" /etc/passwd > /tmp/passwd
70+
echo "mongodb:x:$(id -u):$(id -g):,,,:/:/bin/bash" >> /tmp/passwd
71+
export NSS_WRAPPER_PASSWD=/tmp/passwd
72+
export LD_PRELOAD=libnss_wrapper.so
73+
export NSS_WRAPPER_GROUP=/etc/group
74+
fi
75+
76+
`
77+
MongodbUserCommandWithAPIKeyExport = `current_uid=$(id -u)
6778
AGENT_API_KEY="$(cat /mongodb-automation/agent-api-key/agentApiKey)"
6879
declare -r current_uid
6980
if ! grep -q "${current_uid}" /etc/passwd ; then
@@ -225,7 +236,12 @@ func BaseAgentCommand() string {
225236
return "agent/mongodb-agent -healthCheckFilePath=" + agentHealthStatusFilePathValue + " -serveStatusPort=5000"
226237
}
227238

228-
func AutomationAgentCommand() []string {
239+
// AutomationAgentCommand withAgentAPIKeyExport detects whether we want to deploy this agent with the agent api key exported
240+
// it can be used to register the agent with OM.
241+
func AutomationAgentCommand(withAgentAPIKeyExport bool) []string {
242+
if withAgentAPIKeyExport {
243+
return []string{"/bin/bash", "-c", MongodbUserCommandWithAPIKeyExport + BaseAgentCommand() + " -cluster=" + clusterFilePath + automationAgentOptions + automationAgentLogOptions}
244+
}
229245
return []string{"/bin/bash", "-c", MongodbUserCommand + BaseAgentCommand() + " -cluster=" + clusterFilePath + automationAgentOptions + automationAgentLogOptions}
230246
}
231247

@@ -238,7 +254,7 @@ func mongodbAgentContainer(automationConfigSecretName string, volumeMounts []cor
238254
container.WithReadinessProbe(DefaultReadiness()),
239255
container.WithResourceRequirements(resourcerequirements.Defaults()),
240256
container.WithVolumeMounts(volumeMounts),
241-
container.WithCommand(AutomationAgentCommand()),
257+
container.WithCommand(AutomationAgentCommand(false)),
242258
containerSecurityContext,
243259
container.WithEnvs(
244260
corev1.EnvVar{

0 commit comments

Comments
 (0)