Skip to content

K8SPG-803 specify log level info when pgbackrest is executed through cli - GetInfo #1186

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions e2e-tests/tests/demand-backup/01-create-cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ commands:

get_cr "demand-backup" ${RANDOM} \
| yq '.metadata.finalizers=["percona.com/delete-backups"]' \
| yq '.spec.backups.pgbackrest.global.log-level-console="debug"' \
| yq '.spec.backups.pgbackrest.global.repo1-retention-full="2"' \
| yq '.spec.backups.pgbackrest.global.repo1-retention-full-type="count"' \
| yq '.spec.backups.pgbackrest.global.repo3-retention-full="2"' \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ commands:

instance=$(kubectl get -n "${NAMESPACE}" pod -l postgres-operator.crunchydata.com/instance-set=instance1 -o 'jsonpath={.items[].metadata.name}')

pgbackrest_info_backups=$(kubectl exec -n "${NAMESPACE}" "$instance" -c database -- pgbackrest info --output json | jq '.[0].backup[]')
pgbackrest_info_backups=$(kubectl exec -n "${NAMESPACE}" "$instance" -c database -- pgbackrest info --output json --log-level-console=info | jq '.[0].backup[]')

check_backup() {
local backup_name=$1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ commands:

instance=$(kubectl get -n "${NAMESPACE}" pod -l postgres-operator.crunchydata.com/instance-set=instance1 -o 'jsonpath={.items[].metadata.name}')

pgbackrest_info_backups=$(kubectl exec -n "${NAMESPACE}" "$instance" -c database -- pgbackrest info --output json | jq '.[0].backup[]')
pgbackrest_info_backups=$(kubectl exec -n "${NAMESPACE}" "$instance" -c database -- pgbackrest info --output json --log-level-console=info | jq '.[0].backup[]')

check_backup() {
local backup_name=$1
Expand Down
2 changes: 1 addition & 1 deletion e2e-tests/tests/demand-backup/18-create-restore-s3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ commands:
source ../../functions

primary=$(get_pod_by_role demand-backup primary name)
latest_full_repo1_backup=$(kubectl -n ${NAMESPACE} exec ${primary} -- pgbackrest info --output json | jq '[.[] | .backup[] | select(.type == "full") | select(.database.["repo-key"] == 1)][-1].label')
latest_full_repo1_backup=$(kubectl -n ${NAMESPACE} exec ${primary} -- pgbackrest info --output json --log-level-console=info | jq '[.[] | .backup[] | select(.type == "full") | select(.database.["repo-key"] == 1)][-1].label')

cat <<EOF | kubectl -n ${NAMESPACE} apply -f -
apiVersion: pgv2.percona.com/v2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ commands:
source ../../functions

primary=$(get_pod_by_role demand-backup primary name)
latest_full_repo3_backup=$(kubectl -n ${NAMESPACE} exec ${primary} -- pgbackrest info --output json | jq '[.[] | .backup[] | select(.type == "full") | select(.database.["repo-key"] == 3) ][-1].label')
latest_full_repo3_backup=$(kubectl -n ${NAMESPACE} exec ${primary} -- pgbackrest info --output json --log-level-console=info | jq '[.[] | .backup[] | select(.type == "full") | select(.database.["repo-key"] == 3) ][-1].label')

cat <<EOF | kubectl -n ${NAMESPACE} apply -f -
apiVersion: pgv2.percona.com/v2
Expand Down
8 changes: 7 additions & 1 deletion percona/pgbackrest/pgbackrest.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,13 @@ func GetInfo(ctx context.Context, pod *corev1.Pod, repoName string) (InfoOutput,
return InfoOutput{}, errors.Wrap(err, "failed to create client")
}

if err := c.Exec(ctx, pod, naming.ContainerDatabase, nil, stdout, stderr, "pgbackrest", "info", "--output=json", "--repo="+strings.TrimPrefix(repoName, "repo")); err != nil {
// Setting --log-level-console=info is needed because if the --log-level-console=debug is configured
// through `backups.pgbackrest.global`, the stdout output contains additional text output that
// cannot be unmarshalled to InfoOutput without further processing.
if err := c.Exec(
ctx, pod, naming.ContainerDatabase, nil, stdout, stderr,
"pgbackrest", "info", "--output=json", "--repo="+strings.TrimPrefix(repoName, "repo"), "--log-level-console=info",
); err != nil {
return InfoOutput{}, errors.Wrapf(err, "exec: %s", stderr.String())
}

Expand Down
Loading