Skip to content

Commit

Permalink
Fix remote storage delete bug
Browse files Browse the repository at this point in the history
  • Loading branch information
bluven authored and AMecea committed Jun 14, 2019
1 parent 766484f commit 103e6a9
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 10 deletions.
5 changes: 4 additions & 1 deletion pkg/controller/mysqlbackup/internal/syncer/deletionjob.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
"github.com/presslabs/mysql-operator/pkg/internal/mysqlbackup"
"github.com/presslabs/mysql-operator/pkg/internal/mysqlcluster"
"github.com/presslabs/mysql-operator/pkg/options"
"github.com/presslabs/mysql-operator/pkg/util/constants"
)

const (
Expand Down Expand Up @@ -154,7 +155,9 @@ func (s *deletionJobSyncer) ensureContainers() []core.Container {
Image: s.opt.SidecarImage,
ImagePullPolicy: s.opt.ImagePullPolicy,
Args: []string{
"rclone", "--config=/etc/rclone.conf", "delete",
"rclone",
constants.RcloneConfigArg,
"delete",
bucketForRclone(s.backup.Spec.BackupURL),
},
EnvFrom: []core.EnvFromSource{
Expand Down
3 changes: 1 addition & 2 deletions pkg/sidecar/appclone.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ func cloneFromBucket(initBucket string) error {
// rclone --config={conf file} cat {bucket uri}
// writes to stdout the content of the bucket uri
// nolint: gosec
rclone := exec.Command("rclone", "-vv",
fmt.Sprintf("--config=%s", rcloneConfigFile), "cat", initBucket)
rclone := exec.Command("rclone", "-vv", rcloneConfigArg, "cat", initBucket)

// gzip reads from stdin decompress and then writes to stdout
// nolint: gosec
Expand Down
6 changes: 2 additions & 4 deletions pkg/sidecar/apptakebackup.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ func pushBackupFromTo(cfg *Config, srcHost, destBucket string) error {
gzip := exec.Command("gzip", "-c")

// nolint: gosec
rclone := exec.Command("rclone",
fmt.Sprintf("--config=%s", rcloneConfigFile), "rcat", tmpDestBucket)
rclone := exec.Command("rclone", rcloneConfigArg, "rcat", tmpDestBucket)

gzip.Stdin = response.Body
gzip.Stderr = os.Stderr
Expand Down Expand Up @@ -83,8 +82,7 @@ func pushBackupFromTo(cfg *Config, srcHost, destBucket string) error {
// the backup was a success
// remove .tmp extension
// nolint: gosec
rcMove := exec.Command("rclone",
fmt.Sprintf("--config=%s", rcloneConfigFile), "moveto", tmpDestBucket, destBucket)
rcMove := exec.Command("rclone", rcloneConfigArg, "moveto", tmpDestBucket, destBucket)

if err = rcMove.Start(); err != nil {
return fmt.Errorf("final move failed: %s", err)
Expand Down
7 changes: 4 additions & 3 deletions pkg/sidecar/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,9 @@ var (
)

const (
// RcloneConfigFile represents the path to the file that contains rclon
// RcloneConfigFile represents the path to the file that contains rclone
// configs. This path should be the same as defined in docker entrypoint
// script from mysql-operator-sidecar/docker-entrypoint.sh. /etc/rclone.conf
rcloneConfigFile = "/tmp/rclone.conf"
// script from mysql-operator-sidecar/docker-entrypoint.sh. /tmp/rclone.conf
rcloneConfigFile = constants.RcloneConfigFile
rcloneConfigArg = constants.RcloneConfigArg
)
8 changes: 8 additions & 0 deletions pkg/util/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ const (
// ConfHeartBeatPath the path where to put the heartbeat.conf file
// it's important to have a different extension than .cnf to be ignore by MySQL include
ConfHeartBeatPath = "/etc/mysql/heartbeat.conf"

// RcloneConfigFile represents the path to the file that contains rclone
// configs. This path should be the same as defined in docker entrypoint
// script from mysql-operator-sidecar/docker-entrypoint.sh. /tmp/rclone.conf
RcloneConfigFile = "/tmp/rclone.conf"

// RcloneConfigArg represents the config argument to rclone cmd
RcloneConfigArg = "--config=" + RcloneConfigFile
)

var (
Expand Down

0 comments on commit 103e6a9

Please sign in to comment.