Skip to content

Commit a6386c7

Browse files
authored
Merge pull request #413 from runkecheng/save_xenon_metadata
*: Save Xenon's metadata to persistent storage. #406
2 parents f6932c6 + 87aed49 commit a6386c7

File tree

12 files changed

+50
-12
lines changed

12 files changed

+50
-12
lines changed

mysqlcluster/container/backup.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ func (c *backupSidecar) getVolumeMounts() []corev1.VolumeMount {
134134
{
135135
Name: utils.DataVolumeName,
136136
MountPath: utils.DataVolumeMountPath,
137+
SubPath: utils.MysqlDataSubPath,
137138
},
138139
{
139140
Name: utils.LogsVolumeName,

mysqlcluster/container/init_mysql.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ func (c *initMysql) getVolumeMounts() []corev1.VolumeMount {
115115
{
116116
Name: utils.DataVolumeName,
117117
MountPath: utils.DataVolumeMountPath,
118+
SubPath: utils.MysqlDataSubPath,
118119
},
119120
{
120121
Name: utils.LogsVolumeName,

mysqlcluster/container/init_mysql_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ var (
5959
{
6060
Name: utils.DataVolumeName,
6161
MountPath: utils.DataVolumeMountPath,
62+
SubPath: utils.MysqlDataSubPath,
6263
},
6364
{
6465
Name: utils.LogsVolumeName,

mysqlcluster/container/init_sidecar.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,12 @@ func (c *initSidecar) getVolumeMounts() []corev1.VolumeMount {
202202
corev1.VolumeMount{
203203
Name: utils.DataVolumeName,
204204
MountPath: utils.DataVolumeMountPath,
205+
SubPath: utils.MysqlDataSubPath,
206+
},
207+
corev1.VolumeMount{
208+
Name: utils.DataVolumeName,
209+
MountPath: utils.XenonDataVolumeMountPath,
210+
SubPath: utils.XenonDataSubPath,
205211
},
206212
)
207213
}

mysqlcluster/container/init_sidecar_test.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -455,10 +455,18 @@ func TestGetInitSidecarVolumeMounts(t *testing.T) {
455455
persistenceCase := EnsureContainer("init-sidecar", &testPersistenceCluster)
456456
persistenceVolumeMounts := make([]corev1.VolumeMount, 6, 7)
457457
copy(persistenceVolumeMounts, defaultInitsidecarVolumeMounts)
458-
persistenceVolumeMounts = append(persistenceVolumeMounts, corev1.VolumeMount{
459-
Name: utils.DataVolumeName,
460-
MountPath: utils.DataVolumeMountPath,
461-
})
458+
persistenceVolumeMounts = append(persistenceVolumeMounts,
459+
corev1.VolumeMount{
460+
Name: utils.DataVolumeName,
461+
MountPath: utils.DataVolumeMountPath,
462+
SubPath: utils.MysqlDataSubPath,
463+
},
464+
corev1.VolumeMount{
465+
Name: utils.DataVolumeName,
466+
MountPath: utils.XenonDataVolumeMountPath,
467+
SubPath: utils.XenonDataSubPath,
468+
},
469+
)
462470
assert.Equal(t, persistenceVolumeMounts, persistenceCase.VolumeMounts)
463471
}
464472
}

mysqlcluster/container/mysql.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ func (c *mysql) getVolumeMounts() []corev1.VolumeMount {
141141
{
142142
Name: utils.DataVolumeName,
143143
MountPath: utils.DataVolumeMountPath,
144+
SubPath: utils.MysqlDataSubPath,
144145
},
145146
{
146147
Name: utils.LogsVolumeName,

mysqlcluster/container/mysql_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ func TestGetMysqlVolumeMounts(t *testing.T) {
147147
{
148148
Name: "data",
149149
MountPath: "/var/lib/mysql",
150+
SubPath: "mysql",
150151
},
151152
{
152153
Name: "logs",

mysqlcluster/container/xenon.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,11 @@ func (c *xenon) getVolumeMounts() []corev1.VolumeMount {
114114
Name: utils.ScriptsVolumeName,
115115
MountPath: utils.ScriptsVolumeMountPath,
116116
},
117+
{
118+
Name: utils.DataVolumeName,
119+
MountPath: utils.XenonDataVolumeMountPath,
120+
SubPath: utils.XenonDataSubPath,
121+
},
117122
{
118123
Name: utils.XenonVolumeName,
119124
MountPath: utils.XenonVolumeMountPath,

mysqlcluster/container/xenon_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,11 @@ func TestGetXenonVolumeMounts(t *testing.T) {
134134
Name: "scripts",
135135
MountPath: "/scripts",
136136
},
137+
{
138+
Name: "data",
139+
MountPath: "/var/lib/xenon",
140+
SubPath: "xenon",
141+
},
137142
{
138143
Name: "xenon",
139144
MountPath: "/etc/xenon",

sidecar/init.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,10 @@ func runInitCommand(cfg *Config) error {
133133
if err = os.Chown(dataPath, uid, gid); err != nil {
134134
return fmt.Errorf("failed to chown %s: %s", dataPath, err)
135135
}
136+
// chown -R mysql:mysql /var/lib/xenon.
137+
if err = os.Chown(xenonDataPath, uid, gid); err != nil {
138+
return fmt.Errorf("failed to chown %s: %s", xenonDataPath, err)
139+
}
136140
}
137141

138142
// copy appropriate my.cnf from config-map to config mount.

0 commit comments

Comments
 (0)