-
Notifications
You must be signed in to change notification settings - Fork 176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: improve and refactor backup and restore #4917
Conversation
Signed-off-by: L.Dongming <l.dongming@apecloud.com>
b1cd9d5
to
2cd0d03
Compare
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
// Backup total size. | ||
// A string with capacity units in the form of "1Gi", "1Mi", "1Ki". | ||
// totalSize is the total size of backed up data size. | ||
// A string with capacity units in the format of "1Gi", "1Mi", "1Ki". | ||
// +optional | ||
TotalSize string `json:"totalSize,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add another field to record the exact size in bytes, for example totalSizeBytes
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer to use one filed to record the data size, maybe totalSizeBytes
is a good choice. And other client can convert it to more human-readable format.
I plan to improve it in subsequent PRs.
23b16c4
to
f87c975
Compare
3d98952
to
3c6a197
Compare
/approve to trigger test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are too many changes and I haven't done my review of the controller logic yet.
SourceCluster string `json:"sourceCluster,omitempty"` | ||
RestoreTime *time.Time `json:"restoreTime,omitempty"` | ||
RestoreTimeStr string `json:"restoreTimeStr,omitempty"` | ||
RestoreManagementPolicy string `json:"volumeRestorePolicy,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RestoreManagementPolicy
is hard to understand, maybe ParallelRestoreVolumes bool
.
Ok, I will fix review comment in another PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have finished my review.
type ErrorMode string | ||
|
||
const ( | ||
ErrorModeContinue ErrorMode = "Continue" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused.
return intctrlutil.CheckedRequeueWithError(err, reqCtx.Log, "") | ||
} | ||
if len(targetPods) > 1 { | ||
return nil, fmt.Errorf("do not support more than one target pods") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems possible to hit this error when PodSelectionStrategyAll
is specified in the backup policy.
// if reaches full backup, sort the BackupActionSets and return | ||
sortBackupSets := func(backupSets []BackupActionSet, reverse bool) []BackupActionSet { | ||
sort.Slice(backupSets, func(i, j int) bool { | ||
if reverse { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reverse
is always false
.
var ( | ||
restoreActionCount int | ||
finishedActionCount int | ||
exitFailedAction bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
existFailedAction
? According to the Recalculation()
.
@@ -372,11 +372,9 @@ type BackupSpec struct { | |||
// +optional | |||
BackupPolicyName string `json:"backupPolicyName"` | |||
|
|||
// Backup Type. datafile or logfile or snapshot. If not set, datafile is the default type. | |||
// +kubebuilder:default=datafile | |||
// +kubeBuilder:validation:Enum={datafile,logfile,snapshot} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would expect this an enum string type?
metadata: | ||
name: xtrabackup-for-apecloud-mysql | ||
labels: | ||
clusterdefinition.kubeblocks.io/name: apecloud-mysql |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using label isn't ideal for hard constraint/bounding with clusterdefinition, what is the reason for this design?
// +kubebuilder:validation:Enum={Full,Incremental,Differential,Continuous} | ||
// +kubebuilder:default=Full | ||
// +kubebuilder:validation:Required | ||
BackupType BackupType `json:"backupType"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you have refactored to a generic name (ActionSet), and I would suggest have this attribute as "type" to accommodate future extensible design? Or otherwise this API would be named as "BackupRestoreActionSet".
Signed-off-by: L.Dongming <l.dongming@apecloud.com> Co-authored-by: wangyelei <yelei.wang@apecloud.com>
This PR has redesign the backup/restore and its related CRDs, the relevant controllers have also been refactored. So I'd like to apologize to the reviewers that this is too big of a PR. Below I will explain specifically what has been done and what still needs to be done in the future(Not in this PR).
Refactor backup/restore CRD
backupMethod
to replacebackupType
, add other filedsbackupSchedule
out ofbackupPolicy
, using backupPolicy to configure backup policy that can be used for both manual and automatic backups, and usingbackupSchedule
to configure automatic scheduling strategiesdatafile
andsnapshot
fileds, use more flexiblebackupMethod
array to specify the backup methods, the backup type is only one attribute of backupMethodactionSet
to replacebackupTool
, with actionSet defining the specific actions required for backup and restore, delete fields likelogicalCommand
andphysicalCommand
.restore
CRD by @wangyelei that is used to restore a backupbackupPolicyTempldate
and backupTool to use new CRDRefactor controller
controller
tointernal/dataprotection
kbcli
needs to be done in the future PR
builder
to build the kubernetes objectIn summary, this PR refactored backup and restore, including refactoring the CRD and controller code, but there is still much work remaining going forward.
local env test
TODO: