Skip to content

Commit 69aeb02

Browse files
committed
Add InitializeTimezoneData to populate timezone data with moco-init
1 parent c9cf464 commit 69aeb02

10 files changed

Lines changed: 28 additions & 5 deletions

api/v1beta2/mysqlcluster_types.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,13 @@ type MySQLClusterSpec struct {
143143
// communicate with mysqld over localhost when acting as a sidecar.
144144
AgentUseLocalhost bool `json:"agentUseLocalhost,omitempty"`
145145

146+
// InitializeTimezoneData controls whether the init container should populate the timezone data.
147+
// If set to true, the init container will load timezone data into MySQL.
148+
// The default is false.
149+
// +kubebuilder:default=false
150+
// +optional
151+
InitializeTimezoneData bool `json:"initializeTimezoneData,omitempty"`
152+
146153
// Offline sets the cluster offline, releasing compute resources. Data is not removed.
147154
// +optional
148155
Offline bool `json:"offline,omitempty"`

charts/moco/templates/generated/crds/moco_crds.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2253,6 +2253,10 @@ spec:
22532253
disableSlowQueryLogContainer:
22542254
description: DisableSlowQueryLogContainer controls whether to...
22552255
type: boolean
2256+
initializeTimezoneData:
2257+
default: false
2258+
description: InitializeTimezoneData controls whether the init...
2259+
type: boolean
22562260
logRotationSchedule:
22572261
description: LogRotationSchedule specifies the schedule to...
22582262
type: string

config/crd/bases/moco.cybozu.com_mysqlclusters.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ spec:
7070
disableSlowQueryLogContainer:
7171
description: DisableSlowQueryLogContainer controls whether to...
7272
type: boolean
73+
initializeTimezoneData:
74+
default: false
75+
description: InitializeTimezoneData controls whether the init...
76+
type: boolean
7377
logRotationSchedule:
7478
description: LogRotationSchedule specifies the schedule to...
7579
type: string

config/crd/tests/apiextensions.k8s.io_v1_customresourcedefinition_mysqlclusters.moco.cybozu.com.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ spec:
7070
disableSlowQueryLogContainer:
7171
description: DisableSlowQueryLogContainer controls whether to...
7272
type: boolean
73+
initializeTimezoneData:
74+
default: false
75+
description: InitializeTimezoneData controls whether the init...
76+
type: boolean
7377
logRotationSchedule:
7478
description: LogRotationSchedule specifies the schedule to...
7579
type: string

controllers/mysql_container.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,7 @@ func (r *MySQLClusterReconciler) makeMocoInitContainer(ctx context.Context, clus
332332
filepath.Join(constants.SharedPath, constants.InitCommand),
333333
fmt.Sprintf("%s=%s", constants.MocoInitDataDirFlag, constants.MySQLDataPath),
334334
fmt.Sprintf("%s=%s", constants.MocoInitConfDirFlag, constants.MySQLInitConfPath),
335+
fmt.Sprintf("%s=%s", constants.MocoInitTimezoneDataFlag, strconv.FormatBool(cluster.Spec.InitializeTimezoneData)),
335336
fmt.Sprintf("%d", cluster.Spec.ServerIDBase),
336337
}
337338

controllers/mysqlcluster_controller_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,8 +1026,8 @@ dummyKey: dummyValue
10261026
Expect(initContainer.Name).To(Equal(constants.InitContainerName))
10271027
Expect(initContainer.Image).To(Equal("moco-mysql:latest"))
10281028
Expect(initContainer.Command).To(ContainElement(fmt.Sprintf("%d", cluster.Spec.ServerIDBase)))
1029-
Expect(initContainer.Resources.Requests).To(Equal(corev1.ResourceList{corev1.ResourceCPU: resource.MustParse("100m"), corev1.ResourceMemory: resource.MustParse("300Mi")}))
1030-
Expect(initContainer.Resources.Limits).To(Equal(corev1.ResourceList{corev1.ResourceCPU: resource.MustParse("100m"), corev1.ResourceMemory: resource.MustParse("300Mi")}))
1029+
Expect(initContainer.Resources.Requests).To(Equal(corev1.ResourceList{corev1.ResourceCPU: resource.MustParse("100m"), corev1.ResourceMemory: resource.MustParse("512Mi")}))
1030+
Expect(initContainer.Resources.Limits).To(Equal(corev1.ResourceList{corev1.ResourceCPU: resource.MustParse("100m"), corev1.ResourceMemory: resource.MustParse("512Mi")}))
10311031
Expect(initContainer.SecurityContext).NotTo(BeNil())
10321032
Expect(initContainer.SecurityContext.RunAsUser).NotTo(BeNil())
10331033
Expect(*initContainer.SecurityContext.RunAsUser).To(Equal(int64(constants.ContainerUID)))

docs/crd_mysqlcluster_v1beta2.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ MySQLClusterSpec defines the desired state of MySQLCluster
8787
| disableSlowQueryLogContainer | DisableSlowQueryLogContainer controls whether to add a sidecar container named \"slow-log\" to output slow logs as the containers output. If set to true, the sidecar container and configmap used by the sidecar container are not added. The default is false. | bool | false |
8888
| slowQueryLogConfigTmpl | SlowQueryLogConfigTmpl is the template for slow query log configuration file. If this field is null, MOCO uses the default slow query log configuration. `{{ .Path }}` will be replaced with the path to the slow query log file. | *string | false |
8989
| agentUseLocalhost | AgentUseLocalhost configures the mysqld interface to bind and be accessed over localhost instead of pod name. During container init moco-agent will set mysql admin interface is bound to localhost. The moco-agent will also communicate with mysqld over localhost when acting as a sidecar. | bool | false |
90+
| initializeTimezoneData | InitializeTimezoneData controls whether the init container should populate the timezone data. If set to true, the init container will load timezone data into MySQL. The default is false. | bool | false |
9091
| offline | Offline sets the cluster offline, releasing compute resources. Data is not removed. | bool | false |
9192

9293
[Back to Custom Resources](#custom-resources)

docs/customize-system-container.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Specifying container names in `overwriteContainers` that are not listed here wil
3838
| Name | Default CPU Requests/Limits | Default Memory Requests/Limits | Description |
3939
| --------------- | --------------------------- | ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
4040
| agent | `100m` / `100m` | `100Mi` / `100Mi` | MOCO's agent container running in sidecar. refs: https://github.com/cybozu-go/moco-agent |
41-
| moco-init | `100m` / `100m` | `300Mi` / `300Mi` | Initializes MySQL data directory and create a configuration snippet to give instance specific configuration values such as server_id and admin_address. |
41+
| moco-init | `100m` / `100m` | `512Mi` / `512Mi` | Initializes MySQL data directory and create a configuration snippet to give instance specific configuration values such as server_id and admin_address. |
4242
| slow-log | `100m` / `100m` | `20Mi` / `20Mi` | Sidecar container for outputting slow query logs. |
4343
| mysqld-exporter | `200m` / `200m` | `100Mi` / `100Mi` | MySQL server exporter sidecar container. |
4444

pkg/constants/constants.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ const (
6565
MocoInitDataDirFlag = "--data-dir"
6666
// MocoInitConfDirFlag is flag for conf dir.
6767
MocoInitConfDirFlag = "--conf-dir"
68+
// MocoInitTimezoneDataFlag is flag for populating timezone data.
69+
MocoInitTimezoneDataFlag = "--init-timezones"
6870
// MocoMySQLDLocalhostFlag is flag for localhost bind.
6971
MocoMySQLDLocalhostFlag = "--mysqld-localhost"
7072
)

pkg/constants/container.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ const (
1919

2020
InitContainerCPURequest = "100m"
2121
InitContainerCPULimit = "100m"
22-
InitContainerMemRequest = "300Mi"
23-
InitContainerMemLimit = "300Mi"
22+
InitContainerMemRequest = "512Mi"
23+
InitContainerMemLimit = "512Mi"
2424

2525
SlowQueryLogAgentCPURequest = "100m"
2626
SlowQueryLogAgentCPULimit = "100m"

0 commit comments

Comments
 (0)