-
Notifications
You must be signed in to change notification settings - Fork 498
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
Control backup gc by completed and failed bakcups number #4480
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: just1900 <[email protected]>
[REVIEW NOTIFICATION] This pull request has been approved by:
To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by submitting an approval review. |
Signed-off-by: just1900 <[email protected]>
klog.Infof("backup schedule %s/%s gc backup %s success", ns, bsName, backup.GetName()) | ||
} | ||
|
||
if deleteCount == len(backupsList) && deleteCount > 0 { |
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.
Remove this condition, because only if .spec.maxBackups
is 0 will this condition be true, which is impossible.
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.
Why is this impossible?
Codecov Report
@@ Coverage Diff @@
## master #4480 +/- ##
==========================================
+ Coverage 62.79% 72.35% +9.56%
==========================================
Files 184 188 +4
Lines 19875 22310 +2435
==========================================
+ Hits 12480 16142 +3662
+ Misses 6262 5043 -1219
+ Partials 1133 1125 -8
|
Signed-off-by: just1900 <[email protected]>
Signed-off-by: just1900 <[email protected]>
Signed-off-by: just1900 <[email protected]>
seems like a issue exists when |
… effect immediately Signed-off-by: just1900 <[email protected]>
Signed-off-by: just1900 <[email protected]>
/test pull-e2e-kind-serial |
/test pull-e2e-kind pull-e2e-kind-br pull-e2e-kind-tngm |
@just1900: PR needs rebase. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
// if both MaxCompletedBackups and MaxBackups are set, operator will keep no more than MaxCompletedBackups completed backups, | ||
// and no more than MaxBackups backups in total. | ||
// +kubebuilder:default:=3 | ||
// +kubebuilder:validation:Minimum:=1 |
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.
For the old backupSchedule, if the user does not configure MaxBackups, which means no clean-up for the backups, with this change, after upgrading the TiDB Operator, only 3 completed backups will be retained, and the others will be cleaned, right? If yes, this is unexpected behavior.
// and no more than MaxBackups backups in total. | ||
// +kubebuilder:default:=1 | ||
// +optional | ||
MaxFailedBackups *int32 `json:"maxFailedBackups,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.
ditto.
// if MaxBackups and MaxReservedTime are set at the same time, MaxReservedTime is preferred. | ||
if bs.Spec.MaxReservedTime != nil { | ||
bm.backupGCByMaxReservedTime(bs) | ||
return | ||
} | ||
|
||
if bs.Spec.MaxBackups != nil && *bs.Spec.MaxBackups > 0 { | ||
if (bs.Spec.MaxBackups != nil && *bs.Spec.MaxBackups > 0) || bs.Spec.MaxCompletedBackups != nil || bs.Spec.MaxFailedBackups != nil { |
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.
Check the *bs.Spec.MaxCompletedBackups > 0
and *bs.Spec.MaxFailedBackups > 0
// All backups have been deleted, so the last backup information in the backupSchedule should be reset | ||
bm.resetLastBackup(bs) | ||
if bs.Spec.MaxBackups != nil && int(*bs.Spec.MaxBackups) > 0 && totalCnt > int(*bs.Spec.MaxBackups) { | ||
totalCnt-- |
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.
Should we also adjust the value of complete count and failed count here?
Signed-off-by: just1900 [email protected]
What problem does this PR solve?
fix #3660
What is changed and how does it work?
adding
MaxCompletedBackups
andMaxFailedBackups
fields to control backup gc.Code changes
Tests
Side effects
Related changes
Release Notes
Please refer to Release Notes Language Style Guide before writing the release note.