Skip to content

Commit 89242c4

Browse files
committed
add vtbackup extraflags support
Signed-off-by: Jeremy Doupe <[email protected]> Signed-off-by: Jeremy Doupe <[email protected]>
1 parent e7d6898 commit 89242c4

File tree

13 files changed

+189
-1
lines changed

13 files changed

+189
-1
lines changed

deploy/crds/planetscale.com_vitessclusters.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2115,6 +2115,10 @@ spec:
21152115
terminationGracePeriodSeconds:
21162116
format: int64
21172117
type: integer
2118+
vtbackupExtraFlags:
2119+
additionalProperties:
2120+
type: string
2121+
type: object
21182122
required:
21192123
- resources
21202124
type: object
@@ -2558,6 +2562,10 @@ spec:
25582562
terminationGracePeriodSeconds:
25592563
format: int64
25602564
type: integer
2565+
vtbackupExtraFlags:
2566+
additionalProperties:
2567+
type: string
2568+
type: object
25612569
required:
25622570
- resources
25632571
type: object

deploy/crds/planetscale.com_vitesskeyspaces.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,10 @@ spec:
656656
terminationGracePeriodSeconds:
657657
format: int64
658658
type: integer
659+
vtbackupExtraFlags:
660+
additionalProperties:
661+
type: string
662+
type: object
659663
required:
660664
- resources
661665
type: object
@@ -1099,6 +1103,10 @@ spec:
10991103
terminationGracePeriodSeconds:
11001104
format: int64
11011105
type: integer
1106+
vtbackupExtraFlags:
1107+
additionalProperties:
1108+
type: string
1109+
type: object
11021110
required:
11031111
- resources
11041112
type: object

deploy/crds/planetscale.com_vitessshards.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,10 @@ spec:
639639
terminationGracePeriodSeconds:
640640
format: int64
641641
type: integer
642+
vtbackupExtraFlags:
643+
additionalProperties:
644+
type: string
645+
type: object
642646
required:
643647
- resources
644648
type: object

docs/api.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8805,6 +8805,21 @@ set the string value to either &ldquo;true&rdquo; or &ldquo;false&rdquo;.</p>
88058805
</tr>
88068806
<tr>
88078807
<td>
8808+
<code>vtbackupExtraFlags</code><br>
8809+
<em>
8810+
map[string]string
8811+
</em>
8812+
</td>
8813+
<td>
8814+
<p>VtbackupExtraFlags can optionally be used to pass additional flags only to vtbackup.
8815+
Use this to avoid sending vttablet-only flags to vtbackup, which may not support them.
8816+
All entries must be key-value string pairs of the form &ldquo;flag&rdquo;: &ldquo;value&rdquo;. The flag name should
8817+
not have any prefix (just &ldquo;flag&rdquo;, not &ldquo;-flag&rdquo;). To set a boolean flag, set the string value
8818+
to either &ldquo;true&rdquo; or &ldquo;false&rdquo;.</p>
8819+
</td>
8820+
</tr>
8821+
<tr>
8822+
<td>
88088823
<code>lifecycle</code><br>
88098824
<em>
88108825
<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#lifecycle-v1-core">

docs/api/index.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8807,6 +8807,21 @@ <h3 id="planetscale.com/v2.VttabletSpec">VttabletSpec
88078807
</tr>
88088808
<tr>
88098809
<td>
8810+
<code>vtbackupExtraFlags</code><br>
8811+
<em>
8812+
map[string]string
8813+
</em>
8814+
</td>
8815+
<td>
8816+
<p>VtbackupExtraFlags can optionally be used to pass additional flags only to vtbackup.
8817+
Use this to avoid sending vttablet-only flags to vtbackup, which may not support them.
8818+
All entries must be key-value string pairs of the form &ldquo;flag&rdquo;: &ldquo;value&rdquo;. The flag name should
8819+
not have any prefix (just &ldquo;flag&rdquo;, not &ldquo;-flag&rdquo;). To set a boolean flag, set the string value
8820+
to either &ldquo;true&rdquo; or &ldquo;false&rdquo;.</p>
8821+
</td>
8822+
</tr>
8823+
<tr>
8824+
<td>
88108825
<code>lifecycle</code><br>
88118826
<em>
88128827
<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#lifecycle-v1-core">

