Skip to content

Commit ab6000b

Browse files
authored
Fix #644 secondary restart allows non-empty dir (#645)
- removed secondary_setup, use local files
1 parent d22673a commit ab6000b

4 files changed

Lines changed: 7 additions & 13 deletions

File tree

rsconf/component/bkp.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,16 @@ def internal_build(self):
2929
z = jc.bkp
3030
z.run_u = jc.rsconf_db.root_u
3131
z.run_d = systemd.unit_run_d(jc, self.name)
32-
secondary_setup = None
3332
if jc.rsconf_db.host == z.primary:
3433
self._primary(jc, z)
3534
n = "primary"
3635
else:
37-
secondary_setup = self._secondary(jc, z)
36+
self._secondary(jc, z)
3837
n = "secondary"
3938
te = z.run_d.join(n)
4039
systemd.timer_prepare(self, jc, timer_exec=te, on_calendar=z.on_calendar)
4140
self.install_access(mode="500", owner=z.run_u)
4241
self.install_resource("bkp/{}.sh".format(n), jc, te)
43-
if secondary_setup:
44-
self.install_abspath(
45-
secondary_setup,
46-
z.run_d.join(secondary_setup.purebasename),
47-
)
4842
systemd.timer_enable(self, j2_ctx=jc, run_u=z.run_u)
4943

5044
def _primary(self, jc, z):
@@ -88,4 +82,3 @@ def _primary(self, jc, z):
8882

8983
def _secondary(self, jc, z):
9084
z.setdefault("secondary_copy_unmount_cmds", "")
91-
return z.setdefault("secondary_setup_f", None)

rsconf/package_data/bkp/secondary.sh.jinja

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@ _snap_root_d=$_mirror_d/secondary_snap
88
_restart_f=$_snap_root_d/RESTART
99

1010
_assert_copy_d() {
11+
declare is_restart=$1
1112
if [[ ! -d $_copy_d ]]; then
1213
_err "$_copy_d does not exist"
1314
fi
1415
if [[ $(_file_sys "$_copy_d") == $(_file_sys "$(dirname "$_copy_d")") ]]; then
1516
_err "$_copy_d is not on a separate file system; need to run secondary_setup"
1617
fi
17-
if [[ $(ls $_copy_d) ]]; then
18+
if [[ ! $is_restart && $(ls $_copy_d) ]]; then
1819
_err "$_copy_d is not empty"
1920
fi
2021
}
@@ -121,7 +122,7 @@ systemctl start bkp.service"
121122
rm -rf "$_snap_root_d"
122123
cp -al "$_current_d" "$_snap_root_d"
123124
touch "$_sentinel_f"
124-
_assert_copy_d
125+
_assert_copy_d "$is_restart_rv"
125126
}
126127

127128
_main "$@"

tests/pkcli/build1_data/1.out/srv/host/v9.radia.run/srv/bkp/secondary

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@ _snap_root_d=$_mirror_d/secondary_snap
88
_restart_f=$_snap_root_d/RESTART
99

1010
_assert_copy_d() {
11+
declare is_restart=$1
1112
if [[ ! -d $_copy_d ]]; then
1213
_err "$_copy_d does not exist"
1314
fi
1415
if [[ $(_file_sys "$_copy_d") == $(_file_sys "$(dirname "$_copy_d")") ]]; then
1516
_err "$_copy_d is not on a separate file system; need to run secondary_setup"
1617
fi
17-
if [[ $(ls $_copy_d) ]]; then
18+
if [[ ! $is_restart && $(ls $_copy_d) ]]; then
1819
_err "$_copy_d is not empty"
1920
fi
2021
}
@@ -121,7 +122,7 @@ systemctl start bkp.service"
121122
rm -rf "$_snap_root_d"
122123
cp -al "$_current_d" "$_snap_root_d"
123124
touch "$_sentinel_f"
124-
_assert_copy_d
125+
_assert_copy_d "$is_restart_rv"
125126
}
126127

127128
_main "$@"

tests/pkcli/build1_data/1.out/srv/host/v9.radia.run/srv/bkp/secondary_setup

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)