Skip to content

Commit 4516fa9

Browse files
committed
OSDOCS-11312: adds enhancements and nit fixes to auto recovery MicroShift
1 parent 992e045 commit 4516fa9

8 files changed

+186
-94
lines changed

microshift_backup_and_restore/microshift-auto-recover-manual-backup.adoc

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,16 @@ include::_attributes/attributes-microshift.adoc[]
66

77
toc::[]
88

9-
You can automatically restore data from manual backups when {microshift-short} fails to start by using the `auto-recovery` feature.
9+
You can automatically restore data from manual backups when {microshift-short} fails to start by configuring automatic recovery.
1010

11-
You can use the following options with the existing `backup` and `restore` commands in this feature:
11+
include::modules/microshift-auto-recovery-manual-backups.adoc[leveloffset=+1]
1212

13-
* `--auto-recovery`: Selects the most recent version of the backup, and then restores it. This option treats the `PATH` argument as a path to a directory that holds all the backups for automated recovery, and not just as a path to a particular backup file.
14-
* `--dont-save-failed`: Disables the backup of failed {microshift-short} data.
13+
include::modules/microshift-creating-backups-auto-recovery.adoc[leveloffset=+1]
1514

16-
[NOTE]
17-
====
18-
* You can use the `--auto-recovery` option with both the `backup` and `restore` commands.
19-
* You can use the `--dont-save-failed` option only with the `restore` command.
20-
====
15+
include::modules/microshift-restoring-backups-auto-recovery.adoc[leveloffset=+1]
2116

22-
include::modules/microshift-creating-backups.adoc[leveloffset=+1]
17+
include::modules/microshift-auto-recovery-example-rpm-systems.adoc[leveloffset=+2]
2318

24-
include::modules/microshift-restoring-backups.adoc[leveloffset=+1]
19+
include::modules/microshift-auto-recovery-example-ostree-systems.adoc[leveloffset=+2]
2520

26-
include::modules/microshift-automation-example-rpm-systems.adoc[leveloffset=+1]
27-
28-
include::modules/microshift-automation-example-ostree-systems.adoc[leveloffset=+1]
29-
30-
include::modules/microshift-automation-example-bootc-systems.adoc[leveloffset=+1]
21+
include::modules/microshift-auto-recovery-example-bootc-systems.adoc[leveloffset=+2]
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * microshift/microshift_backup_and_restore/microshift-auto-recover-manual-backup.adoc
4+
5+
:_mod-docs-content-type: PROCEDURE
6+
[id="microshift-auto-recovery-example-bootc-systems_{context}"]
7+
= Using automatic recovery in image mode for {op-system-base} systems
8+
9+
:FeatureName: Image mode for {op-system-base}
10+
11+
include::snippets/technology-preview.adoc[]
12+
13+
As a use case, consider the following example situation in which you want to automate the `auto-recovery` process for image mode for {op-system-base-full} systems that use the systemd service.
14+
15+
[IMPORTANT]
16+
====
17+
You must include the entire `auto-recovery` process for {op-system-image} systems that use `systemd` in the container file.
18+
====
19+
20+
.Prerequisites
21+
22+
* You created a Containerfile as instructed in link:https://docs.redhat.com/en/documentation/red_hat_build_of_microshift/4.18/html/installing_with_rhel_image_mode/installing-with-rhel-image-mode#microshift-rhel-image-mode-build-image_microshift-install-rhel-image-mode[Building the bootc image].
23+
24+
* You created the `10-auto-recovery.conf` and `microshift-auto-recovery.service` files as explained in the "Using auto-recovery in RPM systems" section.
25+
+
26+
[IMPORTANT]
27+
====
28+
The location of the the `10-auto-recovery.conf` and `microshift-auto-recovery.service` must be relative to the Containerfile.
29+
30+
For example, if the path to the Containerfile is `/home/microshift/my-build/Containerfile`, the systemd files need to be adjacent for proper embedding. The following paths are correct for this example:
31+
32+
* `/home/microshift/my-build/auto-rec/10-auto-recovery.conf`
33+
* `/home/microshift/my-build/auto-rec/microshift-auto-recovery.service`
34+
* `/home/microshift/my-build/auto-rec/microshift-auto-recovery`
35+
====
36+
37+
* You created the `microshift-auto-recovery` script as explained in the "Using auto-recovery in RPM systems" section.
38+
39+
.Procedure
40+
41+
. Use the following example snippet to update the container file that you use to prepare the {op-system-image} image.
42+
+
43+
[source,text]
44+
----
45+
RUN mkdir -p /usr/lib/systemd/system/microshift.service.d
46+
COPY ./auto-rec/10-auto-recovery.conf /usr/lib/systemd/system/microshift.service.d/10-auto-recovery.conf
47+
COPY ./auto-rec/microshift-auto-recovery.service /usr/lib/systemd/system/
48+
COPY ./auto-rec/microshift-auto-recovery /usr/bin/
49+
RUN chmod +x /usr/bin/microshift-auto-recovery
50+
----
51+
+
52+
[IMPORTANT]
53+
====
54+
Podman uses the host subscription information and repositories inside the container when building the container image. If the `rhocp` and `fast-datapath` repositories are not available on the host, the build fails.
55+
====
56+
57+
. Rebuild your local bootc image by running the following image build command:
58+
+
59+
[source,terminal]
60+
----
61+
PULL_SECRET=~/.pull-secret.json
62+
USER_PASSWD=<your_redhat_user_password>
63+
IMAGE_NAME=microshift-4.18-bootc
64+
65+
sudo podman build --authfile "${PULL_SECRET}" -t "${IMAGE_NAME}" \
66+
--build-arg USER_PASSWD="${USER_PASSWD}" \
67+
-f Containerfile
68+
----
69+
+
70+
[NOTE]
71+
====
72+
Secrets are used during the image build in the following ways:
73+
74+
* The podman `--authfile` argument is required to pull the base `rhel-bootc:9.4` image from the `registry.redhat.io` registry.
75+
76+
* The build `USER_PASSWD` argument is used to set a password for the `redhat user`.
77+
====
78+
79+
.Verification
80+
81+
* Verify that the local bootc image was created by running the following command:
82+
+
83+
[source,terminal]
84+
----
85+
$ sudo podman images "${IMAGE_NAME}"
86+
----
87+
+
88+
.Example output
89+
[source,text]
90+
----
91+
REPOSITORY TAG IMAGE ID CREATED SIZE
92+
localhost/microshift-4.18-bootc latest 193425283c00 2 minutes ago 2.31 GB
93+
----

