Skip to content

Commit

Permalink
Make user-defined InitContainers take the precedence
Browse files Browse the repository at this point in the history
  • Loading branch information
bananaappletw authored and AMecea committed Sep 22, 2020
1 parent 053fc09 commit dfdea2b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
* Add `initBucketURL` and `initBucketSecretName` options to MysqlCluster chart. This bumps the chart version to `0.3.0`
### Changed
* Only add `binlog-space-limit` for `percona` image
* Make user-defined InitContainer take the precedence
* Set timeout of 15s on connection between the operator and Orchestrator
* Bump controller-util dependency to 0.1.18 which fixes some updates on pod spec.
* Removed `NO_AUTO_VALUE_ON_ZERO` from `sql-mode` to be inline with MySQL default value
Expand Down
23 changes: 12 additions & 11 deletions pkg/controller/mysqlcluster/internal/syncer/statefullset.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,14 +324,20 @@ func (s *sfsSyncer) getEnvFor(name string) []core.EnvVar {
}

func (s *sfsSyncer) ensureInitContainersSpec() []core.Container {
initCs := []core.Container{
// clone and init container
s.ensureContainer(containerCloneAndInitName,
s.opt.SidecarImage,
[]string{"clone-and-init"},
),
initCs := []core.Container{}

// add user defined init containers
if len(s.cluster.Spec.PodSpec.InitContainers) > 0 {
initCs = append(initCs, s.cluster.Spec.PodSpec.InitContainers...)
}

// clone and init container
cloneInit := s.ensureContainer(containerCloneAndInitName,
s.opt.SidecarImage,
[]string{"clone-and-init"},
)
initCs = append(initCs, cloneInit)

// add init container for MySQL if docker image supports this
if s.cluster.ShouldHaveInitContainerForMysql() {
mysqlInit := s.ensureContainer(containerMySQLInitName,
Expand All @@ -341,11 +347,6 @@ func (s *sfsSyncer) ensureInitContainersSpec() []core.Container {
initCs = append(initCs, mysqlInit)
}

// add user defined init containers
if len(s.cluster.Spec.PodSpec.InitContainers) > 0 {
initCs = append(initCs, s.cluster.Spec.PodSpec.InitContainers...)
}

return initCs
}

Expand Down

0 comments on commit dfdea2b

Please sign in to comment.