Skip to content

Commit

Permalink
Ensure that binary logs for PITR are restored to a shared location
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Lord <mattalord@gmail.com>
  • Loading branch information
mattlord committed Mar 13, 2024
1 parent 2daf6c7 commit 1824f91
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
3 changes: 2 additions & 1 deletion pkg/operator/vttablet/mysqlctld.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const (
vtRootInitScript = `set -ex
mkdir -p /mnt/vt/bin
cp --no-clobber /vt/bin/mysqlctld /mnt/vt/bin/
cp --no-clobber $(command -v mysqlbinlog) /mnt/vt/bin/ || true
mkdir -p /mnt/vt/config
if [[ -d /vt/config/mycnf ]]; then
cp --no-clobber -R /vt/config/mycnf /mnt/vt/config/
Expand Down Expand Up @@ -68,7 +69,7 @@ func init() {

securityContext := &corev1.SecurityContext{}
if planetscalev2.DefaultVitessRunAsUser >= 0 {
securityContext.RunAsUser = pointer.Int64Ptr(planetscalev2.DefaultVitessRunAsUser)
securityContext.RunAsUser = pointer.Int64(planetscalev2.DefaultVitessRunAsUser)
}

// Use an init container to copy only the files we need from the Vitess image.
Expand Down
6 changes: 6 additions & 0 deletions pkg/operator/vttablet/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,12 @@ func UpdatePod(obj *corev1.Pod, spec *Spec) {
var mysqldExporterContainer *corev1.Container

mysqlctldAllFlags := mysqlctldFlags.Get(spec)
// Ensure that binary logs are restored to/from a location that all containers
// in the pod can access if no location was explicitly provided.
mysqlctldAllFlags["builtinbackup-incremental-restore-path"] = vtRootPath
if _, ok := mysqlctldAllFlags["builtinbackup-incremental-restore-path"]; !ok {
mysqlctldAllFlags["builtinbackup-incremental-restore-path"] = vtMysqlRootPath
}
mysql.UpdateMySQLServerVersion(mysqlctldAllFlags, spec.Images.Mysqld.Image())

if spec.Mysqld != nil {
Expand Down
10 changes: 8 additions & 2 deletions pkg/operator/vttablet/vtbackup_pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,18 +122,24 @@ func NewBackupPod(key client.ObjectKey, backupSpec *BackupSpec, mysqldImage stri

podSecurityContext := &corev1.PodSecurityContext{}
if planetscalev2.DefaultVitessFSGroup >= 0 {
podSecurityContext.FSGroup = pointer.Int64Ptr(planetscalev2.DefaultVitessFSGroup)
podSecurityContext.FSGroup = pointer.Int64(planetscalev2.DefaultVitessFSGroup)
}
securityContext := &corev1.SecurityContext{}
if planetscalev2.DefaultVitessRunAsUser >= 0 {
securityContext.RunAsUser = pointer.Int64Ptr(planetscalev2.DefaultVitessRunAsUser)
securityContext.RunAsUser = pointer.Int64(planetscalev2.DefaultVitessRunAsUser)
}

var containerResources corev1.ResourceRequirements
// Make a copy of Resources since it contains pointers.
update.ResourceRequirements(&containerResources, &tabletSpec.Mysqld.Resources)

vtbackupAllFlags := vtbackupFlags.Get(backupSpec)
// Ensure that binary logs are restored to/from a location that all containers
// in the pod can access if no location was explicitly provided.
if _, ok := vtbackupAllFlags["builtinbackup-incremental-restore-path"]; !ok {
vtbackupAllFlags["builtinbackup-incremental-restore-path"] = vtMysqlRootPath
}
vtbackupAllFlags["builtinbackup-incremental-restore-path"] = vtRootPath
mysql.UpdateMySQLServerVersion(vtbackupAllFlags, mysqldImage)
pod := &corev1.Pod{
ObjectMeta: metav1.ObjectMeta{
Expand Down

0 comments on commit 1824f91

Please sign in to comment.