mirror of
https://github.com/cloudnative-pg/plugin-barman-cloud.git
synced 2026-09-06 15:02:21 +02:00
Compare commits
4 Commits
8b4dd09a12
...
be7ac7c17a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
be7ac7c17a | ||
|
|
d1a714445c | ||
|
|
7bcb74b987 | ||
|
|
1d777435d0 |
30
.github/workflows/ci.yml
vendored
30
.github/workflows/ci.yml
vendored
@ -6,12 +6,15 @@ on:
|
|||||||
|
|
||||||
permissions: read-all
|
permissions: read-all
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
|
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
ci:
|
ci:
|
||||||
runs-on: ${{ vars.CI_RUNNERS || 'ubuntu-latest' }}
|
runs-on: ${{ vars.CI_RUNNERS || 'ubuntu-latest' }}
|
||||||
permissions:
|
permissions:
|
||||||
packages: write
|
contents: read
|
||||||
contents: write
|
|
||||||
steps:
|
steps:
|
||||||
- name: Cleanup Disk
|
- name: Cleanup Disk
|
||||||
if: vars.CI_RUNNERS == '' || vars.CI_RUNNERS == 'ubuntu-latest'
|
if: vars.CI_RUNNERS == '' || vars.CI_RUNNERS == 'ubuntu-latest'
|
||||||
@ -39,8 +42,6 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
ref: ${{ github.event.pull_request.head.sha }}
|
ref: ${{ github.event.pull_request.head.sha }}
|
||||||
- name: Install QEMU static binaries
|
|
||||||
uses: docker/setup-qemu-action@v4
|
|
||||||
- name: Install Task
|
- name: Install Task
|
||||||
uses: arduino/setup-task@v3.0.0
|
uses: arduino/setup-task@v3.0.0
|
||||||
- name: Install Dagger
|
- name: Install Dagger
|
||||||
@ -52,6 +53,27 @@ jobs:
|
|||||||
- name: Run CI task
|
- name: Run CI task
|
||||||
run: |
|
run: |
|
||||||
task ci
|
task ci
|
||||||
|
|
||||||
|
publish:
|
||||||
|
runs-on: ${{ vars.CI_RUNNERS || 'ubuntu-latest' }}
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
packages: write
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v7.0.1
|
||||||
|
with:
|
||||||
|
ref: ${{ github.event.pull_request.head.sha }}
|
||||||
|
- name: Install QEMU static binaries
|
||||||
|
uses: docker/setup-qemu-action@v4
|
||||||
|
- name: Install Task
|
||||||
|
uses: arduino/setup-task@v3.0.0
|
||||||
|
- name: Install Dagger
|
||||||
|
env:
|
||||||
|
# renovate: datasource=github-tags depName=dagger/dagger versioning=semver
|
||||||
|
DAGGER_VERSION: 0.21.7
|
||||||
|
run: |
|
||||||
|
curl -L https://dl.dagger.io/dagger/install.sh | BIN_DIR=$HOME/.local/bin sh
|
||||||
- name: Write manifest
|
- name: Write manifest
|
||||||
run: |
|
run: |
|
||||||
task manifest
|
task manifest
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
{
|
{
|
||||||
".": "0.13.0"
|
".": "0.14.0"
|
||||||
}
|
}
|
||||||
|
|||||||
30
CHANGELOG.md
30
CHANGELOG.md
@ -1,5 +1,35 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## [0.14.0](https://github.com/cloudnative-pg/plugin-barman-cloud/compare/v0.13.0...v0.14.0) (2026-07-21)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* Honor the operator's check_empty_wal_archive decision ([#1009](https://github.com/cloudnative-pg/plugin-barman-cloud/issues/1009)) ([7bcb74b](https://github.com/cloudnative-pg/plugin-barman-cloud/commit/7bcb74b987a3cca232c6f8021157eb711a1289b0))
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **deps:** Update all non-major go dependencies ([#963](https://github.com/cloudnative-pg/plugin-barman-cloud/issues/963)) ([f949241](https://github.com/cloudnative-pg/plugin-barman-cloud/commit/f94924105b51b7b015338d4ec2c71904ef8d095c))
|
||||||
|
* **deps:** Update all non-major go dependencies ([#979](https://github.com/cloudnative-pg/plugin-barman-cloud/issues/979)) ([bf52833](https://github.com/cloudnative-pg/plugin-barman-cloud/commit/bf5283359478071f116464c14a7a3d3d0a358eea))
|
||||||
|
* **deps:** Update all non-major go dependencies ([#982](https://github.com/cloudnative-pg/plugin-barman-cloud/issues/982)) ([5f84ecc](https://github.com/cloudnative-pg/plugin-barman-cloud/commit/5f84ecce4a9433da27346d194f6a4b456d59f75f))
|
||||||
|
* **deps:** Update all non-major go dependencies to 53ffbf0 ([#973](https://github.com/cloudnative-pg/plugin-barman-cloud/issues/973)) ([7190349](https://github.com/cloudnative-pg/plugin-barman-cloud/commit/719034947061f72ce8fcc919f5e209aa7fd7d874))
|
||||||
|
* **deps:** Update all non-major go dependencies to 592f761 ([#972](https://github.com/cloudnative-pg/plugin-barman-cloud/issues/972)) ([2fa63c4](https://github.com/cloudnative-pg/plugin-barman-cloud/commit/2fa63c4bc28c03fbb79e3751a001868e991b8917))
|
||||||
|
* **deps:** Update all non-major go dependencies to 8d9302e ([#975](https://github.com/cloudnative-pg/plugin-barman-cloud/issues/975)) ([0c687cb](https://github.com/cloudnative-pg/plugin-barman-cloud/commit/0c687cbbf13f4ce5ca1690d4dcf768d76cb4731a))
|
||||||
|
* **deps:** Update all non-major go dependencies to v2.30.0 ([#957](https://github.com/cloudnative-pg/plugin-barman-cloud/issues/957)) ([61b82ce](https://github.com/cloudnative-pg/plugin-barman-cloud/commit/61b82ce250e95f04d49d0fb427e79364f2d900c0))
|
||||||
|
* **deps:** Update documentation dependencies to v3.10.2 ([#1001](https://github.com/cloudnative-pg/plugin-barman-cloud/issues/1001)) ([88f2e29](https://github.com/cloudnative-pg/plugin-barman-cloud/commit/88f2e296746f495d3e7b27cd7297e772d53f61e9))
|
||||||
|
* **deps:** Update github.com/cloudnative-pg/barman-cloud digest to 950b0f5 ([#1022](https://github.com/cloudnative-pg/plugin-barman-cloud/issues/1022)) ([98537c4](https://github.com/cloudnative-pg/plugin-barman-cloud/commit/98537c4d0e899e136e85237b29020a9bbbf9f5aa))
|
||||||
|
* **deps:** Update k8s.io/utils digest to a95e086 ([#968](https://github.com/cloudnative-pg/plugin-barman-cloud/issues/968)) ([f7f0136](https://github.com/cloudnative-pg/plugin-barman-cloud/commit/f7f0136520b1032698b26e33e6eff1caa01173f5))
|
||||||
|
* **deps:** Update k8s.io/utils digest to be93311 ([#986](https://github.com/cloudnative-pg/plugin-barman-cloud/issues/986)) ([2cc4e99](https://github.com/cloudnative-pg/plugin-barman-cloud/commit/2cc4e9905db6b1d1c5788dd6093a1a7d330d9064))
|
||||||
|
* **deps:** Update kubernetes monorepo to v0.36.2 ([#958](https://github.com/cloudnative-pg/plugin-barman-cloud/issues/958)) ([030b28c](https://github.com/cloudnative-pg/plugin-barman-cloud/commit/030b28c4b9aee205f7a43f1fcc4da363b50839d9))
|
||||||
|
* **deps:** Update module github.com/cloudnative-pg/cnpg-i to v0.6.0 ([#1021](https://github.com/cloudnative-pg/plugin-barman-cloud/issues/1021)) ([13450a3](https://github.com/cloudnative-pg/plugin-barman-cloud/commit/13450a370d16fda87c128fc3a2f420f5b0cc442b))
|
||||||
|
* **deps:** Update module google.golang.org/grpc to v1.82.1 ([#1008](https://github.com/cloudnative-pg/plugin-barman-cloud/issues/1008)) ([3c27364](https://github.com/cloudnative-pg/plugin-barman-cloud/commit/3c273641e3fb8027011be74ebb09d0ba91f71c7b))
|
||||||
|
* **docs:** Fix broken anchor link in concepts.md ([#1013](https://github.com/cloudnative-pg/plugin-barman-cloud/issues/1013)) ([9c84d06](https://github.com/cloudnative-pg/plugin-barman-cloud/commit/9c84d069edc39c2848813aff5fd13c13c2ac8ff9))
|
||||||
|
* Inject barman sidecar in replica clusters bootstrapped with pg_basebackup ([#965](https://github.com/cloudnative-pg/plugin-barman-cloud/issues/965)) ([eb5e860](https://github.com/cloudnative-pg/plugin-barman-cloud/commit/eb5e8607752d60bf36b4a9ddcaa5bb447f323012))
|
||||||
|
* Reduce startupProbe periodSeconds without losing failure tolerance ([#992](https://github.com/cloudnative-pg/plugin-barman-cloud/issues/992)) ([bf95543](https://github.com/cloudnative-pg/plugin-barman-cloud/commit/bf955430cb58987bbbe3cd2925ea06700cf85609)), closes [#991](https://github.com/cloudnative-pg/plugin-barman-cloud/issues/991)
|
||||||
|
* Restore WAL from replica source during designated primary promotion ([#966](https://github.com/cloudnative-pg/plugin-barman-cloud/issues/966)) ([c34b232](https://github.com/cloudnative-pg/plugin-barman-cloud/commit/c34b2329ea39f9a1030d9d1225aa4d0a276255eb))
|
||||||
|
* **walrestore:** Serve pg_rewind without prefetching and flag machinery ([#1007](https://github.com/cloudnative-pg/plugin-barman-cloud/issues/1007)) ([fb3f0f9](https://github.com/cloudnative-pg/plugin-barman-cloud/commit/fb3f0f9dabba85d87af85418d58b2f8224ed6305))
|
||||||
|
|
||||||
## [0.13.0](https://github.com/cloudnative-pg/plugin-barman-cloud/compare/v0.12.0...v0.13.0) (2026-06-10)
|
## [0.13.0](https://github.com/cloudnative-pg/plugin-barman-cloud/compare/v0.12.0...v0.13.0) (2026-06-10)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -156,13 +156,17 @@ func (w WALServiceImplementation) Archive(
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 2: Check if the archive location is safe to perform archiving
|
// Step 2: Check if the archive location is safe to perform archiving.
|
||||||
checkFileExisting, err := fileutils.FileExists(emptyWalArchiveFile)
|
checkEmptyWalArchive, err := resolveArchiveEmptyWalArchiveCheck(
|
||||||
|
request.CheckEmptyWalArchive,
|
||||||
|
configuration.Cluster,
|
||||||
|
emptyWalArchiveFile,
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("while checking for empty wal archive check file %q: %w", emptyWalArchiveFile, err)
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if utils.IsEmptyWalArchiveCheckEnabled(&configuration.Cluster.ObjectMeta) && checkFileExisting {
|
if checkEmptyWalArchive {
|
||||||
if err := CheckBackupDestination(
|
if err := CheckBackupDestination(
|
||||||
ctx,
|
ctx,
|
||||||
&objectStore.Spec.Configuration,
|
&objectStore.Spec.Configuration,
|
||||||
@ -224,6 +228,31 @@ func (w WALServiceImplementation) Archive(
|
|||||||
return &wal.WALArchiveResult{}, nil
|
return &wal.WALArchiveResult{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// resolveArchiveEmptyWalArchiveCheck reports whether the WAL archive
|
||||||
|
// destination must be verified before archiving this segment.
|
||||||
|
//
|
||||||
|
// The operator owns the marker file's lifecycle, so when it sets the decision
|
||||||
|
// (non-nil) that value already accounts for the marker and is obeyed as-is. A
|
||||||
|
// nil value comes from an operator that predates this field, so we fall back to
|
||||||
|
// the previous logic: the Cluster annotation combined with the on-disk marker
|
||||||
|
// file.
|
||||||
|
func resolveArchiveEmptyWalArchiveCheck(
|
||||||
|
operatorDecision *bool,
|
||||||
|
cluster *cnpgv1.Cluster,
|
||||||
|
markerFilePath string,
|
||||||
|
) (bool, error) {
|
||||||
|
if operatorDecision != nil {
|
||||||
|
return *operatorDecision, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
markerFilePresent, err := fileutils.FileExists(markerFilePath)
|
||||||
|
if err != nil {
|
||||||
|
return false, fmt.Errorf("while checking for empty wal archive check file %q: %w", markerFilePath, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return utils.IsEmptyWalArchiveCheckEnabled(&cluster.ObjectMeta) && markerFilePresent, nil
|
||||||
|
}
|
||||||
|
|
||||||
// Restore implements the WALService interface
|
// Restore implements the WALService interface
|
||||||
func (w WALServiceImplementation) Restore(
|
func (w WALServiceImplementation) Restore(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
|
|||||||
@ -21,15 +21,20 @@ package common
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
barmanapi "github.com/cloudnative-pg/barman-cloud/pkg/api"
|
barmanapi "github.com/cloudnative-pg/barman-cloud/pkg/api"
|
||||||
barmanRestorer "github.com/cloudnative-pg/barman-cloud/pkg/restorer"
|
barmanRestorer "github.com/cloudnative-pg/barman-cloud/pkg/restorer"
|
||||||
cnpgv1 "github.com/cloudnative-pg/cloudnative-pg/api/v1"
|
cnpgv1 "github.com/cloudnative-pg/cloudnative-pg/api/v1"
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
"k8s.io/utils/ptr"
|
||||||
|
|
||||||
|
"github.com/cloudnative-pg/plugin-barman-cloud/internal/cnpgi/metadata"
|
||||||
|
"github.com/cloudnative-pg/plugin-barman-cloud/internal/cnpgi/operator/config"
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo/v2"
|
. "github.com/onsi/ginkgo/v2"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
||||||
|
|
||||||
"github.com/cloudnative-pg/plugin-barman-cloud/internal/cnpgi/operator/config"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ = Describe("resolveRestoreObjectStore", func() {
|
var _ = Describe("resolveRestoreObjectStore", func() {
|
||||||
@ -177,3 +182,65 @@ var _ = Describe("clearEndOfWALStreamFlag", func() {
|
|||||||
Expect(isEOS).To(BeFalse())
|
Expect(isEOS).To(BeFalse())
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
var _ = Describe("resolveArchiveEmptyWalArchiveCheck", func() {
|
||||||
|
// skipAnnotation mirrors the unexported constant in cloudnative-pg's
|
||||||
|
// pkg/utils; hard-coding the literal makes a divergence surface as a
|
||||||
|
// failing test rather than silently disabling the check.
|
||||||
|
const skipAnnotation = "cnpg.io/skipEmptyWalArchiveCheck"
|
||||||
|
|
||||||
|
clusterWith := func(annotationValue *string) *cnpgv1.Cluster {
|
||||||
|
cluster := &cnpgv1.Cluster{}
|
||||||
|
if annotationValue != nil {
|
||||||
|
cluster.Annotations = map[string]string{skipAnnotation: *annotationValue}
|
||||||
|
}
|
||||||
|
return cluster
|
||||||
|
}
|
||||||
|
|
||||||
|
// markerPath returns the marker file path inside a fresh temp dir,
|
||||||
|
// creating the file there when present is true.
|
||||||
|
markerPath := func(present bool) string {
|
||||||
|
filePath := filepath.Join(GinkgoT().TempDir(), metadata.CheckEmptyWalArchiveFile)
|
||||||
|
if present {
|
||||||
|
Expect(os.WriteFile(filePath, []byte{}, 0o600)).To(Succeed())
|
||||||
|
}
|
||||||
|
return filePath
|
||||||
|
}
|
||||||
|
|
||||||
|
When("the operator sets the decision", func() {
|
||||||
|
It("obeys true, ignoring the annotation and the marker file", func() {
|
||||||
|
// annotation would skip the check and the marker is absent, yet the
|
||||||
|
// operator's explicit true must still win.
|
||||||
|
got, err := resolveArchiveEmptyWalArchiveCheck(
|
||||||
|
ptr.To(true), clusterWith(ptr.To("enabled")), markerPath(false))
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
Expect(got).To(BeTrue())
|
||||||
|
})
|
||||||
|
|
||||||
|
It("obeys false, ignoring the annotation and the marker file", func() {
|
||||||
|
// annotation would keep the check on and the marker is present, yet the
|
||||||
|
// operator's explicit false must still win.
|
||||||
|
got, err := resolveArchiveEmptyWalArchiveCheck(
|
||||||
|
ptr.To(false), clusterWith(nil), markerPath(true))
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
Expect(got).To(BeFalse())
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
When("the operator predates the field (nil decision)", func() {
|
||||||
|
DescribeTable(
|
||||||
|
"falls back to the annotation combined with the marker file",
|
||||||
|
func(annotationValue *string, markerPresent bool, expected bool) {
|
||||||
|
got, err := resolveArchiveEmptyWalArchiveCheck(
|
||||||
|
nil, clusterWith(annotationValue), markerPath(markerPresent))
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
Expect(got).To(Equal(expected))
|
||||||
|
},
|
||||||
|
Entry("no annotation and marker present: check runs", nil, true, true),
|
||||||
|
Entry("no annotation and marker absent: check skipped", nil, false, false),
|
||||||
|
Entry("opt-out annotation and marker present: check skipped", ptr.To("enabled"), true, false),
|
||||||
|
Entry("unrelated annotation value and marker present: check runs", ptr.To("something-else"), true, true),
|
||||||
|
Entry("empty annotation value and marker present: check runs", ptr.To(""), true, true),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|||||||
@ -63,7 +63,7 @@ const (
|
|||||||
// Data is the metadata of this plugin.
|
// Data is the metadata of this plugin.
|
||||||
var Data = identity.GetPluginMetadataResponse{
|
var Data = identity.GetPluginMetadataResponse{
|
||||||
Name: PluginName,
|
Name: PluginName,
|
||||||
Version: "0.13.0", // x-release-please-version
|
Version: "0.14.0", // x-release-please-version
|
||||||
DisplayName: "BarmanCloudInstance",
|
DisplayName: "BarmanCloudInstance",
|
||||||
ProjectUrl: "https://github.com/cloudnative-pg/plugin-barman-cloud",
|
ProjectUrl: "https://github.com/cloudnative-pg/plugin-barman-cloud",
|
||||||
RepositoryUrl: "https://github.com/cloudnative-pg/plugin-barman-cloud",
|
RepositoryUrl: "https://github.com/cloudnative-pg/plugin-barman-cloud",
|
||||||
|
|||||||
@ -113,6 +113,7 @@ func (impl JobHookImpl) Restore(
|
|||||||
configuration.Cluster,
|
configuration.Cluster,
|
||||||
&targetObjectStore.Spec.Configuration,
|
&targetObjectStore.Spec.Configuration,
|
||||||
targetObjectStore.Name,
|
targetObjectStore.Name,
|
||||||
|
req.CheckEmptyWalArchive,
|
||||||
); err != nil {
|
); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -250,6 +251,7 @@ func (impl *JobHookImpl) checkBackupDestination(
|
|||||||
cluster *cnpgv1.Cluster,
|
cluster *cnpgv1.Cluster,
|
||||||
barmanConfiguration *cnpgv1.BarmanObjectStoreConfiguration,
|
barmanConfiguration *cnpgv1.BarmanObjectStoreConfiguration,
|
||||||
objectStoreName string,
|
objectStoreName string,
|
||||||
|
operatorCheckEmptyWalArchive *bool,
|
||||||
) error {
|
) error {
|
||||||
// Get environment from cache
|
// Get environment from cache
|
||||||
env, err := barmanCredentials.EnvSetCloudCredentialsAndCertificates(ctx,
|
env, err := barmanCredentials.EnvSetCloudCredentialsAndCertificates(ctx,
|
||||||
@ -288,14 +290,26 @@ func (impl *JobHookImpl) checkBackupDestination(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if we're ok to archive in the desired destination
|
if resolveRestoreEmptyWalArchiveCheck(operatorCheckEmptyWalArchive, cluster) {
|
||||||
if utils.IsEmptyWalArchiveCheckEnabled(&cluster.ObjectMeta) {
|
|
||||||
return common.CheckBackupDestination(ctx, barmanConfiguration, walArchiver, serverName)
|
return common.CheckBackupDestination(ctx, barmanConfiguration, walArchiver, serverName)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// resolveRestoreEmptyWalArchiveCheck reports whether the destination must be
|
||||||
|
// verified before restoring. When the operator sets the decision (non-nil) it
|
||||||
|
// is obeyed as-is; a nil value comes from an operator that predates this field,
|
||||||
|
// so we fall back to the Cluster annotation. Unlike archiving, restore is a
|
||||||
|
// one-shot operation that has never been gated on the first-archive marker
|
||||||
|
// file, so the annotation is the only fallback needed.
|
||||||
|
func resolveRestoreEmptyWalArchiveCheck(operatorDecision *bool, cluster *cnpgv1.Cluster) bool {
|
||||||
|
if operatorDecision != nil {
|
||||||
|
return *operatorDecision
|
||||||
|
}
|
||||||
|
return utils.IsEmptyWalArchiveCheckEnabled(&cluster.ObjectMeta)
|
||||||
|
}
|
||||||
|
|
||||||
// restoreCustomWalDir moves the current pg_wal data to the specified custom wal dir and applies the symlink
|
// restoreCustomWalDir moves the current pg_wal data to the specified custom wal dir and applies the symlink
|
||||||
// returns indicating if any changes were made and any error encountered in the process
|
// returns indicating if any changes were made and any error encountered in the process
|
||||||
func (impl JobHookImpl) restoreCustomWalDir(ctx context.Context) (bool, error) {
|
func (impl JobHookImpl) restoreCustomWalDir(ctx context.Context) (bool, error) {
|
||||||
|
|||||||
66
internal/cnpgi/restore/restore_test.go
Normal file
66
internal/cnpgi/restore/restore_test.go
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
/*
|
||||||
|
Copyright © contributors to CloudNativePG, established as
|
||||||
|
CloudNativePG a Series of LF Projects, LLC.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
package restore
|
||||||
|
|
||||||
|
import (
|
||||||
|
cnpgv1 "github.com/cloudnative-pg/cloudnative-pg/api/v1"
|
||||||
|
"k8s.io/utils/ptr"
|
||||||
|
|
||||||
|
. "github.com/onsi/ginkgo/v2"
|
||||||
|
. "github.com/onsi/gomega"
|
||||||
|
)
|
||||||
|
|
||||||
|
var _ = Describe("resolveRestoreEmptyWalArchiveCheck", func() {
|
||||||
|
// skipAnnotation mirrors the unexported constant in cloudnative-pg's
|
||||||
|
// pkg/utils; hard-coding the literal makes a divergence surface as a
|
||||||
|
// failing test rather than silently disabling the check.
|
||||||
|
const skipAnnotation = "cnpg.io/skipEmptyWalArchiveCheck"
|
||||||
|
|
||||||
|
clusterWith := func(annotationValue *string) *cnpgv1.Cluster {
|
||||||
|
cluster := &cnpgv1.Cluster{}
|
||||||
|
if annotationValue != nil {
|
||||||
|
cluster.Annotations = map[string]string{skipAnnotation: *annotationValue}
|
||||||
|
}
|
||||||
|
return cluster
|
||||||
|
}
|
||||||
|
|
||||||
|
When("the operator sets the decision", func() {
|
||||||
|
It("obeys true even when the annotation would skip the check", func() {
|
||||||
|
Expect(resolveRestoreEmptyWalArchiveCheck(ptr.To(true), clusterWith(ptr.To("enabled")))).To(BeTrue())
|
||||||
|
})
|
||||||
|
|
||||||
|
It("obeys false even when the annotation would keep the check on", func() {
|
||||||
|
Expect(resolveRestoreEmptyWalArchiveCheck(ptr.To(false), clusterWith(nil))).To(BeFalse())
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
When("the operator predates the field (nil decision)", func() {
|
||||||
|
DescribeTable(
|
||||||
|
"falls back to the Cluster annotation, never to a marker file",
|
||||||
|
func(annotationValue *string, expected bool) {
|
||||||
|
Expect(resolveRestoreEmptyWalArchiveCheck(nil, clusterWith(annotationValue))).To(Equal(expected))
|
||||||
|
},
|
||||||
|
Entry("no annotation: check runs", nil, true),
|
||||||
|
Entry("opt-out annotation: check skipped", ptr.To("enabled"), false),
|
||||||
|
Entry("unrelated annotation value: check runs", ptr.To("something-else"), true),
|
||||||
|
Entry("empty annotation value: check runs", ptr.To(""), true),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
})
|
||||||
32
internal/cnpgi/restore/suite_test.go
Normal file
32
internal/cnpgi/restore/suite_test.go
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
Copyright © contributors to CloudNativePG, established as
|
||||||
|
CloudNativePG a Series of LF Projects, LLC.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
package restore
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
. "github.com/onsi/ginkgo/v2"
|
||||||
|
. "github.com/onsi/gomega"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestRestore(t *testing.T) {
|
||||||
|
RegisterFailHandler(Fail)
|
||||||
|
RunSpecs(t, "Restore job hook test suite")
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user