-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Add maintenance history for backupRepository CRs #8532
base: main
Are you sure you want to change the base?
Add maintenance history for backupRepository CRs #8532
Conversation
Signed-off-by: Lyndon-Li <[email protected]>
Signed-off-by: Lyndon-Li <[email protected]>
Signed-off-by: Lyndon-Li <[email protected]>
8fa1215
to
3b2c50b
Compare
@@ -88,8 +88,8 @@ spec: | |||
description: BackupRepositoryStatus is the current status of a BackupRepository. | |||
properties: | |||
lastMaintenanceTime: | |||
description: LastMaintenanceTime is the last time maintenance was | |||
run. | |||
description: LastMaintenanceTime is the last time repo maintenance |
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.
LastMaintenanceTime
should be used to record the completion time of a successful maintenance.
Previously, it is used to record the start time of a successful maintenance, which is not reasonable. E.g., I run a maintenance which takes more than 1 hour; since the default frequency for quick maintenance is 1 hour, the next maintenance will be launched immediately after the first one completes, but actually it is a wasting one as data has just been maintained.
Previously, the description in the CRD is ambiguous, it could mean the completion time or start time.
So in this PR, both the description and the value set to LastMaintenanceTime
as changed.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #8532 +/- ##
==========================================
- Coverage 59.18% 59.17% -0.01%
==========================================
Files 369 369
Lines 39329 39355 +26
==========================================
+ Hits 23276 23289 +13
- Misses 14585 14597 +12
- Partials 1468 1469 +1 ☔ View full report in Codecov by Sentry. |
func updateRepoMaintenanceHistory(repo *velerov1api.BackupRepository, result velerov1api.BackupRepositoryMaintenanceResult, startTime time.Time, completionTime time.Time, message string) { | ||
length := defaultMaintenanceStatusQueueLength | ||
if len(repo.Status.RecentMaintenanceStatus) < defaultMaintenanceStatusQueueLength { | ||
length = len(repo.Status.RecentMaintenanceStatus) + 1 | ||
} | ||
|
||
lru := make([]velerov1api.BackupRepositoryMaintenanceStatus, length) | ||
|
||
if len(repo.Status.RecentMaintenanceStatus) >= defaultMaintenanceStatusQueueLength { | ||
copy(lru[:length-1], repo.Status.RecentMaintenanceStatus[len(repo.Status.RecentMaintenanceStatus)-defaultMaintenanceStatusQueueLength+1:]) | ||
} else { | ||
copy(lru[:length-1], repo.Status.RecentMaintenanceStatus[:]) | ||
} | ||
|
||
lru[length-1] = velerov1api.BackupRepositoryMaintenanceStatus{ | ||
Result: result, | ||
StartTimestamp: &metav1.Time{Time: startTime}, | ||
CompleteTimestamp: &metav1.Time{Time: completionTime}, | ||
Message: message, | ||
} | ||
|
||
repo.Status.RecentMaintenanceStatus = lru | ||
} |
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.
func updateRepoMaintenanceHistory(repo *velerov1api.BackupRepository, result velerov1api.BackupRepositoryMaintenanceResult, startTime time.Time, completionTime time.Time, message string) { | |
length := defaultMaintenanceStatusQueueLength | |
if len(repo.Status.RecentMaintenanceStatus) < defaultMaintenanceStatusQueueLength { | |
length = len(repo.Status.RecentMaintenanceStatus) + 1 | |
} | |
lru := make([]velerov1api.BackupRepositoryMaintenanceStatus, length) | |
if len(repo.Status.RecentMaintenanceStatus) >= defaultMaintenanceStatusQueueLength { | |
copy(lru[:length-1], repo.Status.RecentMaintenanceStatus[len(repo.Status.RecentMaintenanceStatus)-defaultMaintenanceStatusQueueLength+1:]) | |
} else { | |
copy(lru[:length-1], repo.Status.RecentMaintenanceStatus[:]) | |
} | |
lru[length-1] = velerov1api.BackupRepositoryMaintenanceStatus{ | |
Result: result, | |
StartTimestamp: &metav1.Time{Time: startTime}, | |
CompleteTimestamp: &metav1.Time{Time: completionTime}, | |
Message: message, | |
} | |
repo.Status.RecentMaintenanceStatus = lru | |
} | |
func addRepoMaintenanceHistory(repo *velerov1api.BackupRepository, result velerov1api.BackupRepositoryMaintenanceResult, startTime time.Time, completionTime time.Time, message string) { | |
length := defaultMaintenanceStatusQueueLength | |
resultStatus := velerov1api.BackupRepositoryMaintenanceStatus{ | |
Result: result, | |
StartTimestamp: &metav1.Time{Time: startTime}, | |
CompleteTimestamp: &metav1.Time{Time: completionTime}, | |
Message: message, | |
} | |
startingPos := 0 | |
if len(repo.Status.RecentMaintenanceStatus) >= length { | |
// discard old element(s) | |
startingPos = len(repo.Status.RecentMaintenanceStatus) - length + 1 | |
} | |
repo.Status.RecentMaintenanceStatus = append(repo.Status.RecentMaintenanceStatus[startingPos:], resultStatus) | |
} |
Thoughts?
Fix issue #7810, add maintenance history for backupRepository CRs