Bug #19980
openError in ENC YAML generation when merge enabled and variable or macro is present in parameters
Description
If you try to add a variable (<%= @host.name %>) or macro in a parameter (array or hash) that is merged foreman fails to generate the YAML output for puppet with the following error in the production log:
2017-06-12T11:32:43 xxx [app] [W] Failed to generate external nodes for xxx
| NoMethodError: undefined method `each_pair' for #<String:xxx>
| /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-4.2.8/lib/active_support/core_ext/hash/deep_merge.rb:22:in `deep_merge!'
| /usr/share/foreman/app/services/classification/base.rb:227:in `block in update_hash_matcher'
| /usr/share/foreman/app/services/classification/base.rb:222:in `reverse_each'
| /usr/share/foreman/app/services/classification/base.rb:222:in `update_hash_matcher'
| /usr/share/foreman/app/services/classification/base.rb:59:in `block in values_hash'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/activerecord-4.2.8/lib/active_record/relation/delegation.rb:46:in `each'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/activerecord-4.2.8/lib/active_record/relation/delegation.rb:46:in `each'
| /usr/share/foreman/app/services/classification/base.rb:37:in `values_hash'
| /usr/share/foreman/app/services/classification/class_param.rb:5:in `enc'
| /usr/share/foreman/app/models/host/managed.rb:902:in `lookup_keys_class_params'
| /usr/share/foreman/app/models/host/managed.rb:868:in `enc_puppetclasses'
| /usr/share/foreman/app/models/host/managed.rb:406:in `info'
| /usr/share/foreman/app/controllers/hosts_controller.rb:204:in `block in externalNodes'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/actionpack-4.2.8/lib/action_controller/metal/mime_responds.rb:212:in `respond_to'
| /usr/share/foreman/app/controllers/hosts_controller.rb:202:in `externalNodes'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/actionpack-4.2.8/lib/action_controller/metal/implicit_render.rb:4:in `send_action'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/actionpack-4.2.8/lib/abstract_controller/base.rb:198:in `process_action'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/actionpack-4.2.8/lib/action_controller/metal/rendering.rb:10:in `process_action'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/actionpack-4.2.8/lib/abstract_controller/callbacks.rb:20:in `block in process_action'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-4.2.8/lib/active_support/callbacks.rb:117:in `call'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-4.2.8/lib/active_support/callbacks.rb:117:in `call'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-4.2.8/lib/active_support/callbacks.rb:555:in `block (2 levels) in compile'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-4.2.8/lib/active_support/callbacks.rb:505:in `call'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-4.2.8/lib/active_support/callbacks.rb:505:in `call'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-4.2.8/lib/active_support/callbacks.rb:498:in `block (2 levels) in around'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-4.2.8/lib/active_support/callbacks.rb:313:in `call'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-4.2.8/lib/active_support/callbacks.rb:313:in `block (2 levels) in halting'
| /usr/share/foreman/app/controllers/concerns/application_shared.rb:15:in `set_timezone'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-4.2.8/lib/active_support/callbacks.rb:432:in `block in make_lambda'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-4.2.8/lib/active_support/callbacks.rb:312:in `call'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-4.2.8/lib/active_support/callbacks.rb:312:in `block in halting'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-4.2.8/lib/active_support/callbacks.rb:497:in `call'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-4.2.8/lib/active_support/callbacks.rb:497:in `block in around'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-4.2.8/lib/active_support/callbacks.rb:505:in `call'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-4.2.8/lib/active_support/callbacks.rb:505:in `call'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-4.2.8/lib/active_support/callbacks.rb:498:in `block (2 levels) in around'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-4.2.8/lib/active_support/callbacks.rb:313:in `call'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-4.2.8/lib/active_support/callbacks.rb:313:in `block (2 levels) in halting'
| /usr/share/foreman/app/models/concerns/foreman/thread_session.rb:32:in `clear_thread'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-4.2.8/lib/active_support/callbacks.rb:432:in `block in make_lambda'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-4.2.8/lib/active_support/callbacks.rb:312:in `call'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-4.2.8/lib/active_support/callbacks.rb:312:in `block in halting'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-4.2.8/lib/active_support/callbacks.rb:497:in `call'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-4.2.8/lib/active_support/callbacks.rb:497:in `block in around'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-4.2.8/lib/active_support/callbacks.rb:505:in `call'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-4.2.8/lib/active_support/callbacks.rb:505:in `call'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-4.2.8/lib/active_support/callbacks.rb:498:in `block (2 levels) in around'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-4.2.8/lib/active_support/callbacks.rb:313:in `call'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-4.2.8/lib/active_support/callbacks.rb:313:in `block (2 levels) in halting'
| /usr/share/foreman/app/controllers/concerns/foreman/controller/topbar_sweeper.rb:12:in `set_topbar_sweeper_controller'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-4.2.8/lib/active_support/callbacks.rb:432:in `block in make_lambda'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-4.2.8/lib/active_support/callbacks.rb:312:in `call'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-4.2.8/lib/active_support/callbacks.rb:312:in `block in halting'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-4.2.8/lib/active_support/callbacks.rb:497:in `call'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-4.2.8/lib/active_support/callbacks.rb:497:in `block in around'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-4.2.8/lib/active_support/callbacks.rb:505:in `call'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-4.2.8/lib/active_support/callbacks.rb:505:in `call'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-4.2.8/lib/active_support/callbacks.rb:498:in `block (2 levels) in around'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-4.2.8/lib/active_support/callbacks.rb:313:in `call'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-4.2.8/lib/active_support/callbacks.rb:313:in `block (2 levels) in halting'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/audited-4.4.1/lib/audited/sweeper.rb:14:in `around'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-4.2.8/lib/active_support/callbacks.rb:455:in `public_send'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-4.2.8/lib/active_support/callbacks.rb:455:in `block in make_lambda'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-4.2.8/lib/active_support/callbacks.rb:312:in `call'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-4.2.8/lib/active_support/callbacks.rb:312:in `block in halting'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-4.2.8/lib/active_support/callbacks.rb:497:in `call'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-4.2.8/lib/active_support/callbacks.rb:497:in `block in around'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-4.2.8/lib/active_support/callbacks.rb:505:in `call'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-4.2.8/lib/active_support/callbacks.rb:505:in `call'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-4.2.8/lib/active_support/callbacks.rb:92:in `__run_callbacks__'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-4.2.8/lib/active_support/callbacks.rb:778:in `_run_process_action_callbacks'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-4.2.8/lib/active_support/callbacks.rb:81:in `run_callbacks'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/actionpack-4.2.8/lib/abstract_controller/callbacks.rb:19:in `process_action'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/actionpack-4.2.8/lib/action_controller/metal/rescue.rb:29:in `process_action'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/actionpack-4.2.8/lib/action_controller/metal/instrumentation.rb:32:in `block in process_action'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-4.2.8/lib/active_support/notifications.rb:164:in `block in instrument'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-4.2.8/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-4.2.8/lib/active_support/notifications.rb:164:in `instrument'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/actionpack-4.2.8/lib/action_controller/metal/instrumentation.rb:30:in `process_action'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/actionpack-4.2.8/lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/activerecord-4.2.8/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/actionpack-4.2.8/lib/abstract_controller/base.rb:137:in `process'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/actionview-4.2.8/lib/action_view/rendering.rb:30:in `process'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/actionpack-4.2.8/lib/action_controller/metal.rb:196:in `dispatch'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/actionpack-4.2.8/lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/actionpack-4.2.8/lib/action_controller/metal.rb:237:in `block in action'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/actionpack-4.2.8/lib/action_dispatch/routing/route_set.rb:74:in `call'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/actionpack-4.2.8/lib/action_dispatch/routing/route_set.rb:74:in `dispatch'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/actionpack-4.2.8/lib/action_dispatch/routing/route_set.rb:43:in `serve'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/actionpack-4.2.8/lib/action_dispatch/journey/router.rb:43:in `block in serve'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/actionpack-4.2.8/lib/action_dispatch/journey/router.rb:30:in `each'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/actionpack-4.2.8/lib/action_dispatch/journey/router.rb:30:in `serve'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/actionpack-4.2.8/lib/action_dispatch/routing/route_set.rb:817:in `call'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/apipie-rails-0.4.0/lib/apipie/static_dispatcher.rb:65:in `call'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/apipie-rails-0.4.0/lib/apipie/extractor/recorder.rb:132:in `call'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/apipie-rails-0.4.0/lib/apipie/middleware/checksum_in_headers.rb:27:in `call'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/rack-1.6.6/lib/rack/etag.rb:24:in `call'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/rack-1.6.6/lib/rack/conditionalget.rb:25:in `call'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/rack-1.6.6/lib/rack/head.rb:13:in `call'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/actionpack-4.2.8/lib/action_dispatch/middleware/params_parser.rb:27:in `call'
| /usr/share/foreman/lib/middleware/catch_json_parse_errors.rb:8:in `call'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/actionpack-4.2.8/lib/action_dispatch/middleware/flash.rb:260:in `call'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/rack-1.6.6/lib/rack/session/abstract/id.rb:225:in `context'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/rack-1.6.6/lib/rack/session/abstract/id.rb:220:in `call'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/actionpack-4.2.8/lib/action_dispatch/middleware/cookies.rb:560:in `call'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/activerecord-4.2.8/lib/active_record/query_cache.rb:36:in `call'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:653:in `call'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/actionpack-4.2.8/lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-4.2.8/lib/active_support/callbacks.rb:88:in `__run_callbacks__'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-4.2.8/lib/active_support/callbacks.rb:778:in `_run_call_callbacks'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-4.2.8/lib/active_support/callbacks.rb:81:in `run_callbacks'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/actionpack-4.2.8/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/actionpack-4.2.8/lib/action_dispatch/middleware/remote_ip.rb:78:in `call'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/actionpack-4.2.8/lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/actionpack-4.2.8/lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/railties-4.2.8/lib/rails/rack/logger.rb:38:in `call_app'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/railties-4.2.8/lib/rails/rack/logger.rb:22:in `call'
| /usr/share/foreman/lib/middleware/tagged_logging.rb:18:in `call'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/actionpack-4.2.8/lib/action_dispatch/middleware/request_id.rb:21:in `call'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/rack-1.6.6/lib/rack/methodoverride.rb:22:in `call'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/rack-1.6.6/lib/rack/runtime.rb:18:in `call'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-4.2.8/lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/actionpack-4.2.8/lib/action_dispatch/middleware/static.rb:120:in `call'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/rack-1.6.6/lib/rack/sendfile.rb:113:in `call'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/secure_headers-3.6.4/lib/secure_headers/middleware.rb:12:in `call'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/railties-4.2.8/lib/rails/engine.rb:518:in `call'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/railties-4.2.8/lib/rails/application.rb:165:in `call'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/railties-4.2.8/lib/rails/railtie.rb:194:in `public_send'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/railties-4.2.8/lib/rails/railtie.rb:194:in `method_missing'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/rack-1.6.6/lib/rack/urlmap.rb:66:in `block in call'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/rack-1.6.6/lib/rack/urlmap.rb:50:in `each'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/rack-1.6.6/lib/rack/urlmap.rb:50:in `call'
| /usr/lib/ruby/vendor_ruby/phusion_passenger/rack/thread_handler_extension.rb:74:in `process_request'
| /usr/lib/ruby/vendor_ruby/phusion_passenger/request_handler/thread_handler.rb:141:in `accept_and_process_next_request'
| /usr/lib/ruby/vendor_ruby/phusion_passenger/request_handler/thread_handler.rb:109:in `main_loop'
| /usr/lib/ruby/vendor_ruby/phusion_passenger/request_handler.rb:455:in `block (3 levels) in start_threads'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/logging-2.2.2/lib/logging/diagnostic_context.rb:474:in `call'
| /usr/share/foreman/vendor/ruby/2.1.0/gems/logging-2.2.2/lib/logging/diagnostic_context.rb:474:in `block in create_with_logging_context'
2017-06-12T11:32:43 90351f67 [app] [I] Rendered text template (0.0ms)
2017-06-12T11:32:43 90351f67 [app] [I] Completed 412 Precondition Failed in 99ms (Views: 0.5ms | ActiveRecord: 11.3ms)
Updated by Marek Hulán over 7 years ago
- Category changed from Templates to Parameters
I think this better fits in smart variables (smart class parameters)
Updated by Frederik Weber almost 7 years ago
- Translation missing: en.field_release set to 311
Updated by Marek Hulán almost 7 years ago
- Translation missing: en.field_release deleted (
311)
1.15.6 is out, releases in redmine don't seem to be updated
Updated by Frederik Weber over 6 years ago
- Difficulty set to easy
Okay the bug was introduced with the fix #8052.
The problem is not that the value is interpreted wrong when it is read but already when written to the database.
I'm not exactly aware why we don't cast the value to the right type if it contains an ERB. We could just check if the key has merged == true and then still cast the value.
In a short test everything worked but I need to investigate this issue a little bit deeper especially because I don't understand why the casting is omitted in such a case (what's the reason behind that?).
Updated by The Foreman Bot over 6 years ago
- Status changed from New to Ready For Testing
- Pull request https://github.com/theforeman/foreman/pull/5371 added
Updated by Tomer Brisker about 6 years ago
- Translation missing: en.field_release set to 360
- Triaged set to No
Updated by Tanitpong Apaisuwan about 6 years ago
this bug still present with foreman1.18/katello3.8RC
Updated by Tomer Brisker about 6 years ago
- Target version changed from 1.17.2 to 1.18.2
1.17.3 has been released, pushing out to 1.18.2.
Updated by Tomer Brisker about 6 years ago
- Target version changed from 1.18.2 to 1.19.1
Updated by Tomer Brisker almost 6 years ago
- Target version changed from 1.19.1 to 961
1.19.1 release is in progress and this was not fixed in time, pushing out to 1.19.2.