modules/microshift-automation-example-ostree-systems.adoc renamed to modules/microshift-auto-recovery-example-ostree-systems.adoc

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,50 +3,60 @@
33
// * microshift/microshift_backup_and_restore/microshift-auto-recover-manual-backup.adoc
44

55
:_mod-docs-content-type: PROCEDURE
6-
[id="microshift-automation-example-ostree-systems_{context}"]
7-
= Automating the integration process with systemd for OSTree systems
6+
[id="microshift-auto-recovery-ostree-systems_{context}"]
7+
= Using automatic recovery with {op-system-ostree}
8+
9+
As a use case, consider the following example situation in which you want to automate the `auto-recovery` process for {op-system-ostree-first} systems that use systemd in the blueprint file.
810

911
[IMPORTANT]
1012
====
11-
You must include the entire `auto-recovery` process for OSTree systems that use `systemd` in the blueprint file.
13+
You must include the entire `auto-recovery` process for {op-system-ostree} systems that use `systemd` in the blueprint file.
1214
====
1315

14-
As a use case, consider the following example situation in which you want to automate the `auto-recovery` process for OSTree systems that use systemd.
16+
.Prerequisites
17+
18+
* You installed Podman.
19+
* You installed the command-line `composer-cli` tool.
1520
1621
.Procedure
1722

23+
. Optional: Because the `composer-cli` can only create files in the `/etc` directory, package your files into an RPM that you include the blueprint.
24+
1825
. Use the following example to create your blueprint file:
1926
+
2027
[source,terminal]
2128
----
29+
[[customizations.directories]]
30+
path = "/etc/systemd/system/microshift.service.d"
31+
32+
[[customizations.directories]]
33+
path = "/etc/bin"
34+
2235
[[customizations.files]]
23-
path = "/usr/lib/systemd/system/microshift.service.d/10-auto-recovery.conf"
36+
path = "/etc/systemd/system/microshift.service.d/10-auto-recovery.conf"
2437
data = """
2538
[Unit]
2639
OnFailure=microshift-auto-recovery.service
2740
"""
2841

