Bug 1343058

Summary: Orchestration does not roll back queued actions if DB error occurs
Product: Red Hat Satellite Reporter: Shimon Shtein <sshtein>
Component: OrchestrationAssignee: Shimon Shtein <sshtein>
Status: CLOSED ERRATA QA Contact: Roman Plevka <rplevka>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.2.0CC: adprice, bkearney, rplevka
Target Milestone: Unspecified   
Target Release: Unused   
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: 2018-02-21 16:49:54 UTC 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:
Bug Depends On:    
Bug Blocks: 1332652    

Description Shimon Shtein 2016-06-06 12:22:30 UTC
Description of problem:

If an SQL error occurs upon saving a host, the orchestration actions will still occur.


How reproducible:

Create a host with a missing foreign key (for example environment_id = 999), observe an exception thrown and orchestration leftovers.


Steps to Reproduce:

# hammer host create --name my-cli-host-1 --partition-table-id 61 --domain-id 1 --operatingsystem-id 3 --architecture-id 1 --compute-resource-id 1 --environment-id 999 --puppet-proxy-id 1 --location-id 1 --organization-id 1 --root-password changeme --medium-id 9
[Foreman] Password for admin: 
Could not create the host:
  ERROR:  insert or update on table "hosts" violates foreign key constraint "hosts_environment_id_fk"
  DETAIL:  Key (environment_id)=(999) is not present in table "environments".
[root@sat6 dhcp]# 
[root@sat6 dhcp]# 
[root@sat6 dhcp]# hammer host create --name my-cli-host-1 --partition-table-id 61 --domain-id 1 --operatingsystem-id 3 --architecture-id 1 --compute-resource-id 1 --environment-id 999 --puppet-proxy-id 1 --location-id 1 --organization-id 1 --root-password changeme --medium-id 9
[Foreman] Password for admin: 
Could not create the host:
  Failed to create a compute my_libvirt_cr_1 (Libvirt) instance my-cli-host-1.domain.com: Error saving the server: Call to virDomainDefineXML failed: operation failed: domain 'my-cli-host-1.domain.com' already exists with uuid 3d1ac10d-fb73-fb16-a3a3-503d7625e042


Expected results:

The second request succeeds.

Comment 1 Shimon Shtein 2016-06-06 12:28:25 UTC
Created redmine issue http://projects.theforeman.org/issues/15306 from this bug

Comment 3 Bryan Kearney 2016-06-29 16:16:05 UTC
Moving to POST since upstream bug http://projects.theforeman.org/issues/15306 has been closed

Comment 6 Roman Plevka 2016-10-14 12:30:38 UTC
VERIFIED
on sat6.3 snap3

<pre>
# hammer host create --name my-cli-host-1 --partition-table-id 80 --domain-id 1 --operatingsystem-id 3 --architecture-id 1 --compute-resource-id 1 --environment-id 999 --puppet-proxy-id 1 --location-id 1 --organization-id 1 --root-password changeme --medium-id 9
[Foreman] Password for admin: 
Could not create the host:
  ERROR:  insert or update on table "hosts" violates foreign key constraint "hosts_environment_id_fk"
  DETAIL:  Key (environment_id)=(999) is not present in table "environments".

# hammer host create --name my-cli-host-1 --partition-table-id 80 --domain-id 1 --operatingsystem-id 3 --architecture-id 1 --compute-resource-id 1 --environment-id 999 --puppet-proxy-id 1 --location-id 1 --organization-id 1 --root-password changeme --medium-id 9
[Foreman] Password for admin: 
Could not create the host:
  ERROR:  insert or update on table "hosts" violates foreign key constraint "hosts_environment_id_fk"
  DETAIL:  Key (environment_id)=(999) is not present in table "environments".
</pre>

Comment 7 Satellite Program 2018-02-21 16:49:54 UTC
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA.

For information on the advisory, and where to find the updated files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2018:0336