Skip to content

Commit

Permalink
*: Save Xenon's metadata to persistent storage. radondb#406
Browse files Browse the repository at this point in the history
runkecheng committed Mar 15, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 49384da commit 87aed49
Showing 12 changed files with 50 additions and 12 deletions.
1 change: 1 addition & 0 deletions mysqlcluster/container/backup.go
Original file line number Diff line number Diff line change
@@ -134,6 +134,7 @@ func (c *backupSidecar) getVolumeMounts() []corev1.VolumeMount {
{
Name: utils.DataVolumeName,
MountPath: utils.DataVolumeMountPath,
SubPath: utils.MysqlDataSubPath,
},
{
Name: utils.LogsVolumeName,
1 change: 1 addition & 0 deletions mysqlcluster/container/init_mysql.go
Original file line number Diff line number Diff line change
@@ -115,6 +115,7 @@ func (c *initMysql) getVolumeMounts() []corev1.VolumeMount {
{
Name: utils.DataVolumeName,
MountPath: utils.DataVolumeMountPath,
SubPath: utils.MysqlDataSubPath,
},
{
Name: utils.LogsVolumeName,
1 change: 1 addition & 0 deletions mysqlcluster/container/init_mysql_test.go
Original file line number Diff line number Diff line change
@@ -59,6 +59,7 @@ var (
{
Name: utils.DataVolumeName,
MountPath: utils.DataVolumeMountPath,
SubPath: utils.MysqlDataSubPath,
},
{
Name: utils.LogsVolumeName,
6 changes: 6 additions & 0 deletions mysqlcluster/container/init_sidecar.go
Original file line number Diff line number Diff line change
@@ -202,6 +202,12 @@ func (c *initSidecar) getVolumeMounts() []corev1.VolumeMount {
corev1.VolumeMount{
Name: utils.DataVolumeName,
MountPath: utils.DataVolumeMountPath,
SubPath: utils.MysqlDataSubPath,
},
corev1.VolumeMount{
Name: utils.DataVolumeName,
MountPath: utils.XenonDataVolumeMountPath,
SubPath: utils.XenonDataSubPath,
},
)
}
16 changes: 12 additions & 4 deletions mysqlcluster/container/init_sidecar_test.go
Original file line number Diff line number Diff line change
@@ -455,10 +455,18 @@ func TestGetInitSidecarVolumeMounts(t *testing.T) {
persistenceCase := EnsureContainer("init-sidecar", &testPersistenceCluster)
persistenceVolumeMounts := make([]corev1.VolumeMount, 6, 7)
copy(persistenceVolumeMounts, defaultInitsidecarVolumeMounts)
persistenceVolumeMounts = append(persistenceVolumeMounts, corev1.VolumeMount{
Name: utils.DataVolumeName,
MountPath: utils.DataVolumeMountPath,
})
persistenceVolumeMounts = append(persistenceVolumeMounts,
corev1.VolumeMount{
Name: utils.DataVolumeName,
MountPath: utils.DataVolumeMountPath,
SubPath: utils.MysqlDataSubPath,
},
corev1.VolumeMount{
Name: utils.DataVolumeName,
MountPath: utils.XenonDataVolumeMountPath,
SubPath: utils.XenonDataSubPath,
},
)
assert.Equal(t, persistenceVolumeMounts, persistenceCase.VolumeMounts)
}
}
1 change: 1 addition & 0 deletions mysqlcluster/container/mysql.go
Original file line number Diff line number Diff line change
@@ -141,6 +141,7 @@ func (c *mysql) getVolumeMounts() []corev1.VolumeMount {
{
Name: utils.DataVolumeName,
MountPath: utils.DataVolumeMountPath,
SubPath: utils.MysqlDataSubPath,
},
{
Name: utils.LogsVolumeName,
1 change: 1 addition & 0 deletions mysqlcluster/container/mysql_test.go
Original file line number Diff line number Diff line change
@@ -147,6 +147,7 @@ func TestGetMysqlVolumeMounts(t *testing.T) {
{
Name: "data",
MountPath: "/var/lib/mysql",
SubPath: "mysql",
},
{
Name: "logs",
5 changes: 5 additions & 0 deletions mysqlcluster/container/xenon.go
Original file line number Diff line number Diff line change
@@ -110,6 +110,11 @@ func (c *xenon) getVolumeMounts() []corev1.VolumeMount {
Name: utils.ScriptsVolumeName,
MountPath: utils.ScriptsVolumeMountPath,
},
{
Name: utils.DataVolumeName,
MountPath: utils.XenonDataVolumeMountPath,
SubPath: utils.XenonDataSubPath,
},
{
Name: utils.XenonVolumeName,
MountPath: utils.XenonVolumeMountPath,
5 changes: 5 additions & 0 deletions mysqlcluster/container/xenon_test.go
Original file line number Diff line number Diff line change
@@ -130,6 +130,11 @@ func TestGetXenonVolumeMounts(t *testing.T) {
Name: "scripts",
MountPath: "/scripts",
},
{
Name: "data",
MountPath: "/var/lib/xenon",
SubPath: "xenon",
},
{
Name: "xenon",
MountPath: "/etc/xenon",
4 changes: 4 additions & 0 deletions sidecar/init.go
Original file line number Diff line number Diff line change
@@ -133,6 +133,10 @@ func runInitCommand(cfg *Config) error {
if err = os.Chown(dataPath, uid, gid); err != nil {
return fmt.Errorf("failed to chown %s: %s", dataPath, err)
}
// chown -R mysql:mysql /var/lib/xenon.
if err = os.Chown(xenonDataPath, uid, gid); err != nil {
return fmt.Errorf("failed to chown %s: %s", xenonDataPath, err)
}
}

// copy appropriate my.cnf from config-map to config mount.
2 changes: 2 additions & 0 deletions sidecar/util.go
Original file line number Diff line number Diff line change
@@ -45,6 +45,8 @@ var (

// dataPath is the mysql data path.
dataPath = utils.DataVolumeMountPath
// xenonMetaDataPath is the xenon metadata path.
xenonDataPath = utils.XenonDataVolumeMountPath

// // scriptsPath is the scripts path used for xenon.
// scriptsPath = utils.ScriptsVolumeMountPath
19 changes: 11 additions & 8 deletions utils/constants.go
Original file line number Diff line number Diff line change
@@ -99,14 +99,17 @@ const (
InitFileVolumeName = "init-mysql"

// volumes mount path.
ConfVolumeMountPath = "/etc/mysql"
ConfMapVolumeMountPath = "/mnt/config-map"
LogsVolumeMountPath = "/var/log/mysql"
DataVolumeMountPath = "/var/lib/mysql"
SysVolumeMountPath = "/host-sys"
ScriptsVolumeMountPath = "/scripts"
XenonVolumeMountPath = "/etc/xenon"
InitFileVolumeMountPath = "/docker-entrypoint-initdb.d"
ConfVolumeMountPath = "/etc/mysql"
ConfMapVolumeMountPath = "/mnt/config-map"
LogsVolumeMountPath = "/var/log/mysql"
DataVolumeMountPath = "/var/lib/mysql"
XenonDataVolumeMountPath = "/var/lib/xenon"
SysVolumeMountPath = "/host-sys"
ScriptsVolumeMountPath = "/scripts"
XenonVolumeMountPath = "/etc/xenon"
InitFileVolumeMountPath = "/docker-entrypoint-initdb.d"
MysqlDataSubPath = "mysql"
XenonDataSubPath = "xenon"

// Volume timezone name.
SysLocalTimeZone = "localtime"

0 comments on commit 87aed49

Please sign in to comment.