mirror of
https://github.com/cloudnative-pg/plugin-barman-cloud.git
synced 2026-07-08 18:52:20 +02:00
Compare commits
8 Commits
fe66e0e01f
...
27aa177b33
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
27aa177b33 | ||
|
|
0bb78879ce | ||
|
|
ef4b711137 | ||
|
|
baf7985d66 | ||
|
|
d244faa5b2 | ||
|
|
97675a7685 | ||
|
|
1eeed9f783 | ||
|
|
6ec77fb159 |
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@ -44,7 +44,7 @@ jobs:
|
|||||||
- name: Install Dagger
|
- name: Install Dagger
|
||||||
env:
|
env:
|
||||||
# renovate: datasource=github-tags depName=dagger/dagger versioning=semver
|
# renovate: datasource=github-tags depName=dagger/dagger versioning=semver
|
||||||
DAGGER_VERSION: 0.20.8
|
DAGGER_VERSION: 0.21.0
|
||||||
run: |
|
run: |
|
||||||
curl -L https://dl.dagger.io/dagger/install.sh | BIN_DIR=$HOME/.local/bin sh
|
curl -L https://dl.dagger.io/dagger/install.sh | BIN_DIR=$HOME/.local/bin sh
|
||||||
- name: Run CI task
|
- name: Run CI task
|
||||||
|
|||||||
2
.github/workflows/release-please.yml
vendored
2
.github/workflows/release-please.yml
vendored
@ -31,7 +31,7 @@ jobs:
|
|||||||
- name: Install Dagger
|
- name: Install Dagger
|
||||||
env:
|
env:
|
||||||
# renovate: datasource=github-tags depName=dagger/dagger versioning=semver
|
# renovate: datasource=github-tags depName=dagger/dagger versioning=semver
|
||||||
DAGGER_VERSION: 0.20.8
|
DAGGER_VERSION: 0.21.0
|
||||||
run: |
|
run: |
|
||||||
curl -L https://dl.dagger.io/dagger/install.sh | BIN_DIR=$HOME/.local/bin sh
|
curl -L https://dl.dagger.io/dagger/install.sh | BIN_DIR=$HOME/.local/bin sh
|
||||||
- name: Create image and manifest
|
- name: Create image and manifest
|
||||||
|
|||||||
2
.github/workflows/release-publish.yml
vendored
2
.github/workflows/release-publish.yml
vendored
@ -21,7 +21,7 @@ jobs:
|
|||||||
- name: Install Dagger
|
- name: Install Dagger
|
||||||
env:
|
env:
|
||||||
# renovate: datasource=github-tags depName=dagger/dagger versioning=semver
|
# renovate: datasource=github-tags depName=dagger/dagger versioning=semver
|
||||||
DAGGER_VERSION: 0.20.8
|
DAGGER_VERSION: 0.21.0
|
||||||
run: |
|
run: |
|
||||||
curl -L https://dl.dagger.io/dagger/install.sh | BIN_DIR=$HOME/.local/bin sh
|
curl -L https://dl.dagger.io/dagger/install.sh | BIN_DIR=$HOME/.local/bin sh
|
||||||
- name: Create image and manifest
|
- name: Create image and manifest
|
||||||
|
|||||||
2
Makefile
2
Makefile
@ -159,7 +159,7 @@ GOLANGCI_LINT = $(LOCALBIN)/golangci-lint
|
|||||||
|
|
||||||
## Tool Versions
|
## Tool Versions
|
||||||
KUSTOMIZE_VERSION ?= v5.4.3
|
KUSTOMIZE_VERSION ?= v5.4.3
|
||||||
CONTROLLER_TOOLS_VERSION ?= v0.16.1
|
CONTROLLER_TOOLS_VERSION ?= v0.19.0
|
||||||
ENVTEST_VERSION ?= release-0.19
|
ENVTEST_VERSION ?= release-0.19
|
||||||
GOLANGCI_LINT_VERSION ?= v1.64.8
|
GOLANGCI_LINT_VERSION ?= v1.64.8
|
||||||
|
|
||||||
|
|||||||
12
Taskfile.yml
12
Taskfile.yml
@ -46,7 +46,7 @@ tasks:
|
|||||||
- wordlist-ordered
|
- wordlist-ordered
|
||||||
env:
|
env:
|
||||||
# renovate: datasource=git-refs depName=spellcheck lookupName=https://github.com/cloudnative-pg/daggerverse currentValue=main
|
# renovate: datasource=git-refs depName=spellcheck lookupName=https://github.com/cloudnative-pg/daggerverse currentValue=main
|
||||||
DAGGER_SPELLCHECK_SHA: 537e0ddae55ad0344af8f4454de7f27baeee48fa
|
DAGGER_SPELLCHECK_SHA: 21755df1a27febff19b28dbe6ae57116f6088bb0
|
||||||
cmds:
|
cmds:
|
||||||
- >
|
- >
|
||||||
GITHUB_REF= dagger -s call -m github.com/cloudnative-pg/daggerverse/spellcheck@${DAGGER_SPELLCHECK_SHA}
|
GITHUB_REF= dagger -s call -m github.com/cloudnative-pg/daggerverse/spellcheck@${DAGGER_SPELLCHECK_SHA}
|
||||||
@ -60,7 +60,7 @@ tasks:
|
|||||||
desc: Check for conventional commits
|
desc: Check for conventional commits
|
||||||
env:
|
env:
|
||||||
# renovate: datasource=git-refs depName=commitlint lookupName=https://github.com/cloudnative-pg/daggerverse currentValue=main
|
# renovate: datasource=git-refs depName=commitlint lookupName=https://github.com/cloudnative-pg/daggerverse currentValue=main
|
||||||
DAGGER_COMMITLINT_SHA: 537e0ddae55ad0344af8f4454de7f27baeee48fa
|
DAGGER_COMMITLINT_SHA: 21755df1a27febff19b28dbe6ae57116f6088bb0
|
||||||
cmds:
|
cmds:
|
||||||
- >
|
- >
|
||||||
GITHUB_REF= dagger -s call -m github.com/cloudnative-pg/daggerverse/commitlint@${DAGGER_COMMITLINT_SHA}
|
GITHUB_REF= dagger -s call -m github.com/cloudnative-pg/daggerverse/commitlint@${DAGGER_COMMITLINT_SHA}
|
||||||
@ -74,7 +74,7 @@ tasks:
|
|||||||
- wordlist-ordered
|
- wordlist-ordered
|
||||||
env:
|
env:
|
||||||
# renovate: datasource=git-refs depName=uncommitted lookupName=https://github.com/cloudnative-pg/daggerverse currentValue=main
|
# renovate: datasource=git-refs depName=uncommitted lookupName=https://github.com/cloudnative-pg/daggerverse currentValue=main
|
||||||
DAGGER_UNCOMMITTED_SHA: 537e0ddae55ad0344af8f4454de7f27baeee48fa
|
DAGGER_UNCOMMITTED_SHA: 21755df1a27febff19b28dbe6ae57116f6088bb0
|
||||||
cmds:
|
cmds:
|
||||||
- GITHUB_REF= dagger -s call -m github.com/cloudnative-pg/daggerverse/uncommitted@${DAGGER_UNCOMMITTED_SHA} check-uncommitted --source . stdout
|
- GITHUB_REF= dagger -s call -m github.com/cloudnative-pg/daggerverse/uncommitted@${DAGGER_UNCOMMITTED_SHA} check-uncommitted --source . stdout
|
||||||
sources:
|
sources:
|
||||||
@ -86,7 +86,7 @@ tasks:
|
|||||||
- controller-gen
|
- controller-gen
|
||||||
env:
|
env:
|
||||||
# renovate: datasource=git-refs depName=crd-gen-refs lookupName=https://github.com/cloudnative-pg/daggerverse currentValue=main
|
# renovate: datasource=git-refs depName=crd-gen-refs lookupName=https://github.com/cloudnative-pg/daggerverse currentValue=main
|
||||||
DAGGER_CRDGENREF_SHA: 537e0ddae55ad0344af8f4454de7f27baeee48fa
|
DAGGER_CRDGENREF_SHA: 21755df1a27febff19b28dbe6ae57116f6088bb0
|
||||||
# renovate: datasource=go depName=github.com/elastic/crd-ref-docs
|
# renovate: datasource=go depName=github.com/elastic/crd-ref-docs
|
||||||
CRDREFDOCS_VERSION: v0.3.0
|
CRDREFDOCS_VERSION: v0.3.0
|
||||||
cmds:
|
cmds:
|
||||||
@ -206,7 +206,7 @@ tasks:
|
|||||||
- start-build-network
|
- start-build-network
|
||||||
vars:
|
vars:
|
||||||
# renovate: datasource=github-tags depName=dagger/dagger versioning=semver
|
# renovate: datasource=github-tags depName=dagger/dagger versioning=semver
|
||||||
DAGGER_VERSION: 0.20.8
|
DAGGER_VERSION: 0.21.0
|
||||||
DAGGER_ENGINE_IMAGE: registry.dagger.io/engine:v{{ .DAGGER_VERSION }}
|
DAGGER_ENGINE_IMAGE: registry.dagger.io/engine:v{{ .DAGGER_VERSION }}
|
||||||
cmds:
|
cmds:
|
||||||
- >
|
- >
|
||||||
@ -381,7 +381,7 @@ tasks:
|
|||||||
run: once
|
run: once
|
||||||
env:
|
env:
|
||||||
# renovate: datasource=git-refs depName=controller-gen lookupName=https://github.com/cloudnative-pg/daggerverse currentValue=main
|
# renovate: datasource=git-refs depName=controller-gen lookupName=https://github.com/cloudnative-pg/daggerverse currentValue=main
|
||||||
DAGGER_CONTROLLER_GEN_SHA: 537e0ddae55ad0344af8f4454de7f27baeee48fa
|
DAGGER_CONTROLLER_GEN_SHA: 21755df1a27febff19b28dbe6ae57116f6088bb0
|
||||||
cmds:
|
cmds:
|
||||||
- >
|
- >
|
||||||
GITHUB_REF= dagger -s call -m github.com/cloudnative-pg/daggerverse/controller-gen@${DAGGER_CONTROLLER_GEN_SHA}
|
GITHUB_REF= dagger -s call -m github.com/cloudnative-pg/daggerverse/controller-gen@${DAGGER_CONTROLLER_GEN_SHA}
|
||||||
|
|||||||
@ -94,6 +94,9 @@ type RecoveryWindow struct {
|
|||||||
|
|
||||||
// The last failed backup time
|
// The last failed backup time
|
||||||
LastFailedBackupTime *metav1.Time `json:"lastFailedBackupTime,omitempty"`
|
LastFailedBackupTime *metav1.Time `json:"lastFailedBackupTime,omitempty"`
|
||||||
|
|
||||||
|
// The last time a WAL file was successfully archived by this plugin
|
||||||
|
LastArchivedWALTime *metav1.Time `json:"lastArchivedWALTime,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// +kubebuilder:object:root=true
|
// +kubebuilder:object:root=true
|
||||||
|
|||||||
@ -169,6 +169,10 @@ func (in *RecoveryWindow) DeepCopyInto(out *RecoveryWindow) {
|
|||||||
in, out := &in.LastFailedBackupTime, &out.LastFailedBackupTime
|
in, out := &in.LastFailedBackupTime, &out.LastFailedBackupTime
|
||||||
*out = (*in).DeepCopy()
|
*out = (*in).DeepCopy()
|
||||||
}
|
}
|
||||||
|
if in.LastArchivedWALTime != nil {
|
||||||
|
in, out := &in.LastArchivedWALTime, &out.LastArchivedWALTime
|
||||||
|
*out = (*in).DeepCopy()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RecoveryWindow.
|
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RecoveryWindow.
|
||||||
|
|||||||
@ -677,6 +677,11 @@ spec:
|
|||||||
restored.
|
restored.
|
||||||
format: date-time
|
format: date-time
|
||||||
type: string
|
type: string
|
||||||
|
lastArchivedWALTime:
|
||||||
|
description: The last time a WAL file was successfully archived
|
||||||
|
by this plugin
|
||||||
|
format: date-time
|
||||||
|
type: string
|
||||||
lastFailedBackupTime:
|
lastFailedBackupTime:
|
||||||
description: The last failed backup time
|
description: The last failed backup time
|
||||||
format: date-time
|
format: date-time
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
barman[azure,cloud,google,snappy,zstandard,lz4]==3.18.0
|
barman[azure,cloud,google,snappy,zstandard,lz4]==3.19.1
|
||||||
setuptools==82.0.1
|
setuptools==82.0.1
|
||||||
zipp>=3.19.1 # not directly required, pinned by Snyk to avoid a vulnerability
|
zipp>=3.19.1 # not directly required, pinned by Snyk to avoid a vulnerability
|
||||||
|
|||||||
@ -18,9 +18,9 @@ azure-storage-blob==12.29.0 \
|
|||||||
--hash=sha256:2824ddd7ebc9056034ebc76b17971a38e9aa5835abb0d565b9700493f2a6c657 \
|
--hash=sha256:2824ddd7ebc9056034ebc76b17971a38e9aa5835abb0d565b9700493f2a6c657 \
|
||||||
--hash=sha256:ccf8a1bcd5e49df83ab85aab793b579e5ba2eeea2ad8900b2f62ca3a37dc391f
|
--hash=sha256:ccf8a1bcd5e49df83ab85aab793b579e5ba2eeea2ad8900b2f62ca3a37dc391f
|
||||||
# via barman
|
# via barman
|
||||||
barman==3.18.0 \
|
barman==3.19.1 \
|
||||||
--hash=sha256:8e752ac93d2f3a61e86b8374185209cae477a638ece7e6f540070f36d28d6997 \
|
--hash=sha256:0a6a9e1babf97687732d8b2a3eb79ea95d55246a5257b9433865cb6e755221c0 \
|
||||||
--hash=sha256:ff90c44dafa4107b7574142771cdc2611c4cf1af818d93d3e67440a0c81164b9
|
--hash=sha256:2f71c4a1f1ba53f694cbdf838bb9906d8ba02b97d1fd3041196e8999bec7a1ee
|
||||||
# via -r sidecar-requirements.in
|
# via -r sidecar-requirements.in
|
||||||
boto3==1.43.14 \
|
boto3==1.43.14 \
|
||||||
--hash=sha256:574335744656cfed0b362a0a0467aaf2eb2bf15526edcd02d31d3c661f4b09e4 \
|
--hash=sha256:574335744656cfed0b362a0a0467aaf2eb2bf15526edcd02d31d3c661f4b09e4 \
|
||||||
@ -788,6 +788,4 @@ zstandard==0.25.0 \
|
|||||||
setuptools==82.0.1 \
|
setuptools==82.0.1 \
|
||||||
--hash=sha256:7d872682c5d01cfde07da7bccc7b65469d3dca203318515ada1de5eda35efbf9 \
|
--hash=sha256:7d872682c5d01cfde07da7bccc7b65469d3dca203318515ada1de5eda35efbf9 \
|
||||||
--hash=sha256:a59e362652f08dcd477c78bb6e7bd9d80a7995bc73ce773050228a348ce2e5bb
|
--hash=sha256:a59e362652f08dcd477c78bb6e7bd9d80a7995bc73ce773050228a348ce2e5bb
|
||||||
# via
|
# via -r sidecar-requirements.in
|
||||||
# -r sidecar-requirements.in
|
|
||||||
# barman
|
|
||||||
|
|||||||
4
go.mod
4
go.mod
@ -9,7 +9,7 @@ require (
|
|||||||
github.com/cloudnative-pg/cloudnative-pg v1.29.1
|
github.com/cloudnative-pg/cloudnative-pg v1.29.1
|
||||||
github.com/cloudnative-pg/cnpg-i v0.5.0
|
github.com/cloudnative-pg/cnpg-i v0.5.0
|
||||||
github.com/cloudnative-pg/cnpg-i-machinery v0.4.2
|
github.com/cloudnative-pg/cnpg-i-machinery v0.4.2
|
||||||
github.com/cloudnative-pg/machinery v0.4.0
|
github.com/cloudnative-pg/machinery v0.5.0
|
||||||
github.com/onsi/ginkgo/v2 v2.29.0
|
github.com/onsi/ginkgo/v2 v2.29.0
|
||||||
github.com/onsi/gomega v1.41.0
|
github.com/onsi/gomega v1.41.0
|
||||||
github.com/spf13/cobra v1.10.2
|
github.com/spf13/cobra v1.10.2
|
||||||
@ -114,7 +114,7 @@ require (
|
|||||||
golang.org/x/net v0.53.0 // indirect
|
golang.org/x/net v0.53.0 // indirect
|
||||||
golang.org/x/oauth2 v0.36.0 // indirect
|
golang.org/x/oauth2 v0.36.0 // indirect
|
||||||
golang.org/x/sync v0.20.0 // indirect
|
golang.org/x/sync v0.20.0 // indirect
|
||||||
golang.org/x/sys v0.43.0 // indirect
|
golang.org/x/sys v0.45.0 // indirect
|
||||||
golang.org/x/term v0.42.0 // indirect
|
golang.org/x/term v0.42.0 // indirect
|
||||||
golang.org/x/text v0.36.0 // indirect
|
golang.org/x/text v0.36.0 // indirect
|
||||||
golang.org/x/time v0.15.0 // indirect
|
golang.org/x/time v0.15.0 // indirect
|
||||||
|
|||||||
8
go.sum
8
go.sum
@ -28,8 +28,8 @@ github.com/cloudnative-pg/cnpg-i v0.5.0 h1:/TOzpNT6cwNgrpftTtrnLKdoHgMwd+88vZgXj
|
|||||||
github.com/cloudnative-pg/cnpg-i v0.5.0/go.mod h1:7Gh4+UzhBpGhr4DreB1GN9wGYfvxwXCXZUyVt3zE/3I=
|
github.com/cloudnative-pg/cnpg-i v0.5.0/go.mod h1:7Gh4+UzhBpGhr4DreB1GN9wGYfvxwXCXZUyVt3zE/3I=
|
||||||
github.com/cloudnative-pg/cnpg-i-machinery v0.4.2 h1:0reS9MtyLYINHXQ/MfxJ9jp39hhBf8e3Qdj+T5Nsq6I=
|
github.com/cloudnative-pg/cnpg-i-machinery v0.4.2 h1:0reS9MtyLYINHXQ/MfxJ9jp39hhBf8e3Qdj+T5Nsq6I=
|
||||||
github.com/cloudnative-pg/cnpg-i-machinery v0.4.2/go.mod h1:gvrKabgxXq0zGthXGucemDdsxakLEQDMxn43M4HLW30=
|
github.com/cloudnative-pg/cnpg-i-machinery v0.4.2/go.mod h1:gvrKabgxXq0zGthXGucemDdsxakLEQDMxn43M4HLW30=
|
||||||
github.com/cloudnative-pg/machinery v0.4.0 h1:3sfqrBptH4QQSVB4g10Z+7aiQRnh4g+6AsqsK0ibKaQ=
|
github.com/cloudnative-pg/machinery v0.5.0 h1:hhTnkzn+AiN3NmbjCQ6RXj5rfqV3K6arzq6kdXAzcnQ=
|
||||||
github.com/cloudnative-pg/machinery v0.4.0/go.mod h1:OIwaTYAnLv8PmBmBvEf0BvMK2JBX6J+naTMg9UgV1FQ=
|
github.com/cloudnative-pg/machinery v0.5.0/go.mod h1:uuFjqBUjWn0a9uvAk1ixTSzPM0PrjaS+QiKLOIBqLm4=
|
||||||
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
|
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
@ -275,8 +275,8 @@ golang.org/x/oauth2 v0.36.0 h1:peZ/1z27fi9hUOFCAZaHyrpWG5lwe0RJEEEeH0ThlIs=
|
|||||||
golang.org/x/oauth2 v0.36.0/go.mod h1:YDBUJMTkDnJS+A4BP4eZBjCqtokkg1hODuPjwiGPO7Q=
|
golang.org/x/oauth2 v0.36.0/go.mod h1:YDBUJMTkDnJS+A4BP4eZBjCqtokkg1hODuPjwiGPO7Q=
|
||||||
golang.org/x/sync v0.20.0 h1:e0PTpb7pjO8GAtTs2dQ6jYa5BWYlMuX047Dco/pItO4=
|
golang.org/x/sync v0.20.0 h1:e0PTpb7pjO8GAtTs2dQ6jYa5BWYlMuX047Dco/pItO4=
|
||||||
golang.org/x/sync v0.20.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
|
golang.org/x/sync v0.20.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
|
||||||
golang.org/x/sys v0.43.0 h1:Rlag2XtaFTxp19wS8MXlJwTvoh8ArU6ezoyFsMyCTNI=
|
golang.org/x/sys v0.45.0 h1:dO4czNzziLiiXplLQgBCEpCvXQ3dnkn0SdaZSYdQ+FY=
|
||||||
golang.org/x/sys v0.43.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
|
golang.org/x/sys v0.45.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
|
||||||
golang.org/x/term v0.42.0 h1:UiKe+zDFmJobeJ5ggPwOshJIVt6/Ft0rcfrXZDLWAWY=
|
golang.org/x/term v0.42.0 h1:UiKe+zDFmJobeJ5ggPwOshJIVt6/Ft0rcfrXZDLWAWY=
|
||||||
golang.org/x/term v0.42.0/go.mod h1:Dq/D+snpsbazcBG5+F9Q1n2rXV8Ma+71xEjTRufARgY=
|
golang.org/x/term v0.42.0/go.mod h1:Dq/D+snpsbazcBG5+F9Q1n2rXV8Ma+71xEjTRufARgY=
|
||||||
golang.org/x/text v0.36.0 h1:JfKh3XmcRPqZPKevfXVpI1wXPTqbkE5f7JA92a55Yxg=
|
golang.org/x/text v0.36.0 h1:JfKh3XmcRPqZPKevfXVpI1wXPTqbkE5f7JA92a55Yxg=
|
||||||
|
|||||||
@ -25,6 +25,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/cloudnative-pg/barman-cloud/pkg/archiver"
|
"github.com/cloudnative-pg/barman-cloud/pkg/archiver"
|
||||||
@ -38,7 +39,10 @@ import (
|
|||||||
walUtils "github.com/cloudnative-pg/machinery/pkg/fileutils/wals"
|
walUtils "github.com/cloudnative-pg/machinery/pkg/fileutils/wals"
|
||||||
"github.com/cloudnative-pg/machinery/pkg/log"
|
"github.com/cloudnative-pg/machinery/pkg/log"
|
||||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
|
"k8s.io/client-go/util/retry"
|
||||||
|
"k8s.io/utils/ptr"
|
||||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||||
|
|
||||||
barmancloudv1 "github.com/cloudnative-pg/plugin-barman-cloud/api/v1"
|
barmancloudv1 "github.com/cloudnative-pg/plugin-barman-cloud/api/v1"
|
||||||
@ -67,6 +71,11 @@ func (e *SpoolManagementError) Unwrap() error {
|
|||||||
return e.err
|
return e.err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
// walStatusUpdateThrottle is the minimum time between status updates for WAL archiving
|
||||||
|
walStatusUpdateThrottle = 5 * time.Minute
|
||||||
|
)
|
||||||
|
|
||||||
// WALServiceImplementation is the implementation of the WAL Service
|
// WALServiceImplementation is the implementation of the WAL Service
|
||||||
type WALServiceImplementation struct {
|
type WALServiceImplementation struct {
|
||||||
wal.UnimplementedWALServer
|
wal.UnimplementedWALServer
|
||||||
@ -75,6 +84,9 @@ type WALServiceImplementation struct {
|
|||||||
SpoolDirectory string
|
SpoolDirectory string
|
||||||
PGDataPath string
|
PGDataPath string
|
||||||
PGWALPath string
|
PGWALPath string
|
||||||
|
// LastStatusUpdate tracks the last time we updated the status for each ObjectStore+ServerName
|
||||||
|
// Key format: "namespace/objectStoreName/serverName"
|
||||||
|
LastStatusUpdate *sync.Map
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetCapabilities implements the WALService interface
|
// GetCapabilities implements the WALService interface
|
||||||
@ -102,6 +114,37 @@ func (w WALServiceImplementation) GetCapabilities(
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// shouldUpdateStatus checks if we should update the status based on the throttle.
|
||||||
|
// It returns true if walStatusUpdateThrottle minutes have passed since the last update, or if this is the first update.
|
||||||
|
func (w WALServiceImplementation) shouldUpdateStatus(objectStoreKey client.ObjectKey, serverName string) bool {
|
||||||
|
if w.LastStatusUpdate == nil {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
key := fmt.Sprintf("%s/%s", objectStoreKey.String(), serverName)
|
||||||
|
lastUpdate, ok := w.LastStatusUpdate.Load(key)
|
||||||
|
if !ok {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
lastUpdateTime, ok := lastUpdate.(time.Time)
|
||||||
|
if !ok {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return time.Since(lastUpdateTime) >= walStatusUpdateThrottle
|
||||||
|
}
|
||||||
|
|
||||||
|
// recordStatusUpdate records that we just updated the status for a given ObjectStore and server.
|
||||||
|
func (w WALServiceImplementation) recordStatusUpdate(objectStoreKey client.ObjectKey, serverName string) {
|
||||||
|
if w.LastStatusUpdate == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
key := fmt.Sprintf("%s/%s", objectStoreKey.String(), serverName)
|
||||||
|
w.LastStatusUpdate.Store(key, time.Now())
|
||||||
|
}
|
||||||
|
|
||||||
// Archive implements the WALService interface
|
// Archive implements the WALService interface
|
||||||
func (w WALServiceImplementation) Archive(
|
func (w WALServiceImplementation) Archive(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
@ -220,6 +263,28 @@ func (w WALServiceImplementation) Archive(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update the last archived WAL time in the ObjectStore status
|
||||||
|
// Only update if walStatusUpdateThrottle minutes have passed since the last update to avoid hitting the API server too often
|
||||||
|
objectStoreKey := configuration.GetBarmanObjectKey()
|
||||||
|
if w.shouldUpdateStatus(objectStoreKey, configuration.ServerName) {
|
||||||
|
contextLogger.Debug("Updating last archived WAL time", "serverName", configuration.ServerName)
|
||||||
|
if err := setLastArchivedWALTime(
|
||||||
|
ctx,
|
||||||
|
w.Client,
|
||||||
|
objectStoreKey,
|
||||||
|
configuration.ServerName,
|
||||||
|
time.Now(),
|
||||||
|
); err != nil {
|
||||||
|
// Log the error but don't fail the archive operation
|
||||||
|
contextLogger.Error(err, "Error updating last archived WAL time in ObjectStore status")
|
||||||
|
} else {
|
||||||
|
contextLogger.Debug("Successfully updated last archived WAL time")
|
||||||
|
w.recordStatusUpdate(objectStoreKey, configuration.ServerName)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
contextLogger.Debug("Skipping status update due to throttle", "serverName", configuration.ServerName)
|
||||||
|
}
|
||||||
|
|
||||||
return &wal.WALArchiveResult{}, nil
|
return &wal.WALArchiveResult{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -509,3 +574,30 @@ func isEndOfWALStream(results []barmanRestorer.Result) bool {
|
|||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetLastArchivedWALTime sets the last archived WAL time in the
|
||||||
|
// passed object store, for the passed server name.
|
||||||
|
func setLastArchivedWALTime(
|
||||||
|
ctx context.Context,
|
||||||
|
c client.Client,
|
||||||
|
objectStoreKey client.ObjectKey,
|
||||||
|
serverName string,
|
||||||
|
lastArchivedWALTime time.Time,
|
||||||
|
) error {
|
||||||
|
return retry.RetryOnConflict(retry.DefaultBackoff, func() error {
|
||||||
|
var objectStore barmancloudv1.ObjectStore
|
||||||
|
|
||||||
|
if err := c.Get(ctx, objectStoreKey, &objectStore); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
recoveryWindow := objectStore.Status.ServerRecoveryWindow[serverName]
|
||||||
|
recoveryWindow.LastArchivedWALTime = ptr.To(metav1.NewTime(lastArchivedWALTime))
|
||||||
|
|
||||||
|
if objectStore.Status.ServerRecoveryWindow == nil {
|
||||||
|
objectStore.Status.ServerRecoveryWindow = make(map[string]barmancloudv1.RecoveryWindow)
|
||||||
|
}
|
||||||
|
objectStore.Status.ServerRecoveryWindow[serverName] = recoveryWindow
|
||||||
|
|
||||||
|
return c.Status().Update(ctx, &objectStore)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@ -51,6 +51,7 @@ var (
|
|||||||
firstRecoverabilityPointMetricName = buildFqName("first_recoverability_point")
|
firstRecoverabilityPointMetricName = buildFqName("first_recoverability_point")
|
||||||
lastAvailableBackupTimestampMetricName = buildFqName("last_available_backup_timestamp")
|
lastAvailableBackupTimestampMetricName = buildFqName("last_available_backup_timestamp")
|
||||||
lastFailedBackupTimestampMetricName = buildFqName("last_failed_backup_timestamp")
|
lastFailedBackupTimestampMetricName = buildFqName("last_failed_backup_timestamp")
|
||||||
|
lastArchivedWALTimestampMetricName = buildFqName("last_archived_wal_timestamp")
|
||||||
)
|
)
|
||||||
|
|
||||||
func (m metricsImpl) GetCapabilities(
|
func (m metricsImpl) GetCapabilities(
|
||||||
@ -97,6 +98,11 @@ func (m metricsImpl) Define(
|
|||||||
Help: "The last failed backup as a unix timestamp",
|
Help: "The last failed backup as a unix timestamp",
|
||||||
ValueType: &metrics.MetricType{Type: metrics.MetricType_TYPE_GAUGE},
|
ValueType: &metrics.MetricType{Type: metrics.MetricType_TYPE_GAUGE},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
FqName: lastArchivedWALTimestampMetricName,
|
||||||
|
Help: "The last archived WAL timestamp as a unix timestamp",
|
||||||
|
ValueType: &metrics.MetricType{Type: metrics.MetricType_TYPE_GAUGE},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
@ -136,6 +142,10 @@ func (m metricsImpl) Collect(
|
|||||||
FqName: lastFailedBackupTimestampMetricName,
|
FqName: lastFailedBackupTimestampMetricName,
|
||||||
Value: 0,
|
Value: 0,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
FqName: lastArchivedWALTimestampMetricName,
|
||||||
|
Value: 0,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
@ -143,6 +153,7 @@ func (m metricsImpl) Collect(
|
|||||||
var firstRecoverabilityPoint float64
|
var firstRecoverabilityPoint float64
|
||||||
var lastAvailableBackup float64
|
var lastAvailableBackup float64
|
||||||
var lastFailedBackup float64
|
var lastFailedBackup float64
|
||||||
|
var lastArchivedWAL float64
|
||||||
if x.FirstRecoverabilityPoint != nil {
|
if x.FirstRecoverabilityPoint != nil {
|
||||||
firstRecoverabilityPoint = float64(x.FirstRecoverabilityPoint.Unix())
|
firstRecoverabilityPoint = float64(x.FirstRecoverabilityPoint.Unix())
|
||||||
}
|
}
|
||||||
@ -152,6 +163,9 @@ func (m metricsImpl) Collect(
|
|||||||
if x.LastFailedBackupTime != nil {
|
if x.LastFailedBackupTime != nil {
|
||||||
lastFailedBackup = float64(x.LastFailedBackupTime.Unix())
|
lastFailedBackup = float64(x.LastFailedBackupTime.Unix())
|
||||||
}
|
}
|
||||||
|
if x.LastArchivedWALTime != nil {
|
||||||
|
lastArchivedWAL = float64(x.LastArchivedWALTime.Unix())
|
||||||
|
}
|
||||||
|
|
||||||
return &metrics.CollectMetricsResult{
|
return &metrics.CollectMetricsResult{
|
||||||
Metrics: []*metrics.CollectMetric{
|
Metrics: []*metrics.CollectMetric{
|
||||||
@ -167,6 +181,10 @@ func (m metricsImpl) Collect(
|
|||||||
FqName: lastFailedBackupTimestampMetricName,
|
FqName: lastFailedBackupTimestampMetricName,
|
||||||
Value: lastFailedBackup,
|
Value: lastFailedBackup,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
FqName: lastArchivedWALTimestampMetricName,
|
||||||
|
Value: lastArchivedWAL,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,10 +22,11 @@ package instance
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"time"
|
||||||
|
|
||||||
cnpgv1 "github.com/cloudnative-pg/cloudnative-pg/api/v1"
|
cnpgv1 "github.com/cloudnative-pg/cloudnative-pg/api/v1"
|
||||||
"github.com/cloudnative-pg/plugin-barman-cloud/internal/cnpgi/metadata"
|
"github.com/cloudnative-pg/plugin-barman-cloud/internal/cnpgi/metadata"
|
||||||
"k8s.io/utils/ptr"
|
"k8s.io/utils/ptr"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/cloudnative-pg/cnpg-i/pkg/metrics"
|
"github.com/cloudnative-pg/cnpg-i/pkg/metrics"
|
||||||
barmancloudv1 "github.com/cloudnative-pg/plugin-barman-cloud/api/v1"
|
barmancloudv1 "github.com/cloudnative-pg/plugin-barman-cloud/api/v1"
|
||||||
@ -117,7 +118,7 @@ var _ = Describe("Metrics Collect method", func() {
|
|||||||
res, err := m.Collect(ctx, req)
|
res, err := m.Collect(ctx, req)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(res).ToNot(BeNil())
|
Expect(res).ToNot(BeNil())
|
||||||
Expect(res.Metrics).To(HaveLen(3))
|
Expect(res.Metrics).To(HaveLen(4))
|
||||||
|
|
||||||
// Verify the metrics
|
// Verify the metrics
|
||||||
metricsMap := make(map[string]float64)
|
metricsMap := make(map[string]float64)
|
||||||
@ -131,6 +132,13 @@ var _ = Describe("Metrics Collect method", func() {
|
|||||||
|
|
||||||
expectedLastBackup, _ := metricsMap[lastAvailableBackupTimestampMetricName]
|
expectedLastBackup, _ := metricsMap[lastAvailableBackupTimestampMetricName]
|
||||||
Expect(expectedLastBackup).To(BeNumerically("~", float64(objectStore.Status.ServerRecoveryWindow[clusterName].LastSuccessfulBackupTime.Unix()), 1))
|
Expect(expectedLastBackup).To(BeNumerically("~", float64(objectStore.Status.ServerRecoveryWindow[clusterName].LastSuccessfulBackupTime.Unix()), 1))
|
||||||
|
|
||||||
|
// Check that unset timestamps are 0
|
||||||
|
expectedLastFailedBackup, _ := metricsMap[lastFailedBackupTimestampMetricName]
|
||||||
|
Expect(expectedLastFailedBackup).To(BeZero())
|
||||||
|
|
||||||
|
expectedLastArchivedWAL, _ := metricsMap[lastArchivedWALTimestampMetricName]
|
||||||
|
Expect(expectedLastArchivedWAL).To(BeZero())
|
||||||
})
|
})
|
||||||
|
|
||||||
It("should return an error if the object store is not found", func() {
|
It("should return an error if the object store is not found", func() {
|
||||||
|
|||||||
@ -21,6 +21,7 @@ package instance
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"sync"
|
||||||
|
|
||||||
"github.com/cloudnative-pg/cnpg-i-machinery/pkg/pluginhelper/http"
|
"github.com/cloudnative-pg/cnpg-i-machinery/pkg/pluginhelper/http"
|
||||||
"github.com/cloudnative-pg/cnpg-i/pkg/backup"
|
"github.com/cloudnative-pg/cnpg-i/pkg/backup"
|
||||||
@ -52,6 +53,7 @@ func (c *CNPGI) Start(ctx context.Context) error {
|
|||||||
SpoolDirectory: c.SpoolDirectory,
|
SpoolDirectory: c.SpoolDirectory,
|
||||||
PGDataPath: c.PGDataPath,
|
PGDataPath: c.PGDataPath,
|
||||||
PGWALPath: c.PGWALPath,
|
PGWALPath: c.PGWALPath,
|
||||||
|
LastStatusUpdate: &sync.Map{},
|
||||||
})
|
})
|
||||||
backup.RegisterBackupServer(server, BackupServiceImplementation{
|
backup.RegisterBackupServer(server, BackupServiceImplementation{
|
||||||
Client: c.Client,
|
Client: c.Client,
|
||||||
|
|||||||
@ -22,6 +22,7 @@ package restore
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"path"
|
"path"
|
||||||
|
"sync"
|
||||||
|
|
||||||
"github.com/cloudnative-pg/cnpg-i-machinery/pkg/pluginhelper/http"
|
"github.com/cloudnative-pg/cnpg-i-machinery/pkg/pluginhelper/http"
|
||||||
restore "github.com/cloudnative-pg/cnpg-i/pkg/restore/job"
|
restore "github.com/cloudnative-pg/cnpg-i/pkg/restore/job"
|
||||||
@ -54,6 +55,7 @@ func (c *CNPGI) Start(ctx context.Context) error {
|
|||||||
SpoolDirectory: c.SpoolDirectory,
|
SpoolDirectory: c.SpoolDirectory,
|
||||||
PGDataPath: c.PGDataPath,
|
PGDataPath: c.PGDataPath,
|
||||||
PGWALPath: path.Join(c.PGDataPath, "pg_wal"),
|
PGWALPath: path.Join(c.PGDataPath, "pg_wal"),
|
||||||
|
LastStatusUpdate: &sync.Map{},
|
||||||
})
|
})
|
||||||
|
|
||||||
restore.RegisterRestoreJobHooksServer(server, &JobHookImpl{
|
restore.RegisterRestoreJobHooksServer(server, &JobHookImpl{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user