Skip to content
This repository has been archived by the owner on Nov 9, 2020. It is now read-only.

vmdk volume should not be created on vsan datastore while passing not compatible VSAN policy or policy content is wrong #874

Closed
shuklanirdesh82 opened this issue Jan 24, 2017 · 2 comments

Comments

@shuklanirdesh82
Copy link
Contributor

shuklanirdesh82 commented Jan 24, 2017

Steps to reproduce:

  1. create not-compatible vsan policy
vmdkops_admin.py policy create --name notSatisfiable_policy --content '(("proportionalCapacity" i0)("hostFailuresToTolerate" i3))'
  1. verifies policy is created or not
[root@sc-rdops-vm02-dhcp-37-215:~] /usr/lib/vmware/vmdkops/bin/vmdkops_admin.py policy ls
Policy Name  Policy Content                                              Active  
-----------  ----------------------------------------------------------  ------  
notSatisfiable_policy           (("proportionalCapacity" i0)("hostFailuresToTolerate" i3))  Unused 
  1. create docker volume with the created policy
root@photon-TX4FfW2ET [ ~ ]# docker volume create --driver=vmdk --name=t3 -o vsan-policy-name=notSatisfiable_policy     
t3

vmdkops_admin.py ls
Volume    Datastore      Created By VM                    Created                   Attached To VM  Policy          Capacity  Used     Disk Format  Filesystem Type  Access      Attach As               
--------  -------------  -------------------------------  ------------------------  --------------  --------------  --------  -------  -----------  ---------------  ----------  ----------------------  
t3        vsanDatastore  standalone-c2bea60d2-esx.2-vm.0  Tue Jan 24 00:00:11 2017  detached        [VSAN default]  100.00MB  80.00MB  thin         ext4             read-write  independent_persistent 

Current behavior: volume is created successfully without associating the passed policy and falls back to [VSAN default]

Expectation: volume should not be created while using non-compatible/not-satisfiable policy or when the policy content format is bad

https://github.com/vmware/docker-volume-vsphere/blob/master/esx_service/vmdk_ops.py#L193

# Handle vsan policy
    if kv.VSAN_POLICY_NAME in opts:
        if not vsan_policy.set_policy_by_name(vmdk_path, opts[kv.VSAN_POLICY_NAME]):
            # Drop the failed option
            # A warning is being logged in the called functions
            del opts[kv.VSAN_POLICY_NAME]

on ESX:

*** createVMDK: /vmfs/volumes/vsanDatastore/dockvols/8419cc85-f2b6-4761-a4aa-042814fb3d38/t3.vmdk opts = {'vsan-policy-name': 'notSatisfiable_policy', 'fstype': 'ext4'} 
01/24/17 00:00:11 337757 [standalone-c2bea60d2-esx.2-vm.0-[vsanDatastore] dockvols/8419cc85-f2b6-4761-a4aa-042814fb3d38/t3.vmdk] [WARNING] Failed to set policy for /vmfs/volumes/vsanDatastore/dockvols/8419cc85-f2b6-4761-a4aa-042814fb3d38/t3.vmdk : Failed to set object policy : Out of resources 1835026.

object setPolicy error: Failure 

//CC @msterin @kerneltime @pdhamdhere

@shuklanirdesh82
Copy link
Contributor Author

Here is the analysis when the policy content is having wrong format.

Policy creation.

[root@sc-rdops-vm02-dhcp-37-215:~] /usr/lib/vmware/vmdkops/bin/vmdkops_admin.py policy create --name silver --content '(("proportionalCapacity" i0)("hostFailuresToTolerate" i0)'
Successfully created policy: silver

vmdk_ops.log

01/23/17 23:57:41 337757 [Thread-22] [INFO   ] cmd create with opts {'vsan-policy-name': 'silver', 'fstype': 'ext4'} on tenant_uuid 8419cc85-f2b6-4761-a4aa-042814fb3d38 datastore vsanDatastore is allowed to execute             
01/23/17 23:57:41 337757 [standalone-c2bea60d2-esx.2-vm.0-[vsanDatastore] dockvols/8419cc85-f2b6-4761-a4aa-042814fb3d38/t2.vmdk] [INFO   ] *** createVMDK: /vmfs/volumes/vsanDatastore/dockvols/8419cc85-f2b6-4761-a4aa-042814fb3d38/t2.vmdk opts = {'vsan-policy-name': 'silver', 'fstype': 'ext4'}
01/23/17 23:57:42 337757 [standalone-c2bea60d2-esx.2-vm.0-[vsanDatastore] dockvols/8419cc85-f2b6-4761-a4aa-042814fb3d38/t2.vmdk] [WARNING] Failed to set policy for /vmfs/volumes/vsanDatastore/dockvols/8419cc85-f2b6-4761-a4aa-042814fb3d38/t2.vmdk : error in line 2: syntax error 
 VSAN_SPBMToVsanPolicy: Failed to convert SPBM string to VsanExpr: Not ready                                                                                                                                                       
Failed to set object policy : Input/output error 327684.                                                                                                                                                                           
object setPolicy error: Failure

@pdhamdhere pdhamdhere added this to the v1 GA milestone Feb 1, 2017
@shaominchen
Copy link
Contributor

Over to Liping to take a look.

@pdhamdhere pdhamdhere modified the milestones: 0.12, v1 GA Feb 9, 2017
@tusharnt tusharnt assigned shaominchen and unassigned lipingxue Feb 9, 2017
@shaominchen shaominchen assigned pshahzeb and unassigned shaominchen Feb 16, 2017
pshahzeb pushed a commit that referenced this issue Feb 21, 2017
1. In case of wrong/incompatible policy, error is returned which is
   displayed on the client. Changing signature of set_policy to return
   the error thrown by VSAN
2. cleanVMDK to delete the vmdk file in cases when metafile hasn't been
   created but the vmdk is; and the vmdk file needs to be deleted
   Invoked as a part of removeVMDK procedure and
   cases requiring deletion of vmdk file only (when meta file
   hasn't been generated)
   eg: Unsuccesful attempt to apply vsan policy and when failed
   to create metadata for vmdk_path

Testing:
Added test scenario of impossible policy so that createVMDK fails
Add this in VmdkCreateRemoveTestCase

Resolves: #874
shuklanirdesh82 pushed a commit that referenced this issue Feb 25, 2017
* Failing volume create in case of wrong/incompatible VSAN policy

1. In case of wrong/incompatible policy, error is returned which is
   displayed on the client. Changing signature of set_policy to return
   the error thrown by VSAN
2. cleanVMDK to delete the vmdk file in cases when metafile hasn't been
   created but the vmdk is; and the vmdk file needs to be deleted
   Invoked as a part of removeVMDK procedure and
   cases requiring deletion of vmdk file only (when meta file
   hasn't been generated)
   eg: Unsuccesful attempt to apply vsan policy and when failed
   to create metadata for vmdk_path

Testing:
Added test scenario of impossible policy so that createVMDK fails
Add this in VmdkCreateRemoveTestCase

Resolves: #874

* Adding logs and a negative test case for bad policy content

* Adding CleanVMDK logs

* Correcting logs for cleanVMDK errors
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Projects
None yet
Development

No branches or pull requests

5 participants