Project

General

Profile

Bug #12746

Compute resources can disappear in a development instance

Added by Stephen Benjamin about 5 years ago. Updated over 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Compute resources
Target version:
Difficulty:
Triaged:
Bugzilla link:
Fixed in Releases:
Found in Releases:

Description

Compute resource store plugin registered resources like this: https://github.com/theforeman/foreman/blob/develop/app/models/compute_resource.rb#L13

If you notice, assignment is being done every time the class is loaded. So, let's take foreman_docker and how the 'Docker' compute resource can completely disappear in a dev environment:

(1) foreman_docker engine.r calls ComputeResource.register_provider
(2) register_provider adds Docker to supported_providers class attributes
(3) something causes the ComputeResource class to be reloaded
(4) Line #13 is re-evaluated, and the supported_providers is reset to the default (without docker)

You can try this out:

2.1.5 :008 > ComputeResource.providers
 => ["Libvirt", "Ovirt", "EC2", "Vmware", "Openstack", "Rackspace", "GCE", "Docker"] 
2.1.5 :009 > require 'compute_resource' # simulate reload
Creating scope :live_descendants. Overwriting existing method ComputeResource.live_descendants.
 => true 
2.1.5 :010 > ComputeResource.providers
 => ["Libvirt", "Ovirt", "EC2", "Vmware", "Openstack", "Rackspace", "GCE"] 

Related issues

Related to Foreman - Refactor #12747: Provide some kind of central store or consistent way to manage dynamically registered objects from pluginsResolved2015-12-08
Has duplicate Foreman - Bug #13694: compute resource provider from plugin missing sometimesDuplicate2016-02-13

Associated revisions

Revision 355c3a31 (diff)
Added by Dominic Cleal almost 5 years ago

fixes #12746 - list compute resources from plugin definitions

Load the full list of known CRs from plugins on the fly, instead of
modifying the class-level list of supported plugins. Since plugin
definitions don't get reloaded, this allows the ComputeResource class to
be reloaded without affecting the registered list.

Changes the apipie translation use of ComputeResource.providers to a
lambda to prevent foreman/plugin being autoloaded before it's required
in config/initializers/foreman.rb, and to ensure CRs from plugins are
listed.

Previously registered provider names are no longer rejected, instead
they are merged with preference given to plugins, allowing them to
override existing provider names in Foreman.

History

#1 Updated by Stephen Benjamin about 5 years ago

  • Related to Refactor #12747: Provide some kind of central store or consistent way to manage dynamically registered objects from plugins added

#2 Updated by Dominic Cleal almost 5 years ago

  • Has duplicate Bug #13694: compute resource provider from plugin missing sometimes added

#3 Updated by Dominic Cleal almost 5 years ago

  • Status changed from New to Assigned
  • Assignee set to Dominic Cleal

#4 Updated by The Foreman Bot almost 5 years ago

  • Status changed from Assigned to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/3377 added

#5 Updated by Dominic Cleal almost 5 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100

#6 Updated by Dominic Cleal almost 5 years ago

  • Legacy Backlogs Release (now unused) set to 136

Also available in: Atom PDF