2942
[[customizations.files]]
30-
path = "/usr/lib/systemd/system/microshift-auto-recovery.service"
43+
path = "/etc/systemd/system/microshift-auto-recovery.service"
3144
data = """
3245
[Unit]
3346
Description=MicroShift auto-recovery
34-
3547
[Service]
3648
Type=oneshot
37-
ExecStart=/usr/bin/microshift-auto-recovery
38-
49+
ExecStart=/etc/bin/microshift-auto-recovery
3950
[Install]
4051
WantedBy=multi-user.target
4152
"""
4253

4354
[[customizations.files]]
44-
path = "/usr/bin/microshift-auto-recovery"
55+
path = "/etc/bin/microshift-auto-recovery"
4556
mode = "0755"
4657
data = """
4758
#!/usr/bin/env bash
4859
set -xeuo pipefail
49-
5060
# If greenboot uses a non-default file for clearing boot_counter, use boot_success instead.
5161
if grep -q "/boot/grubenv" /usr/libexec/greenboot/greenboot-grub2-set-success; then
5262
if grub2-editenv - list | grep -q ^boot_success=0; then
@@ -61,12 +71,11 @@ else
6171
exit 0
6272
fi
6373
fi
64-
6574
/usr/bin/microshift restore --auto-recovery /var/lib/microshift-auto-recovery
6675
/usr/bin/systemctl reset-failed microshift
6776
/usr/bin/systemctl start microshift
68-
6977
echo "DONE"
7078
"""
7179
----
80+
7281
. For the next steps, see link:https://docs.redhat.com/en/documentation/red_hat_build_of_microshift/{ocp-version}/html/embedding_in_a_rhel_for_edge_image/microshift-embed-in-rpm-ostree#preparing-for-image-building_microshift-embed-in-rpm-ostree[Preparing for image building].

modules/microshift-automation-example-rpm-systems.adoc renamed to modules/microshift-auto-recovery-example-rpm-systems.adoc

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,16 @@
33
// * microshift/microshift_backup_and_restore/microshift-auto-recover-manual-backup.adoc
44

55
:_mod-docs-content-type: PROCEDURE
6-
[id="microshift-automation-example-rpm-systems_{context}"]
7-
= Automating the integration process with systemd for RPM systems
6+
[id="microshift-auto-recovery-rpm-systems_{context}"]
7+
= Using automatic recovery in RPM systems
88

9-
[NOTE]
10-
====
11-
When the `microshift.service` enters a failed state, `systemd` starts the `microshift-auto-recovery.service` unit. This unit executes the `auto-recovery` restore process and restarts {microshift-short}.
12-
====
9+
When {microshift-short} enters a failed state, the systemd service starts the `microshift-auto-recovery.service` unit. This unit executes the `auto-recovery` restore process.
1310

14-
As a use case, consider the following example situation in which you want to automate the `auto-recovery` process for RPM systems that use systemd.
11+
As a use case, consider the following example situation in which you want to automate the automatic recovery process for RPM systems that use the systemd service.
1512

1613
.Procedure
1714

18-
. Create a directory for the `microshift.service` by running the following command:
15+
. Create a directory for the `microshift` systemd service by running the following command:
1916
+
2017
[source,terminal]
2118
----
@@ -28,8 +25,11 @@ $ sudo mkdir -p /usr/lib/systemd/system/microshift.service.d
2825
$ sudo tee /usr/lib/systemd/system/microshift.service.d/10-auto-recovery.conf > /dev/null <<'EOF'
2926
[Unit]
3027
OnFailure=microshift-auto-recovery.service
28+
StartLimitIntervalSec=25s # <1>
3129
EOF
3230
----
31+
<1> Increase the `StartLimitInterval` value from the default `10s` to a larger value for slower systems. A value that is too low can result in systemd never marking the `microshift` systemd service as failed, which means that the `OnFailure=` service does not get triggered.
32+
3333
. Create the `microshift-auto-recovery.service` file by running the following command:
3434
+
3535
[source,terminal]
@@ -46,6 +46,7 @@ ExecStart=/usr/bin/microshift-auto-recovery
4646
WantedBy=multi-user.target
4747
EOF
4848
----
49+
4950
. Create the `microshift-auto-recovery` script by running the following command:
5051
+
5152
[source,terminal]
@@ -76,12 +77,14 @@ fi
7677
echo "DONE"
7778
EOF
7879
----
80+
7981
. Make the script executable by running the following command:
8082
+
8183
[source,terminal]
8284
----
8385
$ sudo chmod +x /usr/bin/microshift-auto-recovery
8486
----
87+
8588
. Reload the system configuration by running the following command:
8689
+
8790
[source,terminal]
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * microshift/microshift_backup_and_restore/microshift-auto-recover-manual-backup.adoc
4+
5+
:_mod-docs-content-type: CONCEPT
6+
[id="microshift-auto-recovery-manual-backups_{context}"]
7+
= Modifying backup and restore commands to automate data recovery
8+
9+
Use automatic recovery options to store all of your backups in a single directory, then automatically select the latest one to restore. Modifying existing `backup` and `restore` commands enables you to set up automatic recovery.
10+
11+
The `--auto-recovery` option treats the `PATH` argument as a path to a directory that holds all the backups for automated recovery, and not just as a path to a particular backup file. You can use the `--auto-recovery` option with both `backup` and `restore` commands.
12+
13+
* For example, if you use the automatic recovery option with `restore`, such as in `microshift restore --auto-recovery PATH`, running the modified command automatically selects and restores the most recent backup.
14+
15+
* If you use the same option in the `microshift backup` command, such as in `microshift backup --auto-recovery PATH`, a new backup is created in the PATH.
16+
17+
* By default, `microshift restore --auto-recovery PATH` creates a backup of the failed {microshift-short} data in `PATH/failed`. You can add the `--dont-save-failed` option to disable the creation of failed backup data.
18+
19+
[IMPORTANT]
20+
====
21+
You can only use the `--dont-save-failed` option with the `restore` command.
22+
====

