Skip to content
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

Fix rsync and schema validation for backup/recovery #2969

Merged
merged 7 commits into from
Feb 24, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,7 @@
dest: "{{ backup_destination_dir }}"
src: "{{ item }}"
checksum: true
rsync_opts:
- --rsh={{ rsh }}
vars:
# this fixes / replaces incorrect path to the private key file that synchronize provides
# (setting private_key parameter has no effect whatsoever, looks like a bug tbh)
rsh: >-
/usr/bin/ssh -S none -i {{ private_key_file.path }} -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null
private_key: "{{ private_key_file.path }}"
loop: "{{ artifacts }}"

- name: Remove copied artifacts from source
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,5 @@
dest: "{{ recovery_dir }}/"
src: "{{ item }}"
checksum: true
rsync_opts:
- --rsh={{ rsh }}
vars:
# this fixes / replaces incorrect path to the private key file that synchronize provides
# (setting private_key parameter has no effect whatsoever, looks like a bug tbh)
rsh: >-
/usr/bin/ssh -S none -i {{ private_key_file.path }} -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null
loop: >-
{{ artifacts }}
private_key: "{{ private_key_file.path }}"
loop: "{{ artifacts }}"
9 changes: 6 additions & 3 deletions cli/src/commands/BackupRecoveryBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from cli.src.helpers.data_loader import load_schema_obj, load_yamls_file
from cli.src.helpers.data_loader import types as data_types
from cli.src.helpers.doc_list_helpers import (ExpectedSingleResultException,
select_single)
select_single, select_all)
from cli.src.helpers.yaml_helpers import dump
from cli.src.schema.DefaultMerger import DefaultMerger
from cli.src.schema.SchemaValidator import SchemaValidator
Expand Down Expand Up @@ -48,8 +48,11 @@ def _process_input_docs(self):
self.manifest_docs = load_manifest(self.build_directory)
self.cluster_model = select_single(self.manifest_docs, lambda x: x.kind == 'epiphany-cluster')

# Load backup / recovery configuration documents
self.input_docs = load_yamls_file(self.file)
# Load only backup / recovery configuration documents
loaded_docs = load_yamls_file(self.file)
self.input_docs = select_all(loaded_docs, lambda x: x.kind in ['configuration/backup', 'configuration/recovery'])
if len(self.input_docs) < 1:
raise Exception('No documents for backup or recovery in input file.')

# Validate input documents
with SchemaValidator(self.cluster_model.provider, self.input_docs) as schema_validator:
Expand Down
2 changes: 2 additions & 0 deletions docs/changelogs/CHANGELOG-2.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
- [#2940](https://github.com/epiphany-platform/epiphany/issues/2940) - firewalld.service unit could not be found on host however ansible_facts sees it as defined
- [#2979](https://github.com/epiphany-platform/epiphany/issues/2979) - Restore the possibility of choosing the availability zone in AWS
- [#2984](https://github.com/epiphany-platform/epiphany/issues/2984) - Validation blocks overwriting of destination_address_prefix in NSG rules, which is 0.0.0.0/0 by default
- [#2942](https://github.com/epiphany-platform/epiphany/issues/2942) - rsync command fails trying to copy artifacts
- [#2930](https://github.com/epiphany-platform/epiphany/issues/2930) - Backup/recovery commands fail when default configuration for backup attached to cluster-config.yml

### Updated

Expand Down
28 changes: 12 additions & 16 deletions docs/home/howto/BACKUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,16 @@ filesystem. See [How to store backup](#2-how-to-store-backup) chapter.

## 1. How to perform backup

#### Backup configuration file and command
### Backup configuration file and command

Copy default configuration for backup from ``defaults/configuration/backup.yml`` into newly created backup.yml config
file, and enable backup for chosen components by setting up ``enabled`` parameter to ``true``.
file, supply correct provider and enable backup for chosen components by setting up ``enabled`` parameter to ``true``.

This config may also be attached to cluster-config.yml

```
```yaml
kind: configuration/backup
title: Backup Config
name: default
provider: azure
specification:
components:
load_balancer:
Expand All @@ -48,12 +47,10 @@ specification:

Run ``epicli backup`` command:

```
```shell
epicli backup -f backup.yml -b build_folder
```

If backup config is attached to cluster-config.yml, use this file instead of ``backup.yml``.

## 2. How to store backup

Backup location is defined in ``backup`` role as ``backup_destination_host`` and ``backup_destination_dir``. Default
Expand All @@ -80,15 +77,14 @@ machine's disk drive. This is not recommended.
### Recovery configuration file and command

Copy existing default configuration from ``defaults/configuration/recovery.yml`` into newly created recovery.yml config
file, and set ``enabled`` parameter for component to recovery. It's possible to choose snapshot name by passing date and
time part of snapshot name. If snapshot name is not provided, the latest one will be restored.
file, supply correct provider and set ``enabled`` parameter for component to recovery. It's possible to choose snapshot
name by passing date and time part of snapshot name. If snapshot name is not provided, the latest one will be restored.

This config may also be attached to cluster-config.yml

```
```yaml
kind: configuration/recovery
title: Recovery Config
name: default
provider: azure
specification:
components:
load_balancer:
Expand All @@ -110,9 +106,9 @@ specification:

Run ``epicli recovery`` command:

``epicli recovery -f recovery.yml -b build_folder``

If recovery config is attached to cluster-config.yml, use this file instead of ``recovery.yml``.
```shell
epicli recovery -f recovery.yml -b build_folder
```

## 4. How backup and recovery work

Expand Down