pkg/apis/planetscale/v2/vitessshard_types.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,13 @@ type VttabletSpec struct {
291291
// set the string value to either "true" or "false".
292292
ExtraFlags map[string]string `json:"extraFlags,omitempty"`
293293

294+
// VtbackupExtraFlags can optionally be used to pass additional flags only to vtbackup.
295+
// Use this to avoid sending vttablet-only flags to vtbackup, which may not support them.
296+
// All entries must be key-value string pairs of the form "flag": "value". The flag name should
297+
// not have any prefix (just "flag", not "-flag"). To set a boolean flag, set the string value
298+
// to either "true" or "false".
299+
VtbackupExtraFlags map[string]string `json:"vtbackupExtraFlags,omitempty"`
300+
294301
// Lifecycle can optionally be used to add container lifecycle hooks
295302
// to vttablet container
296303
// +kubebuilder:validation:Schemaless

pkg/apis/planetscale/v2/zz_generated.deepcopy.go

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/controller/vitessshard/reconcile_backup_job.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,8 @@ func vtbackupSpec(key client.ObjectKey, vts *planetscalev2.VitessShard, parentLa
233233
InitContainers: pool.InitContainers,
234234
SidecarContainers: pool.SidecarContainers,
235235
ExtraEnv: pool.ExtraEnv,
236+
ExtraVolumes: pool.ExtraVolumes,
237+
ExtraVolumeMounts: pool.ExtraVolumeMounts,
236238
Annotations: annotations,
237239
Affinity: pool.Affinity,
238240
Tolerations: pool.Tolerations,

pkg/operator/vttablet/backup.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package vttablet
1818

1919
import (
2020
"fmt"
21+
"strings"
2122

2223
corev1 "k8s.io/api/core/v1"
2324
planetscalev2 "planetscale.dev/vitess-operator/pkg/apis/planetscale/v2"
@@ -108,6 +109,12 @@ func init() {
108109
}
109110
flags.Merge(xtrabackupFlags(threads, threads))
110111
}
112+
vtbackupExtraFlags := make(vitess.Flags)
113+
for key, value := range spec.Vttablet.VtbackupExtraFlags {
114+
key = strings.TrimLeft(key, "-")
115+
vtbackupExtraFlags[key] = value
116+
}
117+
flags.Merge(vtbackupExtraFlags)
111118
clusterName := spec.Labels[planetscalev2.ClusterLabel]
112119
storageLocationFlags := vitessbackup.StorageFlags(spec.BackupLocation, clusterName)
113120
return flags.Merge(storageLocationFlags)

pkg/operator/vttablet/vtbackup_pod.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ func NewBackupPod(key client.ObjectKey, backupSpec *BackupSpec, mysqldImage stri
119119
volumeMounts = append(volumeMounts, mysqldVolumeMounts.Get(tabletSpec)...)
120120
volumeMounts = append(volumeMounts, tabletVolumeMounts.Get(tabletSpec)...)
121121
volumeMounts = append(volumeMounts, vttabletVolumeMounts.Get(tabletSpec)...)
122+
update.VolumeMounts(&volumeMounts, tabletSpec.ExtraVolumeMounts)
123+
124+
volumes := tabletVolumes.Get(tabletSpec)
125+
update.Volumes(&volumes, tabletSpec.ExtraVolumes)
122126

123127
podSecurityContext := &corev1.PodSecurityContext{}
124128
if planetscalev2.DefaultVitessFSGroup >= 0 {
@@ -145,7 +149,7 @@ func NewBackupPod(key client.ObjectKey, backupSpec *BackupSpec, mysqldImage stri
145149
Spec: corev1.PodSpec{
146150
ImagePullSecrets: tabletSpec.ImagePullSecrets,
147151
RestartPolicy: corev1.RestartPolicyOnFailure,
148-
Volumes: tabletVolumes.Get(tabletSpec),
152+
Volumes: volumes,
149153
SecurityContext: podSecurityContext,
150154
Affinity: tabletSpec.Affinity,
151155
Tolerations: tabletSpec.Tolerations,

0 commit comments

Comments
 (0)