modules/microshift-automation-example-bootc-systems.adoc

Lines changed: 0 additions & 32 deletions
This file was deleted.

modules/microshift-creating-backups.adoc renamed to modules/microshift-creating-backups-auto-recovery.adoc

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
// * microshift/microshift_backup_and_restore/microshift-auto-recover-manual-backup.adoc
44

55
:_mod-docs-content-type: PROCEDURE
6-
[id="microshift-creating-backups_{context}"]
6+
[id="microshift-creating-backups-auto-recovery_{context}"]
77
= Creating backups using the auto-recovery feature
88

9-
Use the following procedure to create backups.
9+
Use the following procedure to create backups using automatic recovery options.
1010

1111
[NOTE]
1212
====
@@ -15,26 +15,24 @@ Creating backups require stopping {microshift-short}, so you must determine the
1515

1616
.Prerequisites
1717

18-
* You have stopped {microshift-short}.
18+
* You stopped {microshift-short}.
1919
2020
.Procedure
2121

2222
* Create and store backups in the directory you choose by running the following command:
2323
+
24-
[source,terminal]
25-
[subs="+quotes"]
24+
[source,terminal,subs="+quotes"]
2625
----
2726
$ sudo microshift backup --auto-recovery _<path_of_directory>_ <1>
2827
----
2928
<1> Replace `_<path_of_directory>_` with the path of the directory that stores backups. For example, `/var/lib/microshift-auto-recovery`.
3029
+
3130
[NOTE]
3231
====
33-
The `--auto-recovery` option modifies the interpretation of the `PATH` argument from the final backup path to a directory that holds all the backups for automated recovery.
32+
The `--auto-recovery` option modifies the interpretation of the `PATH` argument from the final backup path to a directory that holds all of the backups for automated recovery.
3433
====
3534
+
3635
.Example output
37-
+
3836
[source,terminal]
3937
----
4038
??? I1104 09:18:52.100725 8906 system.go:58] "OSTree deployments" deployments=[{"id":"default-b3442053c9ce69310cd54140d8d592234c5306e4c5132de6efe615f79c84300a.1","booted":true,"staged":false,"pinned":false},{"id":"default-a129624b9233fa54fe3574f1aa211bc2d85e1052b52245fe7d83f10c2f6d28e3.0","booted":false,"staged":false,"pinned":false}]
@@ -49,11 +47,10 @@ The `--auto-recovery` option modifies the interpretation of the `PATH` argument
4947
5048
.Verification
5149

52-
* To verify that the backup has been created, view the directory you chose to store backups by running the following command:
50+
* Verify that the backup you created exists in your customized storage directory by running the following command:
5351
+
54-
[source,terminal]
55-
[subs="+quotes"]
52+
[source,terminal,subs="+quotes"]
5653
----
57-
$ ls -la _<path_of_directory>_ <1>
54+
$ sudo ls -la _<path_of_directory>_ <1>
5855
----
5956
<1> Replace `_<path_of_directory>_` with the path of the directory that stores backups. For example, `/var/lib/microshift-auto-recovery`.

0 commit comments

Comments
 (0)