mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-09-19 06:26:44 +00:00
issue 9428: incremental repo maintenance history queue length
Signed-off-by: Lyndon-Li <lyonghui@vmware.com>
This commit is contained in:
@@ -0,0 +1 @@
|
||||
Fix issue #9428, increase repo maintenance history queue length from 3 to 25
|
||||
@@ -52,9 +52,11 @@ import (
|
||||
const (
|
||||
repoSyncPeriod = 5 * time.Minute
|
||||
defaultMaintainFrequency = 7 * 24 * time.Hour
|
||||
defaultMaintenanceStatusQueueLength = 3
|
||||
defaultMaintenanceStatusQueueLength = 25
|
||||
)
|
||||
|
||||
var maintenanceStatusQueueLength = defaultMaintenanceStatusQueueLength
|
||||
|
||||
type BackupRepoReconciler struct {
|
||||
client.Client
|
||||
namespace string
|
||||
@@ -369,7 +371,7 @@ func ensureRepo(repo *velerov1api.BackupRepository, repoManager repomanager.Mana
|
||||
}
|
||||
|
||||
func (r *BackupRepoReconciler) recallMaintenance(ctx context.Context, req *velerov1api.BackupRepository, log logrus.FieldLogger) error {
|
||||
history, err := maintenance.WaitAllJobsComplete(ctx, r.Client, req, defaultMaintenanceStatusQueueLength, log)
|
||||
history, err := maintenance.WaitAllJobsComplete(ctx, r.Client, req, maintenanceStatusQueueLength, log)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "error waiting incomplete repo maintenance job for repo %s", req.Name)
|
||||
}
|
||||
@@ -427,7 +429,7 @@ func consolidateHistory(coming, cur []velerov1api.BackupRepositoryMaintenanceSta
|
||||
|
||||
truncated := []velerov1api.BackupRepositoryMaintenanceStatus{}
|
||||
for consolidator.Len() > 0 {
|
||||
if len(truncated) == defaultMaintenanceStatusQueueLength {
|
||||
if len(truncated) == maintenanceStatusQueueLength {
|
||||
break
|
||||
}
|
||||
|
||||
@@ -537,8 +539,8 @@ func updateRepoMaintenanceHistory(repo *velerov1api.BackupRepository, result vel
|
||||
}
|
||||
|
||||
startingPos := 0
|
||||
if len(repo.Status.RecentMaintenance) >= defaultMaintenanceStatusQueueLength {
|
||||
startingPos = len(repo.Status.RecentMaintenance) - defaultMaintenanceStatusQueueLength + 1
|
||||
if len(repo.Status.RecentMaintenance) >= maintenanceStatusQueueLength {
|
||||
startingPos = len(repo.Status.RecentMaintenance) - maintenanceStatusQueueLength + 1
|
||||
}
|
||||
|
||||
repo.Status.RecentMaintenance = append(repo.Status.RecentMaintenance[startingPos:], latest)
|
||||
|
||||
@@ -929,6 +929,8 @@ func TestUpdateRepoMaintenanceHistory(t *testing.T) {
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
maintenanceStatusQueueLength = 3
|
||||
|
||||
updateRepoMaintenanceHistory(test.backupRepo, test.result, &metav1.Time{Time: standardTime}, &metav1.Time{Time: standardTime.Add(time.Hour)}, "fake-message-0")
|
||||
|
||||
for at := range test.backupRepo.Status.RecentMaintenance {
|
||||
|
||||
Reference in New Issue
Block a user