Skip to content

Commit

Permalink
Merge branch 'b2.1' of https://github.com/opensvc/opensvc into b2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
cvaroqui committed May 5, 2021
2 parents 65f2469 + b1404c7 commit fc0c5a3
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
3 changes: 3 additions & 0 deletions opensvc/core/resourceset.py
Expand Up @@ -330,6 +330,9 @@ def action(self, action, **kwargs):
# the action_job tells us what to do with it through its exitcode
resource.can_rollback = True

if action == "provision" and resource.type == "volume":
# need reset lazy in current process, (subprocess reset lazy has no effect)
resource.post_provision_reset_lazy()
if len(err) > 0:
raise ex.Error("%s non-optional resources jobs returned "
"with error" % ",".join(err))
Expand Down
22 changes: 15 additions & 7 deletions opensvc/drivers/pool/freenas.py
@@ -1,17 +1,16 @@
from __future__ import print_function

import sys

import core.exceptions as ex
from utilities.lazy import lazy
from drivers.array.freenas import Freenass
from core.pool import BasePool

LOCK_NAME = "freenas_create_disk"
LOCK_NAME = "freenas_update_disk"
LOCK_TIMEOUT = 120

class Pool(BasePool):
type = "freenas"
capabilities = ["roo", "rwo", "shared", "blk", "iscsi"]
capabilities = ["roo", "rwo", "rox", "rwx", "shared", "blk", "iscsi"]

@lazy
def insecure_tpc(self):
Expand All @@ -30,7 +29,16 @@ def blocksize(self):
return self.oget("blocksize")

def delete_disk(self, name=None, disk_id=None):
return self.array.del_iscsi_zvol(name=name, volume=self.diskgroup)
lock_id = None
result = {}
try:
lock_id = self.node._daemon_lock(LOCK_NAME, timeout=LOCK_TIMEOUT, on_error="raise")
self.log.info("lock acquired: name=%s id=%s", LOCK_NAME, lock_id)
result = self.array.del_iscsi_zvol(name=name, volume=self.diskgroup)
finally:
self.node._daemon_unlock(LOCK_NAME, lock_id)
self.log.info("lock released: name=%s id=%s", LOCK_NAME, lock_id)
return result

def create_disk(self, name, size, nodes=None):
mappings = self.get_mappings(nodes)
Expand All @@ -39,7 +47,7 @@ def create_disk(self, name, size, nodes=None):
lock_id = None
result = {}
try:
lock_id = self.node._daemon_lock(LOCK_NAME, timeout=120, on_error="raise")
lock_id = self.node._daemon_lock(LOCK_NAME, timeout=LOCK_TIMEOUT, on_error="raise")
self.log.info("lock acquired: name=%s id=%s", LOCK_NAME, lock_id)
result = self.array.add_iscsi_zvol(name=name, size=size,
volume=self.diskgroup,
Expand All @@ -51,7 +59,7 @@ def create_disk(self, name, size, nodes=None):
finally:
self.node._daemon_unlock(LOCK_NAME, lock_id)
self.log.info("lock released: name=%s id=%s", LOCK_NAME, lock_id)
return result
return result

def translate(self, name=None, size=None, fmt=True, shared=False):
data = []
Expand Down
3 changes: 3 additions & 0 deletions opensvc/drivers/resource/volume/__init__.py
Expand Up @@ -655,6 +655,9 @@ def provisioner(self):
raise ex.Error("volume provision returned %d" % ret)
self.can_rollback = True
self.can_rollback_vol_instance = True
self.post_provision_reset_lazy()

def post_provision_reset_lazy(self):
self.unset_lazy("device")
self.unset_lazy("mount_point")
self.unset_lazy("volsvc")
Expand Down

0 comments on commit fc0c5a3

Please sign in to comment.