Skip to content

Commit

Permalink
attach to tc
Browse files Browse the repository at this point in the history
  • Loading branch information
RidRisR committed Dec 4, 2024
1 parent 8f81357 commit bf9b185
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 25 deletions.
12 changes: 4 additions & 8 deletions pkg/apis/pingcap/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -3447,7 +3447,7 @@ type CompactBackup struct {
Status CompactStatus `json:"status,omitempty"`
}

// BackupSpec contains the backup specification for a tidb cluster.
// CompactSpec contains the backup specification for a tidb cluster.
// +k8s:openapi-gen=true
type CompactSpec struct {
corev1.ResourceRequirements `json:"resources,omitempty"`
Expand Down Expand Up @@ -3498,17 +3498,13 @@ type CompactSpec struct {
// Base tolerations of backup Pods, components may add more tolerations upon this respectively
// +optional
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`
// Version specifies the tool image version used in compact `Backup`.
Version string `json:"version,omitempty"`
// BrImage specifies the br image used in compact `Backup`.
// For examples `spec.brImage: pingcap/br:v4.0.8`
// For BR image, if it does not contain tag, Pod will use image 'BrImage:${TiKV_Version}'.
// +optional
BrImage string `json:"brImage,omitempty"`
// TiKVImage specifies the tikv image used in compact `Backup`.
// For examples `spec.tikvImage: pingcap/tikv:v4.0.8`
// +optional
TiKVImage string `json:"tikvImage,omitempty"`
ToolImage string `json:"brImage,omitempty"`
// BRConfig is the configs for BR
BR *BRConfig `json:"br,omitempty"`
// ImagePullSecrets is an optional list of references to secrets in the same namespace to use for pulling any of the images.
// +optional
ImagePullSecrets []corev1.LocalObjectReference `json:"imagePullSecrets,omitempty"`
Expand Down
29 changes: 12 additions & 17 deletions pkg/controller/compactbackup/compact_backup_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,28 +301,23 @@ func (c *Controller) makeBackupJob(backup *v1alpha1.CompactBackup) (*batchv1.Job
fmt.Sprintf("--resourceName=%s", name),
}

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

tikvVersion := backup.Spec.Version
_, imageVersion := backuputil.ParseImage(tikvImage)
if imageVersion != "" {
tikvVersion = imageVersion
tc, err := c.deps.TiDBClusterLister.TidbClusters(ns).Get(backup.Spec.BR.Cluster)
if err != nil {
return nil, fmt.Sprintf("failed to fetch tidbcluster %s/%s", ns, backup.Spec.BR.Cluster), err
}
tikvImage := tc.TiKVImage()
_, tikvVersion := backuputil.ParseImage(tikvImage)
if tikvVersion != "" {
args = append(args, fmt.Sprintf("--tikvVersion=%s", tikvVersion))
} else {
return nil, "tikv version is empty", fmt.Errorf("tikv version is empty")
}

brImage := fmt.Sprintf("pingcap/br:%s", tikvVersion)
if backup.Spec.BrImage != "" {
brImage = backup.Spec.BrImage
if !strings.ContainsRune(brImage, ':') {
brImage = fmt.Sprintf("%s:%s", brImage, tikvVersion)
brImage := "pingcap/br:" + tikvVersion
if backup.Spec.ToolImage != "" {
toolImage := backup.Spec.ToolImage
if !strings.ContainsRune(backup.Spec.ToolImage, ':') {
toolImage = fmt.Sprintf("%s:%s", toolImage, tikvVersion)
}

brImage = toolImage
}

//TODO: (Ris)What is the instance here?
Expand Down

0 comments on commit bf9b185

Please sign in to comment.