From 39d0d7fcad07625a8e4f25516554fe50faeb7b45 Mon Sep 17 00:00:00 2001 From: Florent Poinsard Date: Thu, 29 Aug 2024 14:54:58 -0600 Subject: [PATCH] Allow for backups with the mysqlsh engine Signed-off-by: Florent Poinsard --- pkg/operator/vttablet/backup.go | 19 +++++++++++++------ pkg/operator/vttablet/constants.go | 3 +++ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/pkg/operator/vttablet/backup.go b/pkg/operator/vttablet/backup.go index 75a67c56..e5d3ab3e 100644 --- a/pkg/operator/vttablet/backup.go +++ b/pkg/operator/vttablet/backup.go @@ -26,7 +26,7 @@ import ( "planetscale.dev/vitess-operator/pkg/operator/vitessbackup" ) -func xtrabackupFlags(spec *Spec, backupThreads, restoreThreads int) vitess.Flags { +func xtrabackupFlags(backupThreads, restoreThreads int) vitess.Flags { flags := vitess.Flags{ "xtrabackup_user": xtrabackupUser, "xtrabackup_stream_mode": xtrabackupStreamMode, @@ -39,6 +39,15 @@ func xtrabackupFlags(spec *Spec, backupThreads, restoreThreads int) vitess.Flags return flags } +func mysqlshellFlags(backupLocation string) vitess.Flags { + flags := vitess.Flags{ + "mysql-shell-backup-location": backupLocation, + "mysql-shell-flags": mysqlshellExtraFlags, + } + + return flags +} + func init() { vttabletFlags.Add(func(s lazy.Spec) vitess.Flags { spec := s.(*Spec) @@ -68,12 +77,10 @@ func init() { if restoreThreads < 1 { restoreThreads = 1 } - flags.Merge(xtrabackupFlags(spec, backupThreads, restoreThreads)) + flags.Merge(xtrabackupFlags(backupThreads, restoreThreads)) case planetscalev2.VitessBackupEngineMySQLShell: svm := vitessbackup.StorageVolumeMounts(spec.BackupLocation) - flags.Merge(vitess.Flags{ - "mysql-shell-backup-location": svm[0].MountPath, - }) + flags.Merge(mysqlshellFlags(svm[0].MountPath)) } clusterName := spec.Labels[planetscalev2.ClusterLabel] storageLocationFlags := vitessbackup.StorageFlags(spec.BackupLocation, clusterName) @@ -99,7 +106,7 @@ func init() { if threads < 1 { threads = 1 } - flags.Merge(xtrabackupFlags(spec, threads, threads)) + flags.Merge(xtrabackupFlags(threads, threads)) } clusterName := spec.Labels[planetscalev2.ClusterLabel] storageLocationFlags := vitessbackup.StorageFlags(spec.BackupLocation, clusterName) diff --git a/pkg/operator/vttablet/constants.go b/pkg/operator/vttablet/constants.go index 388bf580..89824ba9 100644 --- a/pkg/operator/vttablet/constants.go +++ b/pkg/operator/vttablet/constants.go @@ -109,6 +109,9 @@ const ( xtrabackupStripeCount = 8 xtrabackupUser = "vt_dba" + mysqlshellUser = "vt_dba" + mysqlshellExtraFlags = "--defaults-file=/dev/null --no-password --js -u " + mysqlshellUser + " -S " + mysqlSocketPath + // mysqlctlWaitTime is how long mysqlctld will wait for mysqld to start up // before assuming it's stuck and trying to restart it. We set this fairly // high because it can take a while to do crash recovery and it's rarely