-
Notifications
You must be signed in to change notification settings - Fork 0
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
base: master
Are you sure you want to change the base?
Conversation
2653c0b
to
b9ab6b9
Compare
b9ab6b9
to
6f24010
Compare
@@ -0,0 +1,3 @@ | |||
DEVICE_SCAN_ATTEMPTS_DEFAULT = 5 | |||
LIGHTOS = "LIGHTOS" | |||
LIGHTOS_API_SERVICE_TIMEOUT = 30 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
newline
a3b644a
to
8d41f09
Compare
self.driver.configuration.lightos_api_address = "" | ||
self.assertRaises(exception.InvalidParameterValue, lightos.LightOSConnection, self.driver.configuration) | ||
|
||
# Yogev |
There was a problem hiding this comment.
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
4a32ddd
to
67a8f77
Compare
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" |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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, {}) |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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"] \ |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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", {}) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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)
67a8f77
to
d7ba8d7
Compare
states=states_to_wait_for, | ||
vol_uuid=vol_uuid, | ||
vol_name=vol_name) | ||
states = ('Available', 'Deleting', 'Deleted', 'Failed', 'UNKNOWN') |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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') |
There was a problem hiding this comment.
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
d7ba8d7
to
89d1c55
Compare
return 'Deleted' | ||
state = resp.get('state', 'UNKNOWN') if \ | ||
status_code == httpstatus.OK and resp else 'UNKNOWN' | ||
if state in states: |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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?
fd084ae
to
2192673
Compare
2192673
to
65e652d
Compare
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.
65e652d
to
682c746
Compare
There was a problem hiding this 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
initial commit to add our driver to the cinder fork
in order to run the unittests:
Test all lightos ut:
Test specific method by name: