-
Notifications
You must be signed in to change notification settings - Fork 95
Not returning orphan/unknown tenant volumes during docker volume ls #1114
Conversation
Checking the tenant reg exp to see if the call was made to return volumes from any tenant and returning orphan/unknown tenant volumes only in such cases. Fixes #1111
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.
the fix looks good , but some style comments.
Also, tenant=None version seems to be broken - was not a part of this PR. but since you are touching this code anyways...
'filename': file_name, | ||
'datastore': datastore, | ||
'tenant' : auth_data_const.ORPHAN_TENANT}) | ||
|
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.
Line 130 looks broken to me - path
is .../dockvol, and should be ../dockvol/__DEFAULT.
for file_name in list_vmdks(root): | ||
volumes.append({'path': root, | ||
'filename': file_name, | ||
'datastore': datastore, |
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.
btw , L168-173 more python-ish would be something like this
volumes += [ {'path': root, 'filename': file_name, 'datastore': datastore,
'tenant' : auth_data_const.ORPHAN_TENANT} for file_name in list_vmdks(root)]
also applies to other places in this function
'tenant' : auth_data_const.ORPHAN_TENANT}) | ||
|
||
# return orphan volumes only in case when volumes from any tenants are asked | ||
if tenant_re == "*": |
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.
nit:
I think it's better to say
if tenant != '*'
return volumes
makes much less indent and easier to read.
@msterin |
Created #1121 for this. |
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.
LGTM
LGTM for now - but please file an issue for the bug and the refactor. |
#1121 Issue to track refactoring of get_volumes() util and fixing the related test cases as well |
Orphan/unknown tenant volumes should not be returned as a list of volumes when a specific tenant is specified. (docker volume ls)
They must be listed only when the tenant regex is "*" i.e. volumes belonging to any tenant. Such regex comes when we list volumes as a part of admin cli volume ls
Fixes #1111
Testing:
VM1 on ESX1 belongs to tenant1
VM2 on ESX2 belongs to tenant2
Create a volume from VM1 and list volumes
Admin cli output on ESX1
docker volume ls on VM2. Can't see volume created by VM1.
Admin cli output on ESX2.
CC @ashahi1