Skip to content

Commit d259730

Browse files
committed
Ensure that binary logs for PITR are restored to a shared location
Signed-off-by: Matt Lord <[email protected]>
1 parent 2daf6c7 commit d259730

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

pkg/operator/vttablet/mysqlctld.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const (
2929
vtRootInitScript = `set -ex
3030
mkdir -p /mnt/vt/bin
3131
cp --no-clobber /vt/bin/mysqlctld /mnt/vt/bin/
32+
cp --no-clobber $(command -v mysqlbinlog) /mnt/vt/bin/ || true
3233
mkdir -p /mnt/vt/config
3334
if [[ -d /vt/config/mycnf ]]; then
3435
cp --no-clobber -R /vt/config/mycnf /mnt/vt/config/
@@ -68,7 +69,7 @@ func init() {
6869

6970
securityContext := &corev1.SecurityContext{}
7071
if planetscalev2.DefaultVitessRunAsUser >= 0 {
71-
securityContext.RunAsUser = pointer.Int64Ptr(planetscalev2.DefaultVitessRunAsUser)
72+
securityContext.RunAsUser = pointer.Int64(planetscalev2.DefaultVitessRunAsUser)
7273
}
7374

7475
// Use an init container to copy only the files we need from the Vitess image.

pkg/operator/vttablet/pod.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,11 @@ func UpdatePod(obj *corev1.Pod, spec *Spec) {
168168
var mysqldExporterContainer *corev1.Container
169169

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

173178
if spec.Mysqld != nil {

pkg/operator/vttablet/vtbackup_pod.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,18 +122,23 @@ func NewBackupPod(key client.ObjectKey, backupSpec *BackupSpec, mysqldImage stri
122122

123123
podSecurityContext := &corev1.PodSecurityContext{}
124124
if planetscalev2.DefaultVitessFSGroup >= 0 {
125-
podSecurityContext.FSGroup = pointer.Int64Ptr(planetscalev2.DefaultVitessFSGroup)
125+
podSecurityContext.FSGroup = pointer.Int64(planetscalev2.DefaultVitessFSGroup)
126126
}
127127
securityContext := &corev1.SecurityContext{}
128128
if planetscalev2.DefaultVitessRunAsUser >= 0 {
129-
securityContext.RunAsUser = pointer.Int64Ptr(planetscalev2.DefaultVitessRunAsUser)
129+
securityContext.RunAsUser = pointer.Int64(planetscalev2.DefaultVitessRunAsUser)
130130
}
131131

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

136136
vtbackupAllFlags := vtbackupFlags.Get(backupSpec)
137+
// Ensure that binary logs are restored to/from a location that all containers
138+
// in the pod can access if no location was explicitly provided.
139+
if _, ok := vtbackupAllFlags["builtinbackup-incremental-restore-path"]; !ok {
140+
vtbackupAllFlags["builtinbackup-incremental-restore-path"] = vtDataRootPath
141+
}
137142
mysql.UpdateMySQLServerVersion(vtbackupAllFlags, mysqldImage)
138143
pod := &corev1.Pod{
139144
ObjectMeta: metav1.ObjectMeta{

0 commit comments

Comments
 (0)