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

Commit 9e32503

Browse files
authored
CLOUDP-204105 Conditionally run the upgrade hook (#1513)
1 parent a07365e commit 9e32503

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

controllers/construct/mongodbstatefulset.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -384,11 +384,13 @@ func getMongoDBImage(version string) string {
384384
func mongodbContainer(version string, volumeMounts []corev1.VolumeMount, additionalMongoDBConfig mdbv1.MongodConfiguration) container.Modification {
385385
filePath := additionalMongoDBConfig.GetDBDataDir() + "/" + automationMongodConfFileName
386386
mongoDbCommand := fmt.Sprintf(`
387-
#run post-start hook to handle version changes
388-
/hooks/version-upgrade
387+
if [ -e "/hooks/version-upgrade" ]; then
388+
#run post-start hook to handle version changes (if exists)
389+
/hooks/version-upgrade
390+
fi
389391
390392
# wait for config and keyfile to be created by the agent
391-
while ! [ -f %s -a -f %s ]; do sleep 3 ; done ; sleep 2 ;
393+
while ! [ -f %s -a -f %s ]; do sleep 3 ; done ; sleep 2 ;
392394
393395
# start mongod with this configuration
394396
exec mongod -f %s;

0 commit comments

Comments
 (0)