Skip to content

Commit

Permalink
Merge pull request #493
Browse files Browse the repository at this point in the history
Fix resources presync not executed on "sync* --rid <sync rids>" actions
  • Loading branch information
cgalibern committed Nov 10, 2021
2 parents c2a7bfe + 98a2c50 commit 1d1d098
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
3 changes: 0 additions & 3 deletions opensvc/core/objects/svc.py
Original file line number Diff line number Diff line change
Expand Up @@ -4671,7 +4671,6 @@ def sync_nodes(self):
]
if not self.can_sync(rtypes, 'nodes'):
return
self.presync()
self.sub_set_action(rtypes, "sync_nodes")

def sync_drp(self):
Expand All @@ -4684,7 +4683,6 @@ def sync_drp(self):
]
if not self.can_sync(rtypes, 'drpnodes'):
return
self.presync()
self.sub_set_action(rtypes, "sync_drp")

def sync_swap(self):
Expand Down Expand Up @@ -4827,7 +4825,6 @@ def sync_all(self):
if not self.can_sync(["sync"]):
return
self.sync_update()
self.presync()
rtypes = [
"sync.rsync",
"sync.btrfs",
Expand Down
16 changes: 14 additions & 2 deletions opensvc/drivers/resource/sync/rsync/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ def __init__(self,
self.timeout = 3600
self.options = options
self.reset_options = reset_options
self.presync_done = False

def __str__(self):
return "%s src=%s dst=%s options=%s target=%s" % (
Expand Down Expand Up @@ -564,8 +565,19 @@ def full_options(self):
def add_resource_files_to_sync(self):
if self.rid != "sync#i0":
return
for resource in self.svc.get_resources():
self.src += resource.files_to_sync()
for r in self.svc.get_resources():
self.src += r.files_to_sync()
if self.presync_done:
return
for r in self.svc.get_resources():
if r.disabled:
continue
if r.encap and not self.svc.encap:
continue
if not hasattr(r, "presync"):
continue
r.presync()
self.presync_done = True

def _info(self):
self.add_resource_files_to_sync()
Expand Down

0 comments on commit 1d1d098

Please sign in to comment.