Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lightos driver: add lightos volume driver #1

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

yogev-lb
Copy link

@yogev-lb yogev-lb commented Jan 12, 2022

initial commit to add our driver to the cinder fork

in order to run the unittests:

Test all lightos ut:

source .tox/py38/bin/activate
stestr run -n cinder.tests.unit.volume.drivers.lightos.test_lightos_storage.LightOSStorageVolumeDriverTest
stestr run -n cinder.tests.unit.volume.drivers.lightos.test_lightos_storage.LightOSStorageVolumeDriverTest.<test_name>

Test specific method by name:

source .tox/py38/bin/activate
stestr run -n cinder.tests.unit.volume.drivers.lightos.test_lightos_storage.LightOSStorageVolumeDriverTest.<test_name>

@yogev-lb yogev-lb requested a review from tomerg-lb January 12, 2022 12:50
@yogev-lb yogev-lb force-pushed the yogev/add-unittests branch 3 times, most recently from 2653c0b to b9ab6b9 Compare January 12, 2022 15:56
@yogev-lb yogev-lb force-pushed the yogev/add-unittests branch from b9ab6b9 to 6f24010 Compare January 12, 2022 16:52
@yogev-lb yogev-lb requested a review from sagi-lb January 12, 2022 16:52
@@ -0,0 +1,3 @@
DEVICE_SCAN_ATTEMPTS_DEFAULT = 5
LIGHTOS = "LIGHTOS"
LIGHTOS_API_SERVICE_TIMEOUT = 30

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

newline

@yogev-lb yogev-lb force-pushed the yogev/add-unittests branch 2 times, most recently from a3b644a to 8d41f09 Compare January 13, 2022 10:19
self.driver.configuration.lightos_api_address = ""
self.assertRaises(exception.InvalidParameterValue, lightos.LightOSConnection, self.driver.configuration)

# Yogev

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are some local comments as well as commented out code that should be removed

@yogev-lb yogev-lb force-pushed the yogev/add-unittests branch 3 times, most recently from 4a32ddd to 67a8f77 Compare January 14, 2022 07:14
FAKE_LIGHTOS_CLUSTER_INFO: Dict[str, str] = {
'UUID': "926e6df8-73e1-11ec-a624-07ba3880f6cc",
'subsystemNQN': "nqn.2014-08.org.nvmexpress:NVMf:uuid:"\
"f4a89ce0-9fc2-4900-bfa3-00ad27995e7b"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

possibly also init statistics, to enable future coverage of get_Stats

"src_snapshot_name": kwargs["src_snapshot_name"],
"acl": kwargs["acl"],
"UUID": str(uuid.uuid4()),
"state": "Available",
Copy link

@ronen-lb ronen-lb Jan 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not critical but real lightOS response will return the as Creating.
we want it as avaialble in DB.
so can possibly init here to creating.
and clone object update cloned pbject to available before adding to db.

"UUID": str(uuid.uuid4()),
"state": "Available",
}
project = self.db["projects"].setdefault(project_name, {})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so create a volume will also set/create a project in db?

project_name = kwargs["project_name"]
volume_uuid = kwargs["volume_uuid"]
project = self.db["projects"].get(project_name, None)
if project:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we dont find project we seem to fall down to raise runtime error.
i think close emulation of product is
return (httpstatus.INVALID_ARGUMENT, None)

if project:
volume = next(
iter(
volume for volume in project["volumes"] \

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not use a dict under project["volumes"] with volume uuid as key?

project_name = kwargs["project_name"]
volume_uuid = kwargs["volume_uuid"]
project = self.db["projects"].get(project_name, None)
if project:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see comment above about project not found


def __init__(self):
self.data = {
"projects"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to initialist it as a map shouldnt it be "projects" : {} ?

def create_volume(self, volume):
assert volume.project_name and volume.name, "must be provided"
project = self.get_or_create_project(volume.project_name)
volumes = project.setdefault("volumes", {})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

create volume in lightOS is not idempotent we will return error if already exist

proj_vols = project.get("volumes", None)
if not proj_vols:
return
proj_vols.remove(volume)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lightos wil lreturn err if volume is not found (likely something we need to change)

@yogev-lb yogev-lb force-pushed the yogev/add-unittests branch from 67a8f77 to d7ba8d7 Compare January 14, 2022 14:40
states=states_to_wait_for,
vol_uuid=vol_uuid,
vol_name=vol_name)
states = ('Available', 'Deleting', 'Deleted', 'Failed', 'UNKNOWN')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note that lightOS will never return Deleted

not for now, but need to discuss what we want to do for states rollback and in particular migrating

vol_name=vol_name)
state = resp.get('state', 'UNKNOWN') if \
status_code == httpstatus.OK and resp else 'UNKNOWN'
if state in states and status_code != httpstatus.NOT_FOUND:
Copy link

@ronen-lb ronen-lb Jan 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we break here on any err exepect for not_found?
i.e for internal error (etcd down) we want to retry.
possibly the only two cases we dont want to retry are if we fail authntication (shouldnt happen happy flow)
or invalide arg (no name and no uuid, should also not happen happy flow)

project_name, timeout, states=(
'Deleted', 'Deleting', 'UNKNOWN'), vol_uuid=vol_uuid)
assert vol_uuid, 'LightOS volume UUID must be specified'
states = ('Deleted', 'Deleting', 'UNKNOWN')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lightOS wont return state Deleted, either one of the active volume states (Aviaalble, updating, creating, migrating, rollback), failed state or deleting
deleted volume will return unkown

@yogev-lb yogev-lb force-pushed the yogev/add-unittests branch from d7ba8d7 to 89d1c55 Compare January 14, 2022 15:27
return 'Deleted'
state = resp.get('state', 'UNKNOWN') if \
status_code == httpstatus.OK and resp else 'UNKNOWN'
if state in states:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thnk this would be clearr if you just check state== deleting (deleted and unkown should never be returned)

@@ -738,7 +738,7 @@ def _create_volume(self, volume, src_snapshot_lightos_name):
src_snapshot_lightos_name=src_snapshot_lightos_name)

# when we get here, we definitely tried to create it in the past
if status_code == httpstatus.OK:
if status_code in (httpstatus.OK, httpstatus.CREATED):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is for UT? lighttOS can return status created?

@yogev-lb yogev-lb force-pushed the yogev/add-unittests branch 4 times, most recently from fd084ae to 2192673 Compare January 16, 2022 09:37
@yogev-lb yogev-lb force-pushed the yogev/add-unittests branch from 2192673 to 65e652d Compare January 16, 2022 10:09
in order to mock these two pieces of code we must inject them from
outside.
…nection

add some validation where needed for input values from config.
wait for volume delete and wait for volume create behave differently.
NOT_FOUND means different things between create and delete.
for create it means that we didn't start yet.
for delete it means that the volume is gone and nothing to do.
Wait for snapshot delete and wait for snapshot create behave
differently.
NOT_FOUND means different things between create and delete.
for create it means that we didn't start yet.
for delete it means that the snapshot is gone and nothing to do.
add unittests for the lightos cinder driver.
try to mock as littel as possible by overriding the send_cmd method of
the connector.
@yogev-lb yogev-lb force-pushed the yogev/add-unittests branch from 65e652d to 682c746 Compare January 16, 2022 16:20
Copy link

@tomerg-lb tomerg-lb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yogev-lb , is this still relevant? If not, please close

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants