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 No newline at end of file | |||
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.
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.
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.
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.
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.
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.
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.
see comment above about project not found
|
|
||
| def __init__(self): | ||
| self.data = { | ||
| "projects" |
There was a problem hiding this comment.
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.
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.
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.
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.
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.
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.
thnk this would be clearr if you just check state== deleting (deleted and unkown should never be returned)
|
|
||
| # 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.
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
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: