mirror of
https://github.com/cloudnative-pg/plugin-barman-cloud.git
synced 2026-03-09 12:12:21 +01:00
Merge eefb45ca5a into 2e0b5d7783
This commit is contained in:
commit
7bbe6b9055
@ -33,7 +33,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// updateRecoveryWindow updates the recovery window inside the object
|
// 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(
|
func updateRecoveryWindow(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
c client.Client,
|
c client.Client,
|
||||||
@ -41,24 +42,33 @@ func updateRecoveryWindow(
|
|||||||
objectStore *barmancloudv1.ObjectStore,
|
objectStore *barmancloudv1.ObjectStore,
|
||||||
serverName string,
|
serverName string,
|
||||||
) error {
|
) error {
|
||||||
// Set the recovery window inside the barman object store object
|
objectStoreKey := client.ObjectKeyFromObject(objectStore)
|
||||||
convertTime := func(t *time.Time) *metav1.Time {
|
|
||||||
if t == nil {
|
return retry.RetryOnConflict(retry.DefaultBackoff, func() error {
|
||||||
return nil
|
var freshObjectStore barmancloudv1.ObjectStore
|
||||||
|
if err := c.Get(ctx, objectStoreKey, &freshObjectStore); err != nil {
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
return ptr.To(metav1.NewTime(*t))
|
|
||||||
}
|
|
||||||
|
|
||||||
recoveryWindow := objectStore.Status.ServerRecoveryWindow[serverName]
|
// Set the recovery window inside the barman object store object
|
||||||
recoveryWindow.FirstRecoverabilityPoint = convertTime(backupList.GetFirstRecoverabilityPoint())
|
convertTime := func(t *time.Time) *metav1.Time {
|
||||||
recoveryWindow.LastSuccessfulBackupTime = convertTime(backupList.GetLastSuccessfulBackupTime())
|
if t == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return ptr.To(metav1.NewTime(*t))
|
||||||
|
}
|
||||||
|
|
||||||
if objectStore.Status.ServerRecoveryWindow == nil {
|
recoveryWindow := freshObjectStore.Status.ServerRecoveryWindow[serverName]
|
||||||
objectStore.Status.ServerRecoveryWindow = make(map[string]barmancloudv1.RecoveryWindow)
|
recoveryWindow.FirstRecoverabilityPoint = convertTime(backupList.GetFirstRecoverabilityPoint())
|
||||||
}
|
recoveryWindow.LastSuccessfulBackupTime = convertTime(backupList.GetLastSuccessfulBackupTime())
|
||||||
objectStore.Status.ServerRecoveryWindow[serverName] = recoveryWindow
|
|
||||||
|
|
||||||
return c.Status().Update(ctx, objectStore)
|
if freshObjectStore.Status.ServerRecoveryWindow == nil {
|
||||||
|
freshObjectStore.Status.ServerRecoveryWindow = make(map[string]barmancloudv1.RecoveryWindow)
|
||||||
|
}
|
||||||
|
freshObjectStore.Status.ServerRecoveryWindow[serverName] = recoveryWindow
|
||||||
|
|
||||||
|
return c.Status().Update(ctx, &freshObjectStore)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// setLastFailedBackupTime sets the last failed backup time in the
|
// setLastFailedBackupTime sets the last failed backup time in the
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user