Skip to content

Commit

Permalink
adapt backup-manager params
Browse files Browse the repository at this point in the history
  • Loading branch information
RidRisR committed Dec 4, 2024
1 parent b6faebd commit 8f81357
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 39 deletions.
4 changes: 2 additions & 2 deletions docs/api-references/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -5481,7 +5481,7 @@ string
</tr>
<tr>
<td>
<code>commitTs</code></br>
<code>startTs</code></br>
<em>
string
</em>
Expand Down Expand Up @@ -5847,7 +5847,7 @@ string
</tr>
<tr>
<td>
<code>commitTs</code></br>
<code>startTs</code></br>
<em>
string
</em>
Expand Down
4 changes: 2 additions & 2 deletions manifests/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8210,8 +8210,6 @@ spec:
type: object
brImage:
type: string
commitTs:
type: string
concurrency:
type: integer
endTs:
Expand Down Expand Up @@ -9193,6 +9191,8 @@ spec:
type: object
serviceAccount:
type: string
startTs:
type: string
storageClassName:
type: string
storageSize:
Expand Down
4 changes: 2 additions & 2 deletions manifests/crd/v1/pingcap.com_compactbackups.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1160,8 +1160,6 @@ spec:
type: object
brImage:
type: string
commitTs:
type: string
concurrency:
type: integer
endTs:
Expand Down Expand Up @@ -2143,6 +2141,8 @@ spec:
type: object
serviceAccount:
type: string
startTs:
type: string
storageClassName:
type: string
storageSize:
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/pingcap/v1alpha1/openapi_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/apis/pingcap/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -3483,7 +3483,7 @@ type CompactSpec struct {
StorageSize string `json:"storageSize,omitempty"`
// StartTs is the start ts of the compact backup.
// Format supports TSO or datetime, e.g. '400036290571534337', '2018-05-11 01:42:23'.
StartTs string `json:"commitTs,omitempty"`
StartTs string `json:"startTs,omitempty"`
// EndTs is the end ts of the compact backup.
// Format supports TSO or datetime, e.g. '400036290571534337', '2018-05-11 01:42:23'.
// Default is current timestamp.
Expand Down
41 changes: 10 additions & 31 deletions pkg/controller/compactbackup/compact_backup_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@ package compact
import (
"context"
"fmt"
"strconv"
"strings"
"time"

"github.com/pingcap/errors"
perrors "github.com/pingcap/errors"
"github.com/pingcap/tidb-operator/pkg/apis/label"
"github.com/pingcap/tidb-operator/pkg/apis/pingcap/v1alpha1"
"github.com/pingcap/tidb-operator/pkg/apis/util/config"
"github.com/pingcap/tidb-operator/pkg/backup/constants"
backuputil "github.com/pingcap/tidb-operator/pkg/backup/util"
"github.com/pingcap/tidb-operator/pkg/client/clientset/versioned"
Expand Down Expand Up @@ -302,29 +300,12 @@ func (c *Controller) makeBackupJob(backup *v1alpha1.CompactBackup) (*batchv1.Job
fmt.Sprintf("--namespace=%s", ns),
fmt.Sprintf("--resourceName=%s", name),
}
startTS, err := config.ParseTSString(backup.Spec.StartTs)
if err != nil {
return nil, fmt.Sprintf("failed to parse startTs(%v)", backup.Spec.StartTs), err
}
args = append(args, "--from-ts", strconv.FormatUint(startTS, 10))
endTS, err := config.ParseTSString(backup.Spec.EndTs)
if err != nil {
return nil, fmt.Sprintf("failed to parse endTs(%v)", backup.Spec.EndTs), err
}
args = append(args, "--until-ts", strconv.FormatUint(endTS, 10))
args = append(args, "--concurrency", backup.Spec.EndTs)
args = append(args, "--name", backup.GetObjectMeta().GetName())
strg, err := backuputil.GetStoragePath(backup.Spec.StorageProvider)
if err != nil {
return nil, fmt.Sprintf("failed to get storage path: %v", err), err
}
args = append(args, "--storage-string", strg)

tikvImage := "pingcap/tikv"
if backup.Spec.TiKVImage != "" {
tikvImage = backup.Spec.TiKVImage
}

tikvVersion := backup.Spec.Version
_, imageVersion := backuputil.ParseImage(tikvImage)
if imageVersion != "" {
Expand Down Expand Up @@ -404,29 +385,27 @@ func (c *Controller) makeBackupJob(backup *v1alpha1.CompactBackup) (*batchv1.Job
Command: []string{"/bin/sh", "-c"},
Args: []string{fmt.Sprintf("cp /br %s/br; echo 'BR copy finished'", util.BRBinPath)},
ImagePullPolicy: corev1.PullIfNotPresent,
VolumeMounts: volumeMounts,
Resources: backup.Spec.ResourceRequirements,
VolumeMounts: volumeMounts,
Resources: backup.Spec.ResourceRequirements,
},
{
Name: "tikv-ctl",
Image: tikvImage,
Command: []string{"/bin/sh", "-c"},
Args: []string{fmt.Sprintf("cp /tikv-ctl %s/tikv-ctl; echo 'tikv-ctl copy finished'", util.KVCTLBinPath)},
ImagePullPolicy: corev1.PullIfNotPresent,
VolumeMounts: volumeMounts,
Resources: backup.Spec.ResourceRequirements,
VolumeMounts: volumeMounts,
Resources: backup.Spec.ResourceRequirements,
},
},
Containers: []corev1.Container{
{
Name: "backup-manager",
Image: c.deps.CLIConfig.TiDBBackupManagerImage,
Command: []string{
"/bin/sh", "-c",
},
Args: args,
Env: envVars,
VolumeMounts: volumeMounts,
Image: c.deps.CLIConfig.TiDBBackupManagerImage,
Args: args,
Env: envVars,
VolumeMounts: volumeMounts,
ImagePullPolicy: corev1.PullAlways,
},
},
RestartPolicy: corev1.RestartPolicyNever,
Expand Down

0 comments on commit 8f81357

Please sign in to comment.