@@ -324,14 +324,20 @@ func (s *sfsSyncer) getEnvFor(name string) []core.EnvVar {
324324}
325325
326326func (s * sfsSyncer ) ensureInitContainersSpec () []core.Container {
327- initCs := []core.Container {
328- // clone and init container
329- s .ensureContainer (containerCloneAndInitName ,
330- s .opt .SidecarImage ,
331- []string {"clone-and-init" },
332- ),
327+ initCs := []core.Container {}
328+
329+ // add user defined init containers
330+ if len (s .cluster .Spec .PodSpec .InitContainers ) > 0 {
331+ initCs = append (initCs , s .cluster .Spec .PodSpec .InitContainers ... )
333332 }
334333
334+ // clone and init container
335+ cloneInit := s .ensureContainer (containerCloneAndInitName ,
336+ s .opt .SidecarImage ,
337+ []string {"clone-and-init" },
338+ )
339+ initCs = append (initCs , cloneInit )
340+
335341 // add init container for MySQL if docker image supports this
336342 if s .cluster .ShouldHaveInitContainerForMysql () {
337343 mysqlInit := s .ensureContainer (containerMySQLInitName ,
@@ -341,11 +347,6 @@ func (s *sfsSyncer) ensureInitContainersSpec() []core.Container {
341347 initCs = append (initCs , mysqlInit )
342348 }
343349
344- // add user defined init containers
345- if len (s .cluster .Spec .PodSpec .InitContainers ) > 0 {
346- initCs = append (initCs , s .cluster .Spec .PodSpec .InitContainers ... )
347- }
348-
349350 return initCs
350351}
351352
0 commit comments