Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1585472

Summary: Import data domain failed on storage domain still exist, after this domain was removed successfully
Product: [oVirt] ovirt-engine Reporter: Elad <ebenahar>
Component: BLL.StorageAssignee: Idan Shaby <ishaby>
Status: CLOSED NOTABUG QA Contact: Elad <ebenahar>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 4.2.4.1CC: bugs, ebenahar, frolland
Target Milestone: ovirt-4.3.0Keywords: Automation
Target Release: ---Flags: rule-engine: ovirt-4.3+
Hardware: x86_64   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-06-11 08:05:45 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: Storage RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
logs none

Description Elad 2018-06-03 11:47:03 UTC
Created attachment 1447198 [details]
logs

Description of problem:
Removed a storage domain without formatting it. Tried to import the domain back to the DC. Import failed on:
Cannot add Storage. The Storage Domain name is already in use


Version-Release number of selected component (if applicable):
ovirt-engine-4.2.4-0.1.el7.noarch
vdsm-4.20.28-1.el7ev.x86_64


How reproducible:
Happened once, on our automation (using REST API)

Steps to Reproduce:
1. Create a storage (iscsi), create some disks on it
2. Deactivate, detach and remove without format the domain
3. Import the domain to the DC right after

Actual results:
Storage domain was reported to be removed successfully:

2018-05-28 16:51:06,077+03 INFO  [org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector] (default task-8) [storagedomains_delete_9fc95414-55c9-] EVENT_ID: USER_REMOVE_STORAGE_DOMAIN(960), Storage 
Domain sd_type_2816434515 was removed by admin@internal-authz
2018-05-28 16:51:06,081+03 INFO  [org.ovirt.engine.core.bll.storage.domain.RemoveStorageDomainCommand] (default task-8) [storagedomains_delete_9fc95414-55c9-] Lock freed to object 'EngineLock:{exclusiveLocks='[f
69fa2cb-53be-4ad6-a358-58d936c64539=STORAGE]', sharedLocks=''}'


Import domain attemp (the same domain that was reported to be removed successfully before):

2018-05-28 16:55:39,471+03 INFO  [org.ovirt.engine.core.bll.storage.domain.AddExistingBlockStorageDomainCommand] (default task-11) [storagedomains_create_23b135a0-8327-] Lock freed to object 'EngineLock:{exclusi
veLocks='[d6087e61-b897-4e14-be0c-f07413b634c8=STORAGE]', sharedLocks=''}'



Import domain failed:

2018-05-28 16:55:39,479+03 ERROR [org.ovirt.engine.api.restapi.resource.AbstractBackendResource] (default task-11) [] Operation Failed: [Cannot add Storage. The Storage Domain name is already in use.]


Expected results:
The domain should have been removed successfully.

Additional info:
logs

Comment 1 Tal Nisan 2018-06-03 13:29:55 UTC
Do you still have access to the environment? Might be that there has been some race in the test, can you try if it succeeds now?

Comment 2 Elad 2018-06-03 13:37:17 UTC
Just noticed the test case failed on the same issue with latest build - ovirt-4.2.4.

Comment 3 Tal Nisan 2018-06-03 14:21:53 UTC
Fred, can you have a look please?

Comment 4 Fred Rolland 2018-06-06 12:57:52 UTC
The audit log is emitted when the command ends, however the removal of the storage domain is done in another transaction.

So there is a time window between the log audit and the DB update where adding a new SD with the same name will fail.

https://github.com/oVirt/ovirt-engine/blob/b9d01e3da7cb16edd508b5706b4905cd6e107ca1/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/domain/RemoveStorageDomainCommand.java#L85

We need to check if it could be done in the same transaction

Comment 5 Idan Shaby 2018-06-11 08:05:45 UTC
From looking at your engine's log, I think that the problem might be in the test.
It looks like the test doesn't really remove a storage domain and then tries to import it, but rather import an existing domain that wasn't ever removed at all.

In the log, there are a few storage domains' removals. Among others, there's the removal of the one with ID=f69fa2cb-53be-4ad6-a358-58d936c64539 that you wrote about in the description of the bug.
However, the error that you got from AddExistingBlockStorageDomainCommand was about a storage domain with ID=d6087e61-b897-4e14-be0c-f07413b634c8, which was not removed at all (at least not at the past 7 hours that can be seen in the log).

Closing as "not a bug".
If you find this information wrong, please reopen and attach the relevant logs.

Comment 6 Elad 2018-06-12 10:25:27 UTC
Thanks Idan, 
We've done a deep investigation and indeed, in the test execution, we are importing all the unregistered storage domain the host sees after discovery. This is not the desired test behavior, we'll adjust our automation.