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
Revert "Merge pull request radondb#413 from runkecheng/save_xenon_metadata"

This reverts commit a6386c7, reversing
changes made to f6932c6.

Subpath does not work in some environments, so we decided to share DATA storage volumes directly.
  • Loading branch information
runkecheng committed Apr 11, 2022
1 parent 4b5c926 commit 06d5bc0
Show file tree
Hide file tree
Showing 14 changed files with 21 additions and 54 deletions.
6 changes: 3 additions & 3 deletions hack/xenon/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@ FROM alpine:3.13
RUN set -ex \
&& addgroup -g 1001 mysql && adduser -u 1001 -g 1001 -S mysql \
&& apk add --no-cache curl bash jq \
&& mkdir -p /etc/xenon /var/lib/xenon /lib64 \
&& mkdir -p /etc/xenon /lib64 \
&& ln -s /lib/libc.musl-x86_64.so.1 /lib64/ld-linux-x86-64.so.2 \
&& echo "/etc/xenon/xenon.json" > /config.path \
# allow to change config files
&& chown -R 1001:1001 /etc/xenon /var/lib/xenon
&& chown -R 1001:1001 /etc/xenon

COPY --from=builder /go/src/github.com/radondb/xenon/bin/xenon /usr/local/bin/xenon
COPY --from=builder /go/src/github.com/radondb/xenon/bin/xenoncli /usr/local/bin/xenoncli

USER 1001
WORKDIR /
EXPOSE 8801
VOLUME ["/var/lib/xenon", "/etc/xenon"]
VOLUME ["/etc/xenon"]

ENTRYPOINT ["xenon"]
CMD ["-c", "/etc/xenon/xenon.json"]
1 change: 0 additions & 1 deletion mysqlcluster/container/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ func (c *backupSidecar) getVolumeMounts() []corev1.VolumeMount {
{
Name: utils.DataVolumeName,
MountPath: utils.DataVolumeMountPath,
SubPath: utils.MysqlDataSubPath,
},
{
Name: utils.LogsVolumeName,
Expand Down
1 change: 0 additions & 1 deletion mysqlcluster/container/init_mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ func (c *initMysql) getVolumeMounts() []corev1.VolumeMount {
{
Name: utils.DataVolumeName,
MountPath: utils.DataVolumeMountPath,
SubPath: utils.MysqlDataSubPath,
},
{
Name: utils.LogsVolumeName,
Expand Down
1 change: 0 additions & 1 deletion mysqlcluster/container/init_mysql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ var (
{
Name: utils.DataVolumeName,
MountPath: utils.DataVolumeMountPath,
SubPath: utils.MysqlDataSubPath,
},
{
Name: utils.LogsVolumeName,
Expand Down
6 changes: 0 additions & 6 deletions mysqlcluster/container/init_sidecar.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,6 @@ 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,
},
)
}
Expand Down
13 changes: 1 addition & 12 deletions mysqlcluster/container/init_sidecar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -455,18 +455,7 @@ 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,
SubPath: utils.MysqlDataSubPath,
},
corev1.VolumeMount{
Name: utils.DataVolumeName,
MountPath: utils.XenonDataVolumeMountPath,
SubPath: utils.XenonDataSubPath,
},
)
persistenceVolumeMounts = append(persistenceVolumeMounts, corev1.VolumeMount{Name: utils.DataVolumeName, MountPath: utils.DataVolumeMountPath})
assert.Equal(t, persistenceVolumeMounts, persistenceCase.VolumeMounts)
}
}
1 change: 0 additions & 1 deletion mysqlcluster/container/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ func (c *mysql) getVolumeMounts() []corev1.VolumeMount {
{
Name: utils.DataVolumeName,
MountPath: utils.DataVolumeMountPath,
SubPath: utils.MysqlDataSubPath,
},
{
Name: utils.LogsVolumeName,
Expand Down
1 change: 0 additions & 1 deletion mysqlcluster/container/mysql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ func TestGetMysqlVolumeMounts(t *testing.T) {
{
Name: "data",
MountPath: "/var/lib/mysql",
SubPath: "mysql",
},
{
Name: "logs",
Expand Down
9 changes: 4 additions & 5 deletions mysqlcluster/container/xenon.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,14 @@ 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,
},
{
Name: utils.DataVolumeName,
MountPath: utils.DataVolumeMountPath,
},
{
Name: utils.SysLocalTimeZone,
MountPath: utils.SysLocalTimeZoneMountPath,
Expand Down
9 changes: 4 additions & 5 deletions mysqlcluster/container/xenon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,14 @@ func TestGetXenonVolumeMounts(t *testing.T) {
Name: "scripts",
MountPath: "/scripts",
},
{
Name: "data",
MountPath: "/var/lib/xenon",
SubPath: "xenon",
},
{
Name: "xenon",
MountPath: "/etc/xenon",
},
{
Name: "data",
MountPath: "/var/lib/mysql",
},
{
Name: utils.SysLocalTimeZone,
MountPath: "/etc/localtime",
Expand Down
2 changes: 1 addition & 1 deletion sidecar/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ func (cfg *Config) buildXenonConf() []byte {
"election-timeout": %d,
"admit-defeat-hearbeat-count": %d,
"heartbeat-timeout": %d,
"meta-datadir": "/var/lib/xenon/",
"meta-datadir": "/var/lib/mysql/xenon",
"semi-sync-degrade": true,
"purge-binlog-disabled": true,
"super-idle": false
Expand Down
4 changes: 0 additions & 4 deletions sidecar/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,6 @@ 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.
Expand Down
2 changes: 0 additions & 2 deletions sidecar/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ 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
Expand Down
19 changes: 8 additions & 11 deletions utils/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,17 +99,14 @@ const (
InitFileVolumeName = "init-mysql"

// volumes mount path.
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"
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"

// Volume timezone name.
SysLocalTimeZone = "localtime"
Expand Down

0 comments on commit 06d5bc0

Please sign in to comment.