Skip to content

Commit f9b8dc4

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

File tree

13 files changed

+186
-1
lines changed

13 files changed

+186
-1
lines changed

deploy/crds/planetscale.com_vitessclusters.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2197,6 +2197,10 @@ spec:
21972197
terminationGracePeriodSeconds:
21982198
format: int64
21992199
type: integer
2200+
vtbackupExtraFlags:
2201+
additionalProperties:
2202+
type: string
2203+
type: object
22002204
required:
22012205
- resources
22022206
type: object
@@ -2663,6 +2667,10 @@ spec:
26632667
terminationGracePeriodSeconds:
26642668
format: int64
26652669
type: integer
2670+
vtbackupExtraFlags:
2671+
additionalProperties:
2672+
type: string
2673+
type: object
26662674
required:
26672675
- resources
26682676
type: object

deploy/crds/planetscale.com_vitesskeyspaces.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,10 @@ spec:
673673
terminationGracePeriodSeconds:
674674
format: int64
675675
type: integer
676+
vtbackupExtraFlags:
677+
additionalProperties:
678+
type: string
679+
type: object
676680
required:
677681
- resources
678682
type: object
@@ -1139,6 +1143,10 @@ spec:
11391143
terminationGracePeriodSeconds:
11401144
format: int64
11411145
type: integer
1146+
vtbackupExtraFlags:
1147+
additionalProperties:
1148+
type: string
1149+
type: object
11421150
required:
11431151
- resources
11441152
type: object

deploy/crds/planetscale.com_vitessshards.yaml

Lines changed: 4 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

docs/api.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8822,6 +8822,21 @@ set the string value to either &ldquo;true&rdquo; or &ldquo;false&rdquo;.</p>
88228822
</tr>
88238823
<tr>
88248824
<td>
8825+
<code>vtbackupExtraFlags</code><br>
8826+
<em>
8827+
map[string]string
8828+
</em>
8829+
</td>
8830+
<td>
8831+
<p>VtbackupExtraFlags can optionally be used to pass additional flags only to vtbackup.
8832+
Use this to avoid sending vttablet-only flags to vtbackup, which may not support them.
8833+
All entries must be key-value string pairs of the form &ldquo;flag&rdquo;: &ldquo;value&rdquo;. The flag name should
8834+
not have any prefix (just &ldquo;flag&rdquo;, not &ldquo;-flag&rdquo;). To set a boolean flag, set the string value
8835+
to either &ldquo;true&rdquo; or &ldquo;false&rdquo;.</p>
8836+
</td>
8837+
</tr>
8838+
<tr>
8839+
<td>
88258840
<code>lifecycle</code><br>
88268841
<em>
88278842
<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
@@ -8824,6 +8824,21 @@ <h3 id="planetscale.com/v2.VttabletSpec">VttabletSpec
88248824
</tr>
88258825
<tr>
88268826
<td>
8827+
<code>vtbackupExtraFlags</code><br>
8828+
<em>
8829+
map[string]string
8830+
</em>
8831+
</td>
8832+
<td>
8833+
<p>VtbackupExtraFlags can optionally be used to pass additional flags only to vtbackup.
8834+
Use this to avoid sending vttablet-only flags to vtbackup, which may not support them.
8835+
All entries must be key-value string pairs of the form &ldquo;flag&rdquo;: &ldquo;value&rdquo;. The flag name should
8836+
not have any prefix (just &ldquo;flag&rdquo;, not &ldquo;-flag&rdquo;). To set a boolean flag, set the string value
8837+
to either &ldquo;true&rdquo; or &ldquo;false&rdquo;.</p>
8838+
</td>
8839+
</tr>
8840+
<tr>
8841+
<td>
88278842
<code>lifecycle</code><br>
88288843
<em>
88298844
<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)