Skip to content

Commit dfdea2b

Browse files
bananaappletwAMecea
authored andcommitted
Make user-defined InitContainers take the precedence
1 parent 053fc09 commit dfdea2b

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
1414
* Add `initBucketURL` and `initBucketSecretName` options to MysqlCluster chart. This bumps the chart version to `0.3.0`
1515
### Changed
1616
* Only add `binlog-space-limit` for `percona` image
17+
* Make user-defined InitContainer take the precedence
1718
* Set timeout of 15s on connection between the operator and Orchestrator
1819
* Bump controller-util dependency to 0.1.18 which fixes some updates on pod spec.
1920
* Removed `NO_AUTO_VALUE_ON_ZERO` from `sql-mode` to be inline with MySQL default value

pkg/controller/mysqlcluster/internal/syncer/statefullset.go

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -324,14 +324,20 @@ func (s *sfsSyncer) getEnvFor(name string) []core.EnvVar {
324324
}
325325

326326
func (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

Comments
 (0)