@@ -421,7 +421,7 @@ func buildDatabaseStatefulSetConfigurationFunction(mdb databaseStatefulSetSource
421
421
}
422
422
423
423
secretsToInject := buildVaultDatabaseSecretsToInject (mdb , opts )
424
- volumes , _ , pvcFuncs := getVolumesAndPVCs (mdb , opts , secretsToInject , log )
424
+ volumes , volumeMounts , pvcFuncs := getVolumesAndPVCs (mdb , opts , secretsToInject , log )
425
425
426
426
volumesFunc := func (spec * corev1.PodTemplateSpec ) {
427
427
for _ , v := range volumes {
@@ -492,6 +492,7 @@ func buildDatabaseStatefulSetConfigurationFunction(mdb databaseStatefulSetSource
492
492
volumesFunc ,
493
493
configureImagePullSecrets ,
494
494
podTemplateSpecFunc ,
495
+ podtemplatespec .WithAllVolumeMounts (volumeMounts ... ),
495
496
)),
496
497
)
497
498
}
@@ -543,7 +544,7 @@ func buildPersistentVolumeClaimsFuncs(opts DatabaseStatefulSetOptions) (map[stri
543
544
return claims , mounts
544
545
}
545
546
546
- func sharedDatabaseContainerFunc (databaseImage string , podSpecWrapper mdbv1.PodSpecWrapper , volumeMounts []corev1. VolumeMount , configureContainerSecurityContext container.Modification , port int32 ) container.Modification {
547
+ func sharedDatabaseContainerFunc (databaseImage string , podSpecWrapper mdbv1.PodSpecWrapper , configureContainerSecurityContext container.Modification , port int32 ) container.Modification {
547
548
return container .Apply (
548
549
container .WithResourceRequirements (buildRequirementsFromPodSpec (podSpecWrapper )),
549
550
container .WithPorts ([]corev1.ContainerPort {{ContainerPort : port }}),
@@ -665,9 +666,6 @@ func buildMongoDBPodTemplateSpec(opts DatabaseStatefulSetOptions, mdb databaseSt
665
666
scriptsVolume := statefulset .CreateVolumeFromEmptyDir ("database-scripts" )
666
667
volumes := []corev1.Volume {scriptsVolume }
667
668
668
- secretsToInject := buildVaultDatabaseSecretsToInject (mdb , opts )
669
- _ , volumeMounts , _ := getVolumesAndPVCs (mdb , opts , secretsToInject , log )
670
-
671
669
pullSecretsConfigurationFunc := podtemplatespec .NOOP ()
672
670
if pullSecrets , ok := env .Read (util .ImagePullSecrets ); ok { // nolint:forbidigo
673
671
pullSecretsConfigurationFunc = podtemplatespec .WithImagePullSecrets (pullSecrets )
@@ -682,49 +680,41 @@ func buildMongoDBPodTemplateSpec(opts DatabaseStatefulSetOptions, mdb databaseSt
682
680
podtemplatespec .WithTopologyKey (opts .PodSpec .GetTopologyKeyOrDefault (), 0 ),
683
681
podtemplatespec .WithServiceAccount (serviceAccountName ),
684
682
podtemplatespec .WithVolumes (volumes ),
685
- buildContainers (opts , mdb , volumeMounts ),
683
+ buildContainers (opts , mdb ),
686
684
)
687
685
}
688
686
689
687
// buildContainers directly creates and configures all containers based on architecture
690
- func buildContainers (opts DatabaseStatefulSetOptions , mdb databaseStatefulSetSource , volumeMounts []corev1. VolumeMount ) func (* corev1.PodTemplateSpec ) {
688
+ func buildContainers (opts DatabaseStatefulSetOptions , mdb databaseStatefulSetSource ) func (* corev1.PodTemplateSpec ) {
691
689
return func (podTemplateSpec * corev1.PodTemplateSpec ) {
692
690
isStaticArchitecture := architectures .IsRunningStaticArchitecture (mdb .GetAnnotations ())
693
691
694
692
if isStaticArchitecture {
695
- buildStaticArchitectureContainers (podTemplateSpec , opts , mdb , volumeMounts )
693
+ buildStaticArchitectureContainers (podTemplateSpec , opts , mdb )
696
694
} else {
697
- buildNonStaticArchitectureContainers (podTemplateSpec , opts , volumeMounts )
698
- }
699
-
700
- // Apply hostname override volume mounts if specified
701
- if opts .HostNameOverrideConfigmapName != "" {
702
- applyHostnameOverrideVolumeMounts (podTemplateSpec , opts .HostNameOverrideConfigmapName )
695
+ buildNonStaticArchitectureContainers (podTemplateSpec , opts )
703
696
}
704
697
}
705
698
}
706
699
707
700
// buildStaticArchitectureContainers creates containers for static architecture
708
- func buildStaticArchitectureContainers (podTemplateSpec * corev1.PodTemplateSpec , opts DatabaseStatefulSetOptions , mdb databaseStatefulSetSource , volumeMounts []corev1. VolumeMount ) {
701
+ func buildStaticArchitectureContainers (podTemplateSpec * corev1.PodTemplateSpec , opts DatabaseStatefulSetOptions , mdb databaseStatefulSetSource ) {
709
702
podTemplateSpec .Spec .Containers = make ([]corev1.Container , 3 )
710
703
podTemplateSpec .Spec .Containers [0 ] = createAgentContainer (opts , mdb )
711
704
podTemplateSpec .Spec .Containers [1 ] = createMongodBinaryHolderContainer (opts )
712
705
podTemplateSpec .Spec .Containers [2 ] = createAgentUtilitiesHolderContainer ()
713
- container .WithVolumeMounts (volumeMounts )(& podTemplateSpec .Spec .Containers [0 ])
714
- container .WithVolumeMounts (volumeMounts )(& podTemplateSpec .Spec .Containers [1 ])
715
- container .WithVolumeMounts (volumeMounts )(& podTemplateSpec .Spec .Containers [2 ])
716
706
717
707
// Apply common configurations to all containers
718
708
applyCommonStaticConfigurations (podTemplateSpec .Spec .Containers , opts )
719
709
}
720
710
721
711
// buildNonStaticArchitectureContainers creates containers for non-static architecture
722
- func buildNonStaticArchitectureContainers (podTemplateSpec * corev1.PodTemplateSpec , opts DatabaseStatefulSetOptions , volumeMounts []corev1. VolumeMount ) {
712
+ func buildNonStaticArchitectureContainers (podTemplateSpec * corev1.PodTemplateSpec , opts DatabaseStatefulSetOptions ) {
723
713
podTemplateSpec .Spec .Containers = make ([]corev1.Container , 1 )
724
714
podTemplateSpec .Spec .InitContainers = make ([]corev1.Container , 1 )
725
715
726
716
podTemplateSpec .Spec .InitContainers [0 ] = createDatabaseInitContainer (opts )
727
- podTemplateSpec .Spec .Containers [0 ] = createDatabaseContainer (opts , volumeMounts )
717
+ podTemplateSpec .Spec .Containers [0 ] = createDatabaseContainer (opts )
728
718
}
729
719
730
720
// createAgentContainer creates the agent container for static architecture
@@ -786,7 +776,7 @@ func createDatabaseInitContainer(opts DatabaseStatefulSetOptions) corev1.Contain
786
776
}
787
777
788
778
// createDatabaseContainer creates the database container for non-static architecture
789
- func createDatabaseContainer (opts DatabaseStatefulSetOptions , volumeMounts []corev1. VolumeMount ) corev1.Container {
779
+ func createDatabaseContainer (opts DatabaseStatefulSetOptions ) corev1.Container {
790
780
// scripts volume is shared by the init container and the AppDB, so the startup
791
781
// script can be copied over
792
782
@@ -795,7 +785,7 @@ func createDatabaseContainer(opts DatabaseStatefulSetOptions, volumeMounts []cor
795
785
Image : opts .DatabaseNonStaticImage ,
796
786
Command : []string {"/opt/scripts/agent-launcher.sh" },
797
787
Env : databaseEnvVars (opts ),
798
- VolumeMounts : append ( volumeMounts , databaseScriptsVolumeMount (true )) ,
788
+ VolumeMounts : []corev1. VolumeMount { databaseScriptsVolumeMount (true )} ,
799
789
Resources : buildRequirementsFromPodSpec (* opts .PodSpec ),
800
790
Ports : []corev1.ContainerPort {{ContainerPort : opts .ServicePort }},
801
791
ImagePullPolicy : corev1 .PullPolicy (env .ReadOrPanic (util .AutomationAgentImagePullPolicy )),
@@ -810,7 +800,7 @@ func createDatabaseContainer(opts DatabaseStatefulSetOptions, volumeMounts []cor
810
800
811
801
_ , containerSecurityContext := podtemplatespec .WithDefaultSecurityContextsModifications ()
812
802
813
- sharedDatabaseContainerFunc (opts .DatabaseNonStaticImage , * opts .PodSpec , volumeMounts , containerSecurityContext , opts .ServicePort )(& c )
803
+ sharedDatabaseContainerFunc (opts .DatabaseNonStaticImage , * opts .PodSpec , containerSecurityContext , opts .ServicePort )(& c )
814
804
815
805
return c
816
806
}
0 commit comments