This commit is contained in:
Gabriel José Mouallem Rodrigues 2026-02-09 11:19:40 -03:00 committed by GitHub
commit a3630c56b5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -33,7 +33,8 @@ import (
)
// updateRecoveryWindow updates the recovery window inside the object
// store status subresource
// store status subresource. It uses retry logic to handle concurrent
// updates from backup completion and retention policy enforcement.
func updateRecoveryWindow(
ctx context.Context,
c client.Client,
@ -41,6 +42,14 @@ func updateRecoveryWindow(
objectStore *barmancloudv1.ObjectStore,
serverName string,
) error {
objectStoreKey := client.ObjectKeyFromObject(objectStore)
return retry.RetryOnConflict(retry.DefaultBackoff, func() error {
var freshObjectStore barmancloudv1.ObjectStore
if err := c.Get(ctx, objectStoreKey, &freshObjectStore); err != nil {
return err
}
// Set the recovery window inside the barman object store object
convertTime := func(t *time.Time) *metav1.Time {
if t == nil {
@ -49,16 +58,17 @@ func updateRecoveryWindow(
return ptr.To(metav1.NewTime(*t))
}
recoveryWindow := objectStore.Status.ServerRecoveryWindow[serverName]
recoveryWindow := freshObjectStore.Status.ServerRecoveryWindow[serverName]
recoveryWindow.FirstRecoverabilityPoint = convertTime(backupList.GetFirstRecoverabilityPoint())
recoveryWindow.LastSuccessfulBackupTime = convertTime(backupList.GetLastSuccessfulBackupTime())
if objectStore.Status.ServerRecoveryWindow == nil {
objectStore.Status.ServerRecoveryWindow = make(map[string]barmancloudv1.RecoveryWindow)
if freshObjectStore.Status.ServerRecoveryWindow == nil {
freshObjectStore.Status.ServerRecoveryWindow = make(map[string]barmancloudv1.RecoveryWindow)
}
objectStore.Status.ServerRecoveryWindow[serverName] = recoveryWindow
freshObjectStore.Status.ServerRecoveryWindow[serverName] = recoveryWindow
return c.Status().Update(ctx, objectStore)
return c.Status().Update(ctx, &freshObjectStore)
})
}
// setLastFailedBackupTime sets the last failed backup time in the