Project

General

Profile

Actions

Bug #3773

closed

puppet class key update type change results in default_value invalid (1.2.2)

Added by Jon Shanks over 10 years ago. Updated over 10 years ago.

Status:
Duplicate
Priority:
Normal
Assignee:
-
Category:
Puppet integration
Target version:
-
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

If a module has been imported and the key types are identified for that puppet class but they change i.e. they alter from an array to a string or maybe to a null value i.e. false. It fails to update the DB accordingly with the new changes.

class ntp($packages = []) { }

Results in:

SELECT DISTINCT "lookup_keys".* FROM "lookup_keys" INNER JOIN "environment_classes" ON "lookup_keys"."id" = "environment_classes"."lookup_key_id" WHERE "environment_classes"."puppetclass_id" = 99 AND "lookup_keys"."key" = 'packages' AND (environment_classes.lookup_key_id is NOT NULL) ORDER BY lookup_keys.key LIMIT 1;
id | key | created_at | updated_at | puppetclass_id | default_value | path | description |
validator_type | validator_rule | is_param | key_type | override | required | lookup_values_count
-----+----------+----------------------------+----------------------------+----------------+---------------+------+-------------+
----------------+----------------+----------+----------+----------+----------+---------------------
292 | packages | 2013-10-03 09:44:35.514242 | 2013-10-03 09:44:35.514242 | | --- [] | | | | | t | array | f | f | 0

Override is set to false:

def update_parameter(db_class, changed_params)
changed_params["updated"].each do |param_name, value|
key = db_class.class_params.find_by_key param_name
if key.override == false
key.default_value = value
key.save!
fh.close
end
end
end

If the code alters to

class ntp($packages = false) { } or class ntp($packages = 'anything') { }

When the import shows that there are updates to NTP, it then throws an error. This seems to be due to the fact that it's type has altered from an array to something different i.e. string, or maybe boolean.

LookupKey Load (2.0ms)  SELECT DISTINCT "lookup_keys".* FROM "lookup_keys" INNER JOIN "environment_classes" ON "lookup_keys"."id" = "environment_classes"."lookup_key_id" WHERE "environment_classes"."puppetclass_id" = 99 AND "lookup_keys"."key" = 'packages' AND (environment_classes.lookup_key_id is NOT NULL) ORDER BY lookup_keys.key LIMIT 1
(0.8ms) BEGIN
(0.7ms) ROLLBACK
Operation FAILED: Validation failed: Default value is invalid
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/validations.rb:56:in `save!'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/attribute_methods/dirty.rb:33:in `save!'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/transactions.rb:246:in `block in save!'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/transactions.rb:295:in `block in with_transaction_returning_status'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/transactions.rb:208:in `transaction'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/transactions.rb:293:in `with_transaction_returning_status'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/transactions.rb:246:in `save!'
/usr/share/foreman/app/models/puppet_class_importer.rb:214:in `block in update_parameter'
/usr/share/foreman/app/models/puppet_class_importer.rb:206:in `each'
/usr/share/foreman/app/models/puppet_class_importer.rb:206:in `update_parameter'
/usr/share/foreman/app/models/puppet_class_importer.rb:201:in `block in update_classes_in_foreman'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/relation/delegation.rb:6:in `each'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/relation/delegation.rb:6:in `each'
/usr/share/foreman/app/models/puppet_class_importer.rb:194:in `update_classes_in_foreman'
/usr/share/foreman/app/models/puppet_class_importer.rb:54:in `block in obsolete_and_new'
/usr/share/foreman/app/models/puppet_class_importer.rb:46:in `each'
/usr/share/foreman/app/models/puppet_class_importer.rb:46:in `obsolete_and_new'
/usr/share/foreman/lib/foreman/controller/environments.rb:28:in `obsolete_and_new'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_controller/metal/implicit_render.rb:4:in `send_action'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/abstract_controller/base.rb:167:in `process_action'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_controller/metal/rendering.rb:10:in `process_action'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/abstract_controller/callbacks.rb:18:in `block in process_action'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:527:in `block (3 levels) in run_3890897385267331029__process_action__4051149281358796367__callbacks'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:215:in `block in conditional_callback_around_5615'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:326:in `around'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:310:in `_callback_around_5443'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:214:in `_conditional_callback_around_5615'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:526:in `block (2 levels) in _run
_3890897385267331029__process_action__4051149281358796367__callbacks'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:215:in `block in conditional_callback_around_5614'
/usr/share/foreman/lib/foreman/thread_session.rb:31:in `clear_thread'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:214:in `_conditional_callback_around_5614'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:415:in `block in _run
_3890897385267331029__process_action__4051149281358796367__callbacks'

Related issues 1 (0 open1 closed)

Is duplicate of Foreman - Bug #2758: On class reimport, Foreman runs class parameter validations even when parameter override is disabledClosed07/08/2013Actions
Actions #1

Updated by Dominic Cleal over 10 years ago

  • Category set to Puppet integration
  • Status changed from New to Feedback

Dupe of #2758 I think, can you confirm please?

Actions #2

Updated by Jon Shanks over 10 years ago

Fast response!

Yep, that is it actually. Fixed in 1.3 then.

Will upgrade.

Thanks

Jon

Actions #3

Updated by Dominic Cleal over 10 years ago

  • Is duplicate of Bug #2758: On class reimport, Foreman runs class parameter validations even when parameter override is disabled added
Actions #4

Updated by Dominic Cleal over 10 years ago

  • Status changed from Feedback to Duplicate

Great, thanks.

Actions

Also available in: Atom PDF