Skip to content

Commit

Permalink
mysqlcluster: wait until file exist #728
Browse files Browse the repository at this point in the history
  • Loading branch information
acekingke committed Nov 2, 2022
1 parent b82fd46 commit b6c191f
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion mysqlcluster/container/auditlog.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (c *auditLog) getImage() string {
// getCommand get the container command.
func (c *auditLog) getCommand() []string {
logsName := "/mysql-audit.log"
return []string{"sh", "-c", "for i in {120..0}; do if [ -f " + utils.LogsVolumeMountPath + logsName + " ] ; then break; fi;sleep 1; done; " +
return []string{"sh", "-c", "while true; do if [ -f " + utils.LogsVolumeMountPath + logsName + " ] ; then break; fi;sleep 1; done; " +
"tail -f " + utils.LogsVolumeMountPath + logsName}
}

Expand Down
2 changes: 1 addition & 1 deletion mysqlcluster/container/auditlog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ var (
MysqlCluster: &auditlogMysqlCluster,
}
auditLogCase = EnsureContainer("auditlog", &testAuditlogCluster)
auditlogCommand = []string{"sh", "-c", "for i in {120..0}; do if [ -f /var/log/mysql/mysql-audit.log ] ; then break; fi;sleep 1; done; tail -f /var/log/mysql/mysql-audit.log"}
auditlogCommand = []string{"sh", "-c", "while true; do if [ -f /var/log/mysql/mysql-audit.log ] ; then break; fi;sleep 1; done; tail -f /var/log/mysql/mysql-audit.log"}
auditlogVolumeMounts = []corev1.VolumeMount{
{
Name: "logs",
Expand Down
2 changes: 1 addition & 1 deletion mysqlcluster/container/slowlog.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (c *slowLog) getImage() string {
// getCommand get the container command.
func (c *slowLog) getCommand() []string {
logsName := "/mysql-slow.log"
return []string{"sh", "-c", "for i in {120..0}; do if [ -f " + utils.LogsVolumeMountPath + logsName + " ] ; then break; fi;sleep 1; done; " +
return []string{"sh", "-c", "while true; do if [ -f " + utils.LogsVolumeMountPath + logsName + " ] ; then break; fi;sleep 1; done; " +
"tail -f " + utils.LogsVolumeMountPath + logsName}
}

Expand Down
2 changes: 1 addition & 1 deletion mysqlcluster/container/slowlog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func TestGetSlowlogImage(t *testing.T) {
}

func TestGetSlowlogCommand(t *testing.T) {
command := []string{"sh", "-c", "for i in {120..0}; do if [ -f /var/log/mysql/mysql-slow.log ] ; then break; fi;sleep 1; done; tail -f /var/log/mysql/mysql-slow.log"}
command := []string{"sh", "-c", "while true; do if [ -f /var/log/mysql/mysql-slow.log ] ; then break; fi;sleep 1; done; tail -f /var/log/mysql/mysql-slow.log"}
assert.Equal(t, command, slowlogCase.Command)
}

Expand Down

0 comments on commit b6c191f

Please sign in to comment.