Skip to content

Commit 093ab5e

Browse files
authored
Clean unused BR code on operator v2 (#6084)
1 parent cde7f8a commit 093ab5e

20 files changed

+8
-3378
lines changed

api/br/v1alpha1/backup.go

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -291,58 +291,6 @@ func IsBackupPrepared(backup *Backup) bool {
291291
return condition != nil && condition.Status == metav1.ConditionTrue
292292
}
293293

294-
// IsVolumeBackupInitialized returns true if volume backup is initialized
295-
func IsVolumeBackupInitialized(backup *Backup) bool {
296-
if backup.Spec.Mode != BackupModeVolumeSnapshot {
297-
return false
298-
}
299-
_, condition := GetBackupCondition(&backup.Status, VolumeBackupInitialized)
300-
return condition != nil && condition.Status == metav1.ConditionTrue
301-
}
302-
303-
// IsVolumeBackupInitializeFailed returns true if volume backup is initialized failed
304-
func IsVolumeBackupInitializeFailed(backup *Backup) bool {
305-
if backup.Spec.Mode != BackupModeVolumeSnapshot {
306-
return false
307-
}
308-
_, condition := GetBackupCondition(&backup.Status, VolumeBackupInitializeFailed)
309-
return condition != nil && condition.Status == metav1.ConditionTrue
310-
}
311-
312-
func IsVolumeBackupSnapshotsCreated(backup *Backup) bool {
313-
if backup.Spec.Mode != BackupModeVolumeSnapshot {
314-
return false
315-
}
316-
_, condition := GetBackupCondition(&backup.Status, VolumeBackupSnapshotsCreated)
317-
return condition != nil && condition.Status == metav1.ConditionTrue
318-
}
319-
320-
func IsVolumeBackupInitializeComplete(backup *Backup) bool {
321-
if backup.Spec.Mode != BackupModeVolumeSnapshot {
322-
return false
323-
}
324-
_, condition := GetBackupCondition(&backup.Status, VolumeBackupInitializeComplete)
325-
return condition != nil && condition.Status == metav1.ConditionTrue
326-
}
327-
328-
// IsVolumeBackupComplete returns true if volume backup is complete
329-
func IsVolumeBackupComplete(backup *Backup) bool {
330-
if backup.Spec.Mode != BackupModeVolumeSnapshot {
331-
return false
332-
}
333-
_, condition := GetBackupCondition(&backup.Status, VolumeBackupComplete)
334-
return condition != nil && condition.Status == metav1.ConditionTrue
335-
}
336-
337-
// IsVolumeBackupFailed returns true if volume backup is failed
338-
func IsVolumeBackupFailed(backup *Backup) bool {
339-
if backup.Spec.Mode != BackupModeVolumeSnapshot {
340-
return false
341-
}
342-
_, condition := GetBackupCondition(&backup.Status, VolumeBackupFailed)
343-
return condition != nil && condition.Status == metav1.ConditionTrue
344-
}
345-
346294
// IsBackupClean returns true if a Backup has been successfully cleaned up
347295
func IsBackupClean(backup *Backup) bool {
348296
// TODO: now we don't handle fault state, maybe we should consider it in the future
@@ -469,7 +417,6 @@ func IsLogBackupAlreadyStart(backup *Backup) bool {
469417
return backup.Spec.Mode == BackupModeLog && backup.Status.CommitTs != ""
470418
}
471419

472-
// TODO(ideascf): do we need theses functions?
473420
// IsLogBackupAlreadyTruncate return whether log backup has already truncated.
474421
func IsLogBackupAlreadyTruncate(backup *Backup) bool {
475422
if backup.Spec.Mode != BackupModeLog {

api/br/v1alpha1/backup_types.go

Lines changed: 0 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import (
3131
// +kubebuilder:printcolumn:name="Status",type=string,JSONPath=`.status.phase`,description="The current status of the backup"
3232
// +kubebuilder:printcolumn:name="BackupPath",type=string,JSONPath=`.status.backupPath`,description="The full path of backup data"
3333
// +kubebuilder:printcolumn:name="BackupSize",type=string,JSONPath=`.status.backupSizeReadable`,description="The data size of the backup"
34-
// +kubebuilder:printcolumn:name="IncrementalBackupSize",type=string,JSONPath=`.status.incrementalBackupSizeReadable`,description="The real size of volume snapshot backup, only valid to volume snapshot backup",priority=10
3534
// +kubebuilder:printcolumn:name="CommitTS",type=string,JSONPath=`.status.commitTs`,description="The commit ts of the backup"
3635
// +kubebuilder:printcolumn:name="LogTruncateUntil",type=string,JSONPath=`.status.logSuccessTruncateUntil`,description="The log backup truncate until ts"
3736
// +kubebuilder:printcolumn:name="Started",type=date,JSONPath=`.status.timeStarted`,description="The time at which the backup was started",priority=1
@@ -209,27 +208,8 @@ const (
209208
BackupModeSnapshot BackupMode = "snapshot"
210209
// BackupModeLog represents the log backup of tidb cluster.
211210
BackupModeLog BackupMode = "log"
212-
// BackupModeVolumeSnapshot represents volume backup of tidb cluster.
213-
BackupModeVolumeSnapshot BackupMode = "volume-snapshot"
214211
)
215212

216-
// TiDBAccessConfig defines the configuration for access tidb cluster
217-
// +k8s:openapi-gen=true
218-
type TiDBAccessConfig struct {
219-
// Host is the tidb cluster access address
220-
Host string `json:"host"`
221-
// Port is the port number to use for connecting tidb cluster
222-
Port int32 `json:"port,omitempty"`
223-
// User is the user for login tidb cluster
224-
User string `json:"user,omitempty"`
225-
// SecretName is the name of secret which stores tidb cluster's password.
226-
SecretName string `json:"secretName"`
227-
// TLSClientSecretName is the name of secret which stores tidb server client certificate
228-
// Optional: Defaults to nil
229-
// +optional
230-
TLSClientSecretName *string `json:"tlsClientSecretName,omitempty"`
231-
}
232-
233213
// +k8s:openapi-gen=true
234214
// CleanPolicyType represents the clean policy of backup data in remote storage
235215
type CleanPolicyType string
@@ -273,11 +253,6 @@ type CleanOption struct {
273253
BackoffEnabled bool `json:"backoffEnabled,omitempty"`
274254

275255
BatchDeleteOption `json:",inline"`
276-
277-
// TODO(ideascf): remove this field, EBS volume snapshot backup is deprecated in v2
278-
// SnapshotsDeleteRatio represents the number of snapshots deleted per second
279-
// +kubebuilder:default=1
280-
// SnapshotsDeleteRatio float64 `json:"snapshotsDeleteRatio,omitempty"`
281256
}
282257

283258
type Progress struct {
@@ -315,9 +290,6 @@ type BackupSpec struct {
315290
// - BR_LOG_TO_TERM
316291
// +optional
317292
Env []corev1.EnvVar `json:"env,omitempty"`
318-
// TODO(ideascf): remove it in v2
319-
// From is the tidb cluster that needs to backup.
320-
From *TiDBAccessConfig `json:"from,omitempty"`
321293
// Type is the backup type for tidb cluster and only used when Mode = snapshot, such as full, db, table.
322294
Type BackupType `json:"backupType,omitempty"`
323295
// Mode is the backup mode, such as snapshot backup or log backup.
@@ -357,19 +329,6 @@ type BackupSpec struct {
357329
// LogStop indicates that will stop the log backup.
358330
// +optional
359331
LogStop bool `json:"logStop,omitempty"`
360-
// CalcSizeLevel determines how to size calculation of snapshots for EBS volume snapshot backup
361-
// +optional
362-
// +kubebuilder:default="all"
363-
CalcSizeLevel string `json:"calcSizeLevel,omitempty"`
364-
// FederalVolumeBackupPhase indicates which phase to execute in federal volume backup
365-
// +optional
366-
FederalVolumeBackupPhase FederalVolumeBackupPhase `json:"federalVolumeBackupPhase,omitempty"`
367-
// ResumeGcSchedule indicates whether resume gc and pd scheduler for EBS volume snapshot backup
368-
// +optional
369-
ResumeGcSchedule bool `json:"resumeGcSchedule,omitempty"`
370-
// TODO(ideascf): remove it in v2
371-
// DumplingConfig is the configs for dumpling
372-
Dumpling *DumplingConfig `json:"dumpling,omitempty"`
373332
// Base tolerations of backup Pods, components may add more tolerations upon this respectively
374333
// +optional
375334
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`
@@ -418,27 +377,6 @@ type BackupSpec struct {
418377
VolumeBackupInitJobMaxActiveSeconds int `json:"volumeBackupInitJobMaxActiveSeconds,omitempty"`
419378
}
420379

421-
// FederalVolumeBackupPhase represents a phase to execute in federal volume backup
422-
type FederalVolumeBackupPhase string
423-
424-
const (
425-
// FederalVolumeBackupInitialize means we should stop GC and PD schedule
426-
FederalVolumeBackupInitialize FederalVolumeBackupPhase = "initialize"
427-
// FederalVolumeBackupExecute means we should take volume snapshots for TiKV
428-
FederalVolumeBackupExecute FederalVolumeBackupPhase = "execute"
429-
// FederalVolumeBackupTeardown means we should resume GC and PD schedule
430-
FederalVolumeBackupTeardown FederalVolumeBackupPhase = "teardown"
431-
)
432-
433-
// +k8s:openapi-gen=true
434-
// DumplingConfig contains config for dumpling
435-
type DumplingConfig struct {
436-
// Options means options for backup data to remote storage with dumpling.
437-
Options []string `json:"options,omitempty"`
438-
// Deprecated. Please use `Spec.TableFilter` instead. TableFilter means Table filter expression for 'db.table' matching
439-
TableFilter []string `json:"tableFilter,omitempty"`
440-
}
441-
442380
// +k8s:openapi-gen=true
443381
// BRConfig contains config for BR
444382
type BRConfig struct {
@@ -543,32 +481,13 @@ const (
543481
BackupStopped BackupConditionType = "Stopped"
544482
// BackupRestart means the backup was restarted, now just support snapshot backup
545483
BackupRestart BackupConditionType = "Restart"
546-
// VolumeBackupInitialized means the volume backup has stopped GC and PD scheduler
547-
VolumeBackupInitialized BackupConditionType = "VolumeBackupInitialized"
548-
// VolumeBackupInitializeFailed means the volume backup initialize job failed
549-
VolumeBackupInitializeFailed BackupConditionType = "VolumeBackupInitializeFailed"
550-
// VolumeBackupSnapshotsCreated means the local volume snapshots created, and they won't be changed
551-
VolumeBackupSnapshotsCreated BackupConditionType = "VolumeBackupSnapshotsCreated"
552-
// VolumeBackupInitializeComplete means the volume backup has safely resumed GC and PD scheduler
553-
VolumeBackupInitializeComplete BackupConditionType = "VolumeBackupInitializeComplete"
554-
// VolumeBackupComplete means the volume backup has taken volume snapshots successfully
555-
VolumeBackupComplete BackupConditionType = "VolumeBackupComplete"
556-
// VolumeBackupFailed means the volume backup take volume snapshots failed
557-
VolumeBackupFailed BackupConditionType = "VolumeBackupFailed"
558484
)
559485

560486
// BackupCondition describes the observed state of a Backup at a certain point.
561487
type BackupCondition struct {
562488
Command LogSubCommandType `json:"command,omitempty"`
563489

564490
metav1.Condition `json:",inline"`
565-
// TODO(ideascf): remove these fields
566-
// Type BackupConditionType `json:"type"`
567-
// Status corev1.ConditionStatus `json:"status"`
568-
// // +nullable
569-
// LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty"`
570-
// Reason string `json:"reason,omitempty"`
571-
// Message string `json:"message,omitempty"`
572491
}
573492

574493
// LogSubCommandType is the log backup subcommand type.
@@ -628,11 +547,6 @@ type BackupStatus struct {
628547
BackupSizeReadable string `json:"backupSizeReadable,omitempty"`
629548
// BackupSize is the data size of the backup.
630549
BackupSize int64 `json:"backupSize,omitempty"`
631-
// the difference with IncrementalBackupSize is that its format is human readable
632-
IncrementalBackupSizeReadable string `json:"incrementalBackupSizeReadable,omitempty"`
633-
// IncrementalBackupSize is the incremental data size of the backup, it is only used for volume snapshot backup
634-
// it is the real size of volume snapshot backup
635-
IncrementalBackupSize int64 `json:"incrementalBackupSize,omitempty"`
636550
// CommitTs is the commit ts of the backup, snapshot ts for full backup or start ts for log backup.
637551
CommitTs string `json:"commitTs,omitempty"`
638552
// LogSuccessTruncateUntil is log backup already successfully truncate until timestamp.

api/br/v1alpha1/restore.go

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ import (
2424

2525
// GetRestoreJobName return the restore job name
2626
func (rs *Restore) GetRestoreJobName() string {
27-
if IsRestoreVolumeComplete(rs) && !IsRestoreDataComplete(rs) {
28-
return fmt.Sprintf("restore-data-%s", rs.GetName())
29-
}
3027
return fmt.Sprintf("restore-%s", rs.GetName())
3128
}
3229

@@ -125,37 +122,6 @@ func IsRestoreFailed(restore *Restore) bool {
125122
return condition != nil && condition.Status == metav1.ConditionTrue
126123
}
127124

128-
// IsRestoreVolumeComplete returns true if a Restore for volume has successfully completed
129-
func IsRestoreVolumeComplete(restore *Restore) bool {
130-
_, condition := GetRestoreCondition(&restore.Status, RestoreVolumeComplete)
131-
return condition != nil && condition.Status == metav1.ConditionTrue
132-
}
133-
134-
// IsRestoreVolumeFailed returns true if a Restore for volume is Failed
135-
func IsRestoreVolumeFailed(restore *Restore) bool {
136-
return restore.Spec.Mode == RestoreModeVolumeSnapshot &&
137-
IsRestoreFailed(restore) &&
138-
!IsRestoreVolumeComplete(restore)
139-
}
140-
141-
// IsCleanVolumeComplete returns true if restored volumes are cleaned
142-
func IsCleanVolumeComplete(restore *Restore) bool {
143-
_, condition := GetRestoreCondition(&restore.Status, CleanVolumeComplete)
144-
return condition != nil && condition.Status == metav1.ConditionTrue
145-
}
146-
147-
// IsRestoreWarmUpStarted returns true if all the warmup jobs has successfully started
148-
func IsRestoreWarmUpStarted(restore *Restore) bool {
149-
_, condition := GetRestoreCondition(&restore.Status, RestoreWarmUpStarted)
150-
return condition != nil && condition.Status == metav1.ConditionTrue
151-
}
152-
153-
// IsRestoreWarmUpComplete returns true if all the warmup jobs has successfully finished
154-
func IsRestoreWarmUpComplete(restore *Restore) bool {
155-
_, condition := GetRestoreCondition(&restore.Status, RestoreWarmUpComplete)
156-
return condition != nil && condition.Status == metav1.ConditionTrue
157-
}
158-
159125
// IsRestoreTiKVComplete returns true if all TiKVs run successfully during volume restore
160126
func IsRestoreTiKVComplete(restore *Restore) bool {
161127
_, condition := GetRestoreCondition(&restore.Status, RestoreTiKVComplete)

api/br/v1alpha1/restore_types.go

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ const (
6666
RestoreModeSnapshot RestoreMode = "snapshot"
6767
// RestoreModePiTR represents PiTR restore which is from a snapshot backup and log backup.
6868
RestoreModePiTR RestoreMode = "pitr"
69-
// RestoreModeVolumeSnapshot represents restore from a volume snapshot backup.
70-
RestoreModeVolumeSnapshot RestoreMode = "volume-snapshot"
7169
)
7270

7371
// RestoreConditionType represents a valid condition of a Restore.
@@ -78,16 +76,6 @@ const (
7876
RestoreScheduled RestoreConditionType = "Scheduled"
7977
// RestoreRunning means the Restore is currently being executed.
8078
RestoreRunning RestoreConditionType = "Running"
81-
// RestoreVolumeComplete means the Restore has successfully executed part-1 and the
82-
// backup volumes have been rebuilded from the corresponding snapshot
83-
RestoreVolumeComplete RestoreConditionType = "VolumeComplete"
84-
// CleanVolumeComplete means volumes are cleaned successfully if restore volume failed
85-
CleanVolumeComplete RestoreConditionType = "CleanVolumeComplete"
86-
// RestoreWarmUpStarted means the Restore has successfully started warm up pods to
87-
// initialize volumes restored from snapshots
88-
RestoreWarmUpStarted RestoreConditionType = "WarmUpStarted"
89-
// RestoreWarmUpComplete means the Restore has successfully warmed up all TiKV volumes
90-
RestoreWarmUpComplete RestoreConditionType = "WarmUpComplete"
9179
// RestoreDataComplete means the Restore has successfully executed part-2 and the
9280
// data in restore volumes has been deal with consistency based on min_resolved_ts
9381
RestoreDataComplete RestoreConditionType = "DataComplete"
@@ -138,9 +126,6 @@ type RestoreSpec struct {
138126
// - BR_LOG_TO_TERM
139127
// +optional
140128
Env []corev1.EnvVar `json:"env,omitempty"`
141-
// TODO(ideascf): remove it in v2
142-
// To is the tidb cluster that needs to restore.
143-
To *TiDBAccessConfig `json:"to,omitempty"`
144129
// Type is the backup type for tidb cluster and only used when Mode = snapshot, such as full, db, table.
145130
Type BackupType `json:"backupType,omitempty"`
146131
// Mode is the restore mode. such as snapshot or pitr.
@@ -151,13 +136,6 @@ type RestoreSpec struct {
151136
// LogRestoreStartTs is the start timestamp which log restore from.
152137
// +optional
153138
LogRestoreStartTs string `json:"logRestoreStartTs,omitempty"`
154-
// FederalVolumeRestorePhase indicates which phase to execute in federal volume restore
155-
// +optional
156-
FederalVolumeRestorePhase FederalVolumeRestorePhase `json:"federalVolumeRestorePhase,omitempty"`
157-
// VolumeAZ indicates which AZ the volume snapshots restore to.
158-
// it is only valid for mode of volume-snapshot
159-
// +optional
160-
VolumeAZ string `json:"volumeAZ,omitempty"`
161139
// TikvGCLifeTime is to specify the safe gc life time for restore.
162140
// The time limit during which data is retained for each GC, in the format of Go Duration.
163141
// When a GC happens, the current time minus this value is the safe point.
@@ -195,15 +173,6 @@ type RestoreSpec struct {
195173
ImagePullSecrets []corev1.LocalObjectReference `json:"imagePullSecrets,omitempty"`
196174
// TableFilter means Table filter expression for 'db.table' matching. BR supports this from v4.0.3.
197175
TableFilter []string `json:"tableFilter,omitempty"`
198-
// Warmup represents whether to initialize TiKV volumes after volume snapshot restore
199-
// +optional
200-
Warmup RestoreWarmupMode `json:"warmup,omitempty"`
201-
// WarmupImage represents using what image to initialize TiKV volumes
202-
// +optional
203-
WarmupImage string `json:"warmupImage,omitempty"`
204-
// WarmupStrategy
205-
// +kubebuilder:default=hybrid
206-
WarmupStrategy RestoreWarmupStrategy `json:"warmupStrategy,omitempty"`
207176

208177
// PodSecurityContext of the component
209178
// +optional
@@ -223,42 +192,6 @@ type RestoreSpec struct {
223192
TolerateSingleTiKVOutage bool `json:"tolerateSingleTiKVOutage,omitempty"`
224193
}
225194

226-
// FederalVolumeRestorePhase represents a phase to execute in federal volume restore
227-
type FederalVolumeRestorePhase string
228-
229-
const (
230-
// FederalVolumeRestoreVolume means restore volumes of TiKV and start TiKV
231-
FederalVolumeRestoreVolume FederalVolumeRestorePhase = "restore-volume"
232-
// FederalVolumeRestoreData means restore data of TiKV to resolved TS
233-
FederalVolumeRestoreData FederalVolumeRestorePhase = "restore-data"
234-
// FederalVolumeRestoreFinish means restart TiKV and set recoveryMode true
235-
FederalVolumeRestoreFinish FederalVolumeRestorePhase = "restore-finish"
236-
)
237-
238-
// RestoreWarmupMode represents when to initialize TiKV volumes
239-
type RestoreWarmupMode string
240-
241-
const (
242-
// RestoreWarmupModeSync means initialize TiKV volumes before TiKV starts
243-
RestoreWarmupModeSync RestoreWarmupMode = "sync"
244-
// RestoreWarmupModeASync means initialize TiKV volumes after restore complete
245-
RestoreWarmupModeASync RestoreWarmupMode = "async"
246-
)
247-
248-
// RestoreWarmupStrategy represents how to initialize TiKV volumes
249-
type RestoreWarmupStrategy string
250-
251-
const (
252-
// RestoreWarmupStrategyFio warms up all data block by block. (use fio)
253-
RestoreWarmupStrategyFio RestoreWarmupStrategy = "fio"
254-
// RestoreWarmupStrategyHybrid warms up data volume by read sst files one by one, other (e.g. WAL or Raft) will be warmed up via fio.
255-
RestoreWarmupStrategyHybrid RestoreWarmupStrategy = "hybrid"
256-
// RestoreWarmupStrategyFsr warms up data volume by enabling Fast Snapshot Restore, other (e.g. WAL or Raft) will be warmed up via fio.
257-
RestoreWarmupStrategyFsr RestoreWarmupStrategy = "fsr"
258-
// RestoreWarmupStrategyCheckOnly warm up none data volumes and check wal consistency
259-
RestoreWarmupStrategyCheckOnly RestoreWarmupStrategy = "check-wal-only"
260-
)
261-
262195
// RestoreStatus represents the current status of a tidb cluster restore.
263196
type RestoreStatus struct {
264197
// TimeStarted is the time at which the restore was started.

0 commit comments

Comments
 (0)