timescale / helm-charts

Configuration and Documentation to run TimescaleDB in your Kubernetes cluster
Apache License 2.0
263 stars 223 forks source link

Error in `restore_or_initdb.sh` while restoring a backup #618

Open corentingiraud opened 1 year ago

corentingiraud commented 1 year ago

What happened?

I tried to restore a backup with the timescale-single helm chart. I faced this error:

2023-08-07 08:56:13 - restore_or_initdb - Attempting restore from backup
2023-08-07 08:56:13 - restore_or_initdb - Listing available backup information
ERROR: [032]: 'time' is not allowed for 'type' option
Process Process-1:
Traceback (most recent call last):
  File "/usr/lib/python3.10/multiprocessing/process.py", line 314, in _bootstrap
    self.run()
  File "/usr/lib/python3.10/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/lib/python3/dist-packages/patroni/__main__.py", line 162, in patroni_main
    abstract_main(Patroni, configfile)
  File "/usr/lib/python3/dist-packages/patroni/daemon.py", line 174, in abstract_main
    controller.run()
  File "/usr/lib/python3/dist-packages/patroni/__main__.py", line 133, in run
    super(Patroni, self).run()
  File "/usr/lib/python3/dist-packages/patroni/daemon.py", line 143, in run
    self._run_cycle()
  File "/usr/lib/python3/dist-packages/patroni/__main__.py", line 136, in _run_cycle
    logger.info(self.ha.run_cycle())
  File "/usr/lib/python3/dist-packages/patroni/ha.py", line 1824, in run_cycle
    info = self._run_cycle()
  File "/usr/lib/python3/dist-packages/patroni/ha.py", line 1639, in _run_cycle
    return self.post_bootstrap()
  File "/usr/lib/python3/dist-packages/patroni/ha.py", line 1526, in post_bootstrap
    self.cancel_initialization()
  File "/usr/lib/python3/dist-packages/patroni/ha.py", line 1519, in cancel_initialization
    raise PatroniFatalException('Failed to bootstrap cluster')
patroni.exceptions.PatroniFatalException: Failed to bootstrap cluster
2023-08-07 08:56:18,509 WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f4b34817490>: Failed to establish a new connection: [Errno 111] Connection refused')': /liveness
2023-08-07 08:56:18,509 WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f4b347bd000>: Failed to establish a new connection: [Errno 111] Connection refused')': /liveness
2023-08-07 08:56:18,510 WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f4b348175b0>: Failed to establish a new connection: [Errno 111] Connection refused')': /liveness
Sourcing /home/postgres/.pod_environment

I followed the admin documentation: So, I created the secret pgbackrest-bootstrap.

apiVersion: v1
stringData:
    PGBACKREST_REPO1_S3_BUCKET: xxx
    PGBACKREST_REPO1_S3_ENDPOINT: s3-eu-west-1.amazonaws.com
    PGBACKREST_REPO1_S3_KEY: xxx
    PGBACKREST_REPO1_S3_KEY_SECRET: xxx
    PGBACKREST_REPO1_S3_REGION: eu-west-1
    PGBACKREST_REPO1_CIPHER_TYPE: aes-256-cbc
    PGBACKREST_REPO1_CIPHER_PASS: xxx
    PGBACKREST_TARGET_ACTION: promote
    PGBACKREST_TYPE: time
    PGBACKREST_DELTA: "y"
kind: Secret
metadata:
    name: pgbackrest-bootstrap
type: Opaque

Then I edited my values.yaml files:

#1: Enable bootstrapFromBackup
bootstrapFromBackup:
  secretName: pgbackrest-bootstrap
  enabled: true
  # /!\ To change
  repo1-path: /k8s-namespace/helm-release-name

#2: Disable backup
backup:
    enabled: false

#3: Manually add PGBACKREST_TARGET env var
# We do notinclude this in the `pgbackrest-bootstrap` secret otherwise we have a parsing error because of the space character.
env:
- name: PGBACKREST_TARGET
  value: 2022-08-02 08:00:00.0000+00

The issue is that pgbackrest info and pgbackrest restore share argument --type but with different values.

This line of restore_or_initdb.sh causes the issue.

Did you expect to see something different?

The restore process should work.

How to reproduce it (as minimally and precisely as possible):

See above

Environment

WARNING: This version information is deprecated and will be replaced with the output from kubectl version --short.  Use --output=yaml|json to get the full version.
Client Version: version.Info{Major:"1", Minor:"27", GitVersion:"v1.27.2", GitCommit:"7f6f68fdabc4df88cfea2dcf9a19b2b830f1e647", GitTreeState:"clean", BuildDate:"2023-05-17T14:20:07Z", GoVersion:"go1.20.4", Compiler:"gc", Platform:"darwin/amd64"}
Kustomize Version: v5.0.1
Server Version: version.Info{Major:"1", Minor:"22+", GitVersion:"v1.22.17-eks-a5565ad", GitCommit:"f9957380bdf944def12b72be44e853c92c2b8518", GitTreeState:"clean", BuildDate:"2023-06-15T21:20:13Z", GoVersion:"go1.16.15", Compiler:"gc", Platform:"linux/amd64"}
WARNING: version difference between client (1.27) and server (1.22) exceeds the supported minor version skew of +/-1