Skip to content

Commit f13aaaa

Browse files
authored
br: allow user to customize tikv image in compact (#6167)
1 parent d318c23 commit f13aaaa

File tree

7 files changed

+75
-18
lines changed

7 files changed

+75
-18
lines changed

docs/api-references/docs.md

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5324,9 +5324,23 @@ string
53245324
</td>
53255325
<td>
53265326
<em>(Optional)</em>
5327-
<p>BrImage specifies the br image used in compact <code>Backup</code>.
5328-
For examples <code>spec.brImage: pingcap/br:v4.0.8</code>
5329-
For BR image, if it does not contain tag, Pod will use image &lsquo;BrImage:${TiKV_Version}&rsquo;.</p>
5327+
<p>ToolImage specifies the br image used in compact <code>Backup</code>.
5328+
For examples <code>spec.toolImage: pingcap/br:v4.0.8</code>
5329+
For BR image, if it does not contain tag, Pod will use the same version in tc &lsquo;BrImage:${TiKV_Version}&rsquo;.</p>
5330+
</td>
5331+
</tr>
5332+
<tr>
5333+
<td>
5334+
<code>tikvImage</code></br>
5335+
<em>
5336+
string
5337+
</em>
5338+
</td>
5339+
<td>
5340+
<em>(Optional)</em>
5341+
<p>TikvImage specifies the tikv image used in compact <code>Backup</code>.
5342+
For examples <code>spec.tikvImage: pingcap/tikv:v9.0.0</code>
5343+
For TiKV image, if it does not contain tag, Pod will use the same version in tc &lsquo;TiKVImage:${TiKV_Version}&rsquo;.</p>
53305344
</td>
53315345
</tr>
53325346
<tr>
@@ -5665,9 +5679,23 @@ string
56655679
</td>
56665680
<td>
56675681
<em>(Optional)</em>
5668-
<p>BrImage specifies the br image used in compact <code>Backup</code>.
5669-
For examples <code>spec.brImage: pingcap/br:v4.0.8</code>
5670-
For BR image, if it does not contain tag, Pod will use image &lsquo;BrImage:${TiKV_Version}&rsquo;.</p>
5682+
<p>ToolImage specifies the br image used in compact <code>Backup</code>.
5683+
For examples <code>spec.toolImage: pingcap/br:v4.0.8</code>
5684+
For BR image, if it does not contain tag, Pod will use the same version in tc &lsquo;BrImage:${TiKV_Version}&rsquo;.</p>
5685+
</td>
5686+
</tr>
5687+
<tr>
5688+
<td>
5689+
<code>tikvImage</code></br>
5690+
<em>
5691+
string
5692+
</em>
5693+
</td>
5694+
<td>
5695+
<em>(Optional)</em>
5696+
<p>TikvImage specifies the tikv image used in compact <code>Backup</code>.
5697+
For examples <code>spec.tikvImage: pingcap/tikv:v9.0.0</code>
5698+
For TiKV image, if it does not contain tag, Pod will use the same version in tc &lsquo;TiKVImage:${TiKV_Version}&rsquo;.</p>
56715699
</td>
56725700
</tr>
56735701
<tr>

manifests/crd.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4470,6 +4470,8 @@ spec:
44704470
type: string
44714471
startTs:
44724472
type: string
4473+
tikvImage:
4474+
type: string
44734475
tolerations:
44744476
items:
44754477
properties:
@@ -12207,6 +12209,8 @@ spec:
1220712209
type: string
1220812210
startTs:
1220912211
type: string
12212+
tikvImage:
12213+
type: string
1221012214
tolerations:
1221112215
items:
1221212216
properties:

manifests/crd/v1/pingcap.com_backupschedules.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4470,6 +4470,8 @@ spec:
44704470
type: string
44714471
startTs:
44724472
type: string
4473+
tikvImage:
4474+
type: string
44734475
tolerations:
44744476
items:
44754477
properties:

manifests/crd/v1/pingcap.com_compactbackups.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2163,6 +2163,8 @@ spec:
21632163
type: string
21642164
startTs:
21652165
type: string
2166+
tikvImage:
2167+
type: string
21662168
tolerations:
21672169
items:
21682170
properties:

pkg/apis/pingcap/v1alpha1/openapi_generated.go

Lines changed: 8 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/apis/pingcap/v1alpha1/types.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3547,11 +3547,16 @@ type CompactSpec struct {
35473547
// Base tolerations of backup Pods, components may add more tolerations upon this respectively
35483548
// +optional
35493549
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`
3550-
// BrImage specifies the br image used in compact `Backup`.
3551-
// For examples `spec.brImage: pingcap/br:v4.0.8`
3552-
// For BR image, if it does not contain tag, Pod will use image 'BrImage:${TiKV_Version}'.
3550+
// ToolImage specifies the br image used in compact `Backup`.
3551+
// For examples `spec.toolImage: pingcap/br:v4.0.8`
3552+
// For BR image, if it does not contain tag, Pod will use the same version in tc 'BrImage:${TiKV_Version}'.
35533553
// +optional
35543554
ToolImage string `json:"toolImage,omitempty"`
3555+
// TikvImage specifies the tikv image used in compact `Backup`.
3556+
// For examples `spec.tikvImage: pingcap/tikv:v9.0.0`
3557+
// For TiKV image, if it does not contain tag, Pod will use the same version in tc 'TiKVImage:${TiKV_Version}'.
3558+
// +optional
3559+
TiKVImage string `json:"tikvImage,omitempty"`
35553560
// BRConfig is the configs for BR
35563561
// *** Note: This field should generally not be left empty, unless you are certain the BR config
35573562
// *** can be obtained from another source, such as a schedule CR.

pkg/controller/compactbackup/compact_backup_controller.go

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import (
1717
"context"
1818
"fmt"
1919
"math"
20-
"strings"
2120
"time"
2221

2322
"github.com/pingcap/errors"
@@ -355,15 +354,25 @@ func (c *Controller) makeCompactJob(compact *v1alpha1.CompactBackup) (*batchv1.J
355354
return nil, fmt.Sprintf("failed to fetch tidbcluster %s/%s", ns, compact.Spec.BR.Cluster), err
356355
}
357356
tikvImage := tc.TiKVImage()
358-
_, tikvVersion := backuputil.ParseImage(tikvImage)
359-
brImage := "pingcap/br:" + tikvVersion
357+
_, tcVersion := backuputil.ParseImage(tikvImage)
358+
brImage := "pingcap/br:" + tcVersion
360359
if compact.Spec.ToolImage != "" {
361-
toolImage := compact.Spec.ToolImage
362-
if !strings.ContainsRune(compact.Spec.ToolImage, ':') {
363-
toolImage = fmt.Sprintf("%s:%s", toolImage, tikvVersion)
360+
var brVersion string
361+
brImage, brVersion = backuputil.ParseImage(compact.Spec.ToolImage)
362+
if brVersion != "" {
363+
brImage = fmt.Sprintf("%s:%s", brImage, brVersion)
364+
} else {
365+
brImage = fmt.Sprintf("%s:%s", brImage, tcVersion)
366+
}
367+
}
368+
if compact.Spec.TiKVImage != "" {
369+
var tikvVersion string
370+
tikvImage, tikvVersion = backuputil.ParseImage(compact.Spec.TiKVImage)
371+
if tikvVersion != "" {
372+
tikvImage = fmt.Sprintf("%s:%s", tikvImage, tikvVersion)
373+
} else {
374+
tikvImage = fmt.Sprintf("%s:%s", tikvImage, tcVersion)
364375
}
365-
366-
brImage = toolImage
367376
}
368377
klog.Infof("Compact %s/%s use br image %s and tikv image %s", ns, name, brImage, tikvImage)
369378

0 commit comments

Comments
 (0)