Bug 2232577

Summary: Impossible to remove SD in inactive state via ansible, despite "destroy: true". Via API or UI works as intended
Product: Red Hat Enterprise Virtualization Manager Reporter: Andrea Perotti <aperotti>
Component: ovirt-ansible-collectionAssignee: Martin Perina <mperina>
Status: NEW --- QA Contact: Lukas Svaty <lsvaty>
Severity: high Docs Contact:
Priority: unspecified    
Version: 4.5.3   
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Andrea Perotti 2023-08-17 12:55:41 UTC
Description of problem:

While using the redhat.rhv.ovirt_storage_domain module from the redhat.rhv v2.4.2-1 collection, we are facing this scenario:

* Disaster (or simulation thereof) happens: LUNs are not accessible anymore, I/O is denied to the hypervisors.
* The only Storage Domain in the DataCenter goes into Inactive state. It was the master SD.
* No VMs are running (to simplify the scenario)
* At this time, if we need to perform a cleanup (i.e. remove/destroy the faulted SD) we would call the following task with Ansible:

- name: Destroy SD
  redhat.rhv.ovirt_storage_domain:
    auth: "{{ ovirt_auth }}"
    data_center: "{{ dc_name }}"
    name: "{{ sd_name }}"
    state: absent
    destroy: true
    wait: true
    host: "{{ one_of_the_cluster_hosts }}"

* The task always fails with Exception "Not possible to manage storage domain" because of function control_state() in ./plugins/modules/ovirt_storage_domain.py. The function checks whether the SD is in Unknown or Inactive state and in that case refuses to continue. 


Version-Release number of selected component (if applicable):
ovirt-ansible-collection-2.4.2-1.el8ev.noarch


Actual results:

* The function is called too early without taking into account the "destroy: true" variable. This means there is no way to reach the actual code calling the oVirt API for removing the SD.
* Manually performing the same operation - either via RHVM GUI, curl or ansible uri module - always succeeds.