diff --git a/chart/cluster-tasks/templates/clear-cache.yaml b/chart/cluster-tasks/templates/clear-cache.yaml index 1508b43d42b428c12d62217fe80dd054bd1946a3..8c8a63eed4eac8a471c9f2162be320f80027970b 100644 --- a/chart/cluster-tasks/templates/clear-cache.yaml +++ b/chart/cluster-tasks/templates/clear-cache.yaml @@ -21,7 +21,8 @@ spec: - |- echo "--------------------------- Clear cache ---------------------------" echo "Drupal site name: $(params.drupalSite)" - export TASK=clear-cache + export DATE=$(date +%F-%H-%M) + export TASK=clear-cache-$DATE export OPERATION="clear-cache" export DRUPALSITE=$(params.drupalSite) export NAMESPACE=$(params.namespace) diff --git a/chart/cluster-tasks/templates/database-restore.yaml b/chart/cluster-tasks/templates/database-restore.yaml new file mode 100644 index 0000000000000000000000000000000000000000..4188bcc53be5798660f9ee430968efd69c896886 --- /dev/null +++ b/chart/cluster-tasks/templates/database-restore.yaml @@ -0,0 +1,36 @@ +apiVersion: tekton.dev/v1beta1 +kind: ClusterTask +metadata: + name: database-restore +spec: + params: + - name: drupalSite + type: string + description: The name of the drupal site + - name: namespace + type: string + description: The namespace of the drupal site + steps: + - name: database-restore + image: gitlab-registry.cern.ch/drupal/paas/drupal-operations/openshift-cli:velero-restore + imagePullPolicy: Always + command: + - /bin/sh + - '-c' + args: + - |- + echo "--------------------------- Database restore ---------------------------" + echo "Drupal site name: $(params.drupalSite)" + export DATE=$(date +%F-%H-%M) + export TASK=database-restore-$DATE + export OPERATION="database-restore" + export DRUPALSITE=$(params.drupalSite) + export ARGS="-f 'database_backup.sql'" + export NAMESPACE=$(params.namespace) + export SERVING_POD_IMAGE=$(oc get -n $(params.namespace) drupalsite/$(params.drupalSite) -o=jsonpath='{.status.servingPodImage}') + envsubst < /tekton-task-templates/drupal_operation_job.yaml | oc create -n $(params.namespace) -f - + oc wait --for=condition=complete job/$TASK-$(params.drupalSite) + jobStatus=$(oc get job/$TASK-$(params.drupalSite) -o=jsonpath='{.status.conditions[*].type}' | grep -i -E 'failed|complete' || echo "Failed") + echo "Job status: $jobStatus" + echo "Job logs:" + oc logs job/$TASK-$DRUPALSITE -n $(params.namespace) diff --git a/chart/cluster-tasks/templates/drupalsite-restore.yaml b/chart/cluster-tasks/templates/drupalsite-restore.yaml index 380f23dfcd84687cf8390ec879c219aba0e4dc44..16bfa0dc3ba80d73c7b79c96f3f61d1839e783c9 100644 --- a/chart/cluster-tasks/templates/drupalsite-restore.yaml +++ b/chart/cluster-tasks/templates/drupalsite-restore.yaml @@ -43,7 +43,7 @@ spec: export TASK=db-restore-$DATE export SERVING_POD_IMAGE=$(oc get -n $NAMESPACE drupalsite/$(params.drupalSite) -o=jsonpath='{.status.servingPodImage}') export OPERATION="database-restore" - export ARGS="-f database_backup.sql" + export ARGS="-f 'database_backup.sql'" envsubst < /tekton-task-templates/drupal_operation_job.yaml | oc create -n $NAMESPACE -f - oc wait --for=condition=complete job/$TASK-$(params.drupalSite) jobStatus=$(oc get job/$TASK-$(params.drupalSite) -o=jsonpath='{.status.conditions[*].type}' | grep -i -E 'failed|complete' || echo "Failed") diff --git a/tekton-task-templates/drupal_operation_job.yaml b/tekton-task-templates/drupal_operation_job.yaml index c505d1cdfb682b559a8fadabe8ed3b892608e0bb..b9fb1656902f6e050a0cdc58c9fd91b626162295 100644 --- a/tekton-task-templates/drupal_operation_job.yaml +++ b/tekton-task-templates/drupal_operation_job.yaml @@ -16,8 +16,8 @@ spec: containers: - command: - sh - - /operations/$OPERATION.sh - - $ARGS + - '-c' + - /operations/$OPERATION.sh $ARGS env: - name: DRUPAL_SHARED_VOLUME value: /drupal-data diff --git a/tekton-task-templates/restore_pv_job.yaml b/tekton-task-templates/restore_pv_job.yaml index a40ff3d01ac60583e232312685752f15fda79115..9ef9e3bed7559309443561c94f0ea240ad5fdb29 100644 --- a/tekton-task-templates/restore_pv_job.yaml +++ b/tekton-task-templates/restore_pv_job.yaml @@ -43,12 +43,12 @@ spec: valueFrom: secretKeyRef: name: cephfs-backup-secrets - key: cephfs-backup-s3-access-key + key: cephfsBackupS3AccessKey - name: AWS_SECRET_ACCESS_KEY valueFrom: secretKeyRef: name: cephfs-backup-secrets - key: cephfs-backup-s3-secret-key + key: cephfsBackupS3SecretKey resources: {} volumeMounts: - name: openstack-credentials @@ -69,13 +69,7 @@ spec: imagePullPolicy: Always securityContext: privileged: true - runAsUser: 0 restartPolicy: Never terminationGracePeriodSeconds: 30 - dnsPolicy: ClusterFirst - nodeSelector: - node-role.kubernetes.io/infra: '' serviceAccountName: $RESTORE_SERVICE_ACCOUNT serviceAccount: $RESTORE_SERVICE_ACCOUNT - securityContext: {} - schedulerName: default-scheduler diff --git a/velero-restic-restore/restore_pvs.sh b/velero-restic-restore/restore_pvs.sh index c86d0ce187a4daa497331e251b006a600e462695..e7c11dd35ca3106eebf7c13e84d5033e7524bc87 100755 --- a/velero-restic-restore/restore_pvs.sh +++ b/velero-restic-restore/restore_pvs.sh @@ -89,7 +89,7 @@ mount -t ceph "$CEPHFS_PATH_PV" -o name="$PV_NAME",noatime,secret="$CEPHFS_USERK mkdir -p /restore chmod 777 /restore -restic -p /tmp/restic_password -r "$RESTIC_REPO" restore "$RESTIC_SNAPSHOT_ID" --target /restore +restic -p /tmp/repository-password -r "$RESTIC_REPO" restore "$RESTIC_SNAPSHOT_ID" --target /restore rsync -avz /restore/ /mnt/ --delete