Fixing list_volumes_and_policies() to correctly list volumes #953
Conversation
1. Using get_volumes() in list_volumes_and_policies() instead of list_vmdks() to properly walk in dockvols directory which contain tenant-uuid based subdirectories This fixes output by admin policy ls command 2. Fixing update_vsan_objects_with_policy to make proper use of list_volumes_and_policies() Testing: Porting the update_vsan_policy test to tenant based Vmdk ops test suite Manual testing of admin policy ls command done Resolves: #853
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 contingent to CI pass.
Can you also confirm in-use policy name can't be deleted?
@@ -204,33 +204,6 @@ def testAttachAsOpts(self): | |||
|
|||
@unittest.skipIf(not vsan_info.get_vsan_datastore(), | |||
"VSAN is not found - skipping vsan_info tests") | |||
def testPolicyUpdate(self): |
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.
is there a reason for removing this test?
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 test creates a vmdk inside dockvols folder, assign a good policy to it and then update the policy with bad content. In this case, it tries to list the vmdks associated with the good policy and set the updated policy to it. The test expects the update to fail because of the bad content. In this process, when the vsan_policy update api is invoked, no vmdks are listed because the vmdks are created inside tenant uuid named sub directories as per multi tenancy design. As no vmdk that would be affected are returned, this test case wasn't throwing an error.
I haven't removed it, but moved it to the test suite where tenant based vmdks are created.
Hence it properly lists the vmdk files, tries to update it and fails appropriately because of the bad content of policy
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.
Okay great!! Makes sense!
esx_service/vmdk_ops_test.py
Outdated
@@ -1039,6 +1012,55 @@ def test_vmdkops_on_tenant_vm(self): | |||
error_info = vmdk_ops.executeRequest(vm1_uuid, self.vm1_name, self.vm1_config_path, auth.CMD_REMOVE, self.tenant1_vol1_name, opts) | |||
self.assertEqual(None, error_info) | |||
|
|||
@unittest.skipIf(not vsan_info.get_vsan_datastore(), | |||
"VSAN is not found - skipping vsan_info tests") | |||
def testPolicyUpdateBackup(self): |
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.
can you confirm whether the test is added to cover proposed code in this PR?
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 proposed code in this PR hits in two ways. One through vsan update policy flow, for which following the test case is added. Second is the policy ls admin command which I have described in manual testing in description. Will add a unit test for this as well.
@pdhamdhere |
1. Minor change to use list_volumes_and_policies() instead of list_vmdks() to find vmdks using a policy Testing: 1. Manual testing done 2. Adding test cases to cover policy ls and policy rm functionality in vmdk_ops_test Resolves: #948
This also fixes #948 |
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.
@shuklanirdesh82 Are you okay with Shahzeb's explanation?
@@ -204,33 +204,6 @@ def testAttachAsOpts(self): | |||
|
|||
@unittest.skipIf(not vsan_info.get_vsan_datastore(), | |||
"VSAN is not found - skipping vsan_info tests") | |||
def testPolicyUpdate(self): |
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.
Okay great!! Makes sense!
@pshahzeb, couple of things to take care
|
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.
few comments for the added testcase.
esx_service/vmdk_ops_test.py
Outdated
if len(datastores) > 1: | ||
datastore1 = datastores[1] | ||
self.datastore1_name = datastore1[0] | ||
self.datastoer1_path = datastore[2] |
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.
do you mean datastore1[2]?
esx_service/vmdk_ops_test.py
Outdated
self.datastore1_name = datastore1[0] | ||
self.datastoer1_path = datastore[2] | ||
logging.debug("Found second datastore: datastore_name=%s datastore_path=%s", | ||
self.datastore1_name, self.datastore1_path) |
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.
are we really using self.datastore1_name
?
esx_service/vmdk_ops_test.py
Outdated
self.vm1_config_path = vmdk_utils.get_vm_config_path(self.vm1_name) | ||
logging.info("VmdkTenantPolicyUsageTestCase: create vm1 name=%s Done", self.vm1_name) | ||
|
||
error, self.vm2 = create_vm(si=si, |
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.
Is there a reason for creating second vm? it seems your test is not consuming second vm unless I have mistaken. Please clarify here.
esx_service/vmdk_ops_test.py
Outdated
error_info = vmdk_ops.executeRequest(vm1_uuid, self.vm1_name, self.vm1_config_path, | ||
auth.CMD_REMOVE, self.default_tenant_vol4_name, opts) | ||
self.assertEqual(None, error_info) | ||
|
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.
can you add similar check after removing volumes .. usage count should drop to 0 or vmdkops_admin.py policy ls
?
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! Thanks for addressing comments quickly!
You may want to squash the commit into one.
list_vmdks() to properly walk in dockvols directory which contain
tenant-uuid based subdirectories
This fixes output by admin policy ls command
of list_volumes_and_policies()
Testing:
Porting the update_vsan_policy test to tenant based Vmdk ops test suite
Manual testing of admin policy ls command done
Creating two volumes using the above policy
Resolves: #853 #948