Skip to content

Commit

Permalink
Multi-claims volume fixes
Browse files Browse the repository at this point in the history
Remove the patchs trying to workaround vol provision issues when access is not
set to r.x by a flex consumer: Now the access is forced to ..x.

Also separate the rollback boolean in 2 booleans :
* one for the vol start rollbacking
* one for the volume resource state flag

So even if we didn't start the vol instance we can rollback the state flag.
  • Loading branch information
cvaroqui committed Dec 16, 2020
1 parent bf7ab3f commit e84a491
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
6 changes: 6 additions & 0 deletions opensvc/core/objects/vol.py
Expand Up @@ -9,6 +9,12 @@ class Vol(Svc):
def users(self, exclude=None):
exclude = exclude or []
users = []

# purge lazies that may have changed due to claims
# that occured in the lifespan of this object
self.unset_lazy("cd")
self.unset_lazy("children")

for child in self.children:
if child in exclude:
continue
Expand Down
4 changes: 0 additions & 4 deletions opensvc/drivers/resource/fs/flag/__init__.py
Expand Up @@ -71,10 +71,6 @@ def abort_start(self):
self.log.exception(exc)
return True

def post_provision_start(self):
if self.svc.options.leader:
self.start()

def provisioner(self):
pass

Expand Down
20 changes: 15 additions & 5 deletions opensvc/drivers/resource/volume/__init__.py
Expand Up @@ -179,6 +179,8 @@ def __init__(self, name=None, pool=None, pooltype=None, size=None,
self.perm = perm
self.dirperm = dirperm
self.signal = signal
self.can_rollback_vol_instance = False
self.can_rollback_flag = False

def __str__(self):
return "%s name=%s" % (super(Volume, self).__str__(), self.volname)
Expand Down Expand Up @@ -283,6 +285,9 @@ def stop(self):

def _stop(self, force=False):
self.uninstall_flag()
self.stop_vol_instance()

def stop_vol_instance(self):
try:
self.volsvc
except ex.Error:
Expand All @@ -301,6 +306,12 @@ def _stop(self, force=False):
if self.volsvc.action("stop", options={"local": True, "leader": self.svc.options.leader, "force": force}) != 0:
raise ex.Error

def rollback(self):
if self.can_rollback_flag:
self.uninstall_flag()
if self.can_rollback_vol_instance:
self.stop_vol_instance()

def start(self):
try:
self.volsvc
Expand All @@ -310,9 +321,12 @@ def start(self):
raise ex.Error("volume %s does not exist" % self.volname)
if self.volsvc.action("start", options={"local": True, "leader": self.svc.options.leader}) != 0:
raise ex.Error
self.can_rollback |= any([r.can_rollback for r in self.volsvc.resources_by_id.values()])
self.can_rollback_vol_instance = any([r.can_rollback for r in self.volsvc.resources_by_id.values()])
self.can_rollback |= self.can_rollback_vol_instance
self.chown()
self.install_flag()
self.can_rollback_flag = True
self.can_rollback |= self.can_rollback_flag
self.install_directories()
self.install_secrets()
self.install_configs()
Expand Down Expand Up @@ -612,10 +626,6 @@ def unprovisioner(self):
def provisioner_shared_non_leader(self):
self.provisioner()

def post_provision_start(self):
if self.svc.options.leader:
self.start()

def provisioner(self):
"""
Create a volume service with resources definitions deduced from the storage
Expand Down

0 comments on commit e84a491

Please sign in to comment.