Project

General

Profile

Bug #34232

Clean discovery attributes on managed hosts too

Added by Lukas Zapletal 4 months ago. Updated 4 months ago.

Status:
Ready For Testing
Priority:
Normal
Category:
-
Target version:
Difficulty:
Triaged:
Yes
Bugzilla link:
Fixed in Releases:
Found in Releases:

Description

Discovered hosts have 1:1 relationship to DiscoveryAttributeSet model, in Rails the relationship is also specified for the "Host::Discovered" STI class.

During discovered provisioning, application performs a ton of stuff and we do not use SQL transactions due to the fact it breaks callbacks (thus Dynflow/Tasks). When discovery process fails, an incorrect managed host can be sometimes left in the database. The host was already changed to Host::Managed type, but transaction was not processed to the end, when DiscoveryAttributeSet is deleted.

Such a host now still have a related record in the SQL database (with its FOREIGN KEY constraint), but Rails does not see the relationship anymore as the type is not Host::Discovered. Any attempt to delete such host will fail with a foreign key SQL error.

The solution is to simply extend the managed host to also clean up all (now irrelevant) DiscoveryAttributeSet records on delete.

History

#1 Updated by The Foreman Bot 4 months ago

  • Status changed from New to Ready For Testing
  • Pull request https://github.com/theforeman/foreman_discovery/pull/561 added

Also available in: Atom PDF