Bug 790186

Summary: [ovirt] [vdsm] deactivate missing domain fails on UnboundLocal error
Product: [Retired] oVirt Reporter: Haim <hateya>
Component: vdsmAssignee: Dan Kenigsberg <danken>
Status: CLOSED WONTFIX QA Contact:
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: unspecifiedCC: abaron, acathrow, amureini, bazulay, hateya, iheim, mgoldboi, yeylon, ykaul
Target Milestone: ---   
Target Release: 3.3.4   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: storage
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-03-11 21:58:37 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: Storage RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Haim 2012-02-13 21:00:24 UTC
Description of problem:

The following case is true when trying to deactivate missing storage domain (i.e - removed, deleted, no longer exists):

Thread-14935::WARNING::2012-02-13 22:42:52,096::sp::1063::Storage.StoragePool::(deactivateSD) deactivating missing domain 8150bd54-f64f-490e-98fd-e1efb7a250e1
Traceback (most recent call last):
  File "/usr/share/vdsm/storage/sp.py", line 1057, in deactivateSD
    dom = sdCache.produce(sdUUID)
  File "/usr/share/vdsm/storage/sdc.py", line 91, in produce
    dom = self._findDomain(sdUUID)
  File "/usr/share/vdsm/storage/sdc.py", line 115, in _findDomain
    raise se.StorageDomainDoesNotExist(sdUUID)
StorageDomainDoesNotExist: Storage domain does not exist: ('8150bd54-f64f-490e-98fd-e1efb7a250e1',)
Thread-14935::ERROR::2012-02-13 22:42:52,097::task::855::TaskManager.Task::(_setError) Task=`f7c49c11-8195-4684-acce-d197e59f501b`::Unexpected error
Traceback (most recent call last):
  File "/usr/share/vdsm/storage/task.py", line 863, in _run
    return fn(*args, **kargs)
  File "/usr/share/vdsm/logUtils.py", line 38, in wrapper
    res = f(*args, **kwargs)
  File "/usr/share/vdsm/storage/hsm.py", line 897, in deactivateStorageDomain
    pool.deactivateSD(sdUUID, msdUUID, masterVersion)
  File "/usr/share/vdsm/storage/sp.py", line 1078, in deactivateSD
    dom.releaseHostId(self.id)
UnboundLocalError: local variable 'dom' referenced before assignment

Analysis: 

We start in sp,py, deactivateSD() function, we are trying to build domain list from cache, but exception is thrown, as 'domain' doesn't exits, code handles the following exceptions: se.StorageException, AttributeError, Timeout but not UnboundlocalError, so dom parameter object is not initialized, flow continues, and we try to use dom object in line 1078, but its not set. 

Result: domain stay up for good.

Comment 1 Haim 2012-02-13 21:10:49 UTC
(In reply to comment #0)
> Description of problem:
> 
> The following case is true when trying to deactivate missing storage domain
> (i.e - removed, deleted, no longer exists):
> 
> Thread-14935::WARNING::2012-02-13
> 22:42:52,096::sp::1063::Storage.StoragePool::(deactivateSD) deactivating
> missing domain 8150bd54-f64f-490e-98fd-e1efb7a250e1
> Traceback (most recent call last):
>   File "/usr/share/vdsm/storage/sp.py", line 1057, in deactivateSD
>     dom = sdCache.produce(sdUUID)
>   File "/usr/share/vdsm/storage/sdc.py", line 91, in produce
>     dom = self._findDomain(sdUUID)
>   File "/usr/share/vdsm/storage/sdc.py", line 115, in _findDomain
>     raise se.StorageDomainDoesNotExist(sdUUID)
> StorageDomainDoesNotExist: Storage domain does not exist:
> ('8150bd54-f64f-490e-98fd-e1efb7a250e1',)
> Thread-14935::ERROR::2012-02-13
> 22:42:52,097::task::855::TaskManager.Task::(_setError)
> Task=`f7c49c11-8195-4684-acce-d197e59f501b`::Unexpected error
> Traceback (most recent call last):
>   File "/usr/share/vdsm/storage/task.py", line 863, in _run
>     return fn(*args, **kargs)
>   File "/usr/share/vdsm/logUtils.py", line 38, in wrapper
>     res = f(*args, **kwargs)
>   File "/usr/share/vdsm/storage/hsm.py", line 897, in deactivateStorageDomain
>     pool.deactivateSD(sdUUID, msdUUID, masterVersion)
>   File "/usr/share/vdsm/storage/sp.py", line 1078, in deactivateSD
>     dom.releaseHostId(self.id)
> UnboundLocalError: local variable 'dom' referenced before assignment
> 
> Analysis: 
> 
> We start in sp,py, deactivateSD() function, we are trying to build domain list
> from cache, but exception is thrown, as 'domain' doesn't exits, code handles
> the following exceptions: se.StorageException, AttributeError, Timeout but not
> UnboundlocalError, so dom parameter object is not initialized, flow continues,
> and we try to use dom object in line 1078, but its not set. 

we shouldn't catch the UnboundlocalError, it happens due to the un-initialized object reference before assignment, we should not release host id once we fails though. 


> 
> Result: domain stay up for good.

Comment 2 Itamar Heim 2013-03-11 21:58:37 UTC
Closing old bugs. If this issue is still relevant/important in current version, please re-open the bug.