couchbase-partners / helm-charts

Helm charts for deployed couchbase services
Apache License 2.0
25 stars 39 forks source link

Restoring from a backup does not work due Permission denied: '/data/scriptlogs' #127

Open camilamacedo86 opened 6 months ago

camilamacedo86 commented 6 months ago

See: https://docs.couchbase.com/operator/current/howto-backup.html#restoring-from-a-backup

By applying the resource it will not workout the issue faced is described following and it is the same scenario of to create the backup at the first place: https://github.com/couchbase-partners/helm-charts/issues/126#issuecomment-2126675183

Traceback (most recent call last):
  File "/usr/local/bin/backup.py", line 1288, in <module>
    Backup(context).run()
  File "/usr/local/bin/backup.py", line 395, in run
    self._setup_logging()
  File "/usr/local/bin/backup.py", line 1196, in _setup_logging
    os.makedirs(self.context.log_path, exist_ok=True)
  File "/usr/lib/python3.8/os.py", line 223, in makedirs
    mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/data/scriptlogs'

PS.: This issue seems to be impossible to workaround since the Operator will delete the Cronjob.

camilamacedo86 commented 5 months ago

We can try to workaround by creating the JOB

kubectl apply -f - <<EOF
apiVersion: batch/v1
kind: Job
metadata:
  annotations:
    operator.couchbase.com/version: 2.5.0
  name: couchbase-restore-test
  namespace: couchbase
  labels:
    app: couchbase
    couchbase_cluster: couchbase
    couchbase_restore: couchbase-restore
spec:
  backoffLimit: 2
  completionMode: NonIndexed
  completions: 1
  parallelism: 1
  suspend: false
  template:
    metadata:
      labels:
        app: couchbase
        couchbase_cluster: couchbase
        couchbase_restore: couchbase-restore
    spec:
      containers:
      - args:
        - --mode
        - restore
        - --v
        - "DEBUG"
        - --log-ret
        - "168.00"
        - couchbase
        - --repo
        - couchbase-2024-05-28T06_41_38 
        - --threads
        - "1"
        - --obj-endpoint
        - storage.googleapis.com
        - --obj-store
        - gs://my-couchbase
        image: docker.io/couchbase/operator-backup:1.3.8
        imagePullPolicy: IfNotPresent
        name: cbbackupmgr-restore
        resources: {}
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
        volumeMounts:
        - mountPath: /data
          name: couchbase-cluster-backup-volume
        - mountPath: /var/run/secrets/couchbase
          name: couchbase-admin
          readOnly: true
        workingDir: /
      dnsPolicy: ClusterFirst
      restartPolicy: Never
      schedulerName: default-scheduler
      securityContext:
        fsGroup: 1000
      serviceAccountName: couchbase-backup
      terminationGracePeriodSeconds: 30
      volumes:
      - name: couchbase-cluster-backup-volume
        persistentVolumeClaim:
          claimName: couchbase-backup
      - name: couchbase-admin
        secret:
          defaultMode: 420
          secretName: my-secret
EOF

However, that will fails because the Operator will say that the CR is not created

HTTP response body: {"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"couchbasebackuprestores.couchbase.com \"couchbase-restore\" not found","reason":"NotFound","details":{"name":"couchbase-restore","group":"couchbase.com","kind":"couchbasebackuprestores"},"code":404}
camilamacedo86 commented 5 months ago

I could workaround this issue by

        - --default-recovery
        - "purge"