Skip to content

Commit 2008e1e

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 2008e1e

File tree

9 files changed

+84
-0
lines changed

9 files changed

+84
-0
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/vtbackup_pod.go

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

1919
import (
2020
"strconv"
21+
"strings"
2122
"time"
2223

2324
corev1 "k8s.io/api/core/v1"
@@ -134,6 +135,11 @@ func NewBackupPod(key client.ObjectKey, backupSpec *BackupSpec, mysqldImage stri
134135
update.ResourceRequirements(&containerResources, &tabletSpec.Mysqld.Resources)
135136

136137
vtbackupAllFlags := vtbackupFlags.Get(backupSpec)
138+
// Merge vtbackup-specific extra flags only.
139+
for key, value := range tabletSpec.Vttablet.VtbackupExtraFlags {
140+
key = strings.TrimLeft(key, "-")
141+
vtbackupAllFlags[key] = value
142+
}
137143
mysql.UpdateMySQLServerVersion(vtbackupAllFlags, mysqldImage)
138144
pod := &corev1.Pod{
139145
ObjectMeta: metav1.ObjectMeta{
@@ -184,6 +190,18 @@ func NewBackupPod(key client.ObjectKey, backupSpec *BackupSpec, mysqldImage stri
184190
},
185191
}
186192

193+
// Allow user-provided extra volumes and mounts to be applied last.
194+
update.Volumes(&pod.Spec.Volumes, tabletSpec.ExtraVolumes)
195+
update.VolumeMounts(&volumeMounts, tabletSpec.ExtraVolumeMounts)
196+
197+
// Apply the updated volume mounts to the vtbackup container
198+
for i := range pod.Spec.Containers {
199+
if pod.Spec.Containers[i].Name == vtbackupContainerName {
200+
pod.Spec.Containers[i].VolumeMounts = volumeMounts
201+
break
202+
}
203+
}
204+
187205
if planetscalev2.DefaultVitessServiceAccount != "" {
188206
pod.Spec.ServiceAccountName = planetscalev2.DefaultVitessServiceAccount
189207
}

0 commit comments

Comments
 (0)