mirror of
https://github.com/cloudnative-pg/plugin-barman-cloud.git
synced 2026-01-11 21:23:12 +01:00
In the in-tree barman-cloud implementation, the check for an empty WAL archive is performed both immediately after the restore process and when the first WAL file is archived. Previously, the plugin-based implementation only performed this check after restore, skipping it during archiving of the first WAL. This patch restores parity with the in-tree behavior by ensuring the check is also performed during WAL archiving. Closes: #457 Signed-off-by: Leonardo Cecchi <leonardo.cecchi@enterprisedb.com>
35 lines
1001 B
Go
35 lines
1001 B
Go
package common
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/cloudnative-pg/barman-cloud/pkg/archiver"
|
|
cnpgv1 "github.com/cloudnative-pg/cloudnative-pg/api/v1"
|
|
"github.com/cloudnative-pg/machinery/pkg/log"
|
|
)
|
|
|
|
// CheckBackupDestination checks if the backup destination is suitable
|
|
// to archive WALs
|
|
func CheckBackupDestination(
|
|
ctx context.Context,
|
|
barmanConfiguration *cnpgv1.BarmanObjectStoreConfiguration,
|
|
barmanArchiver *archiver.WALArchiver,
|
|
serverName string,
|
|
) error {
|
|
contextLogger := log.FromContext(ctx)
|
|
contextLogger.Info(
|
|
"Checking backup destination with barman-cloud-wal-archive",
|
|
"serverName", serverName)
|
|
|
|
// Get WAL archive options
|
|
checkWalOptions, err := barmanArchiver.BarmanCloudCheckWalArchiveOptions(
|
|
ctx, barmanConfiguration, serverName)
|
|
if err != nil {
|
|
log.Error(err, "while getting barman-cloud-wal-archive options")
|
|
return err
|
|
}
|
|
|
|
// Check if we're ok to archive in the desired destination
|
|
return barmanArchiver.CheckWalArchiveDestination(ctx, checkWalOptions)
|
|
}
|