Provisioning a new host fails with error "NoMethodError: undefined method `sub' for nil:NilClass" in Red Hat Satellite 6.5

Solution Verified - Updated

Environment

  • Red Hat Satellite 6.5

Issue

  • While creating a host using VMware as a compute resource, after selecting Resources as the Resource Pool, the Folder list is coming completely blank.

  • If selecting an alternate Resource Pool, then the host creation fails with an error message as displayed below.

    2019-06-14T10:51:07 [W|app|f020e421] Failed to create a compute vimiXXXXXXX (VMware) instance client.example.com: undefined method `sub' for nil:NilClass
     
    NoMethodError: undefined method `sub' for nil:NilClass
    /opt/theforeman/tfm/root/usr/share/gems/gems/fog-vsphere-2.4.0/lib/fog/vsphere/requests/compute/get_folder.rb:34:in `get_raw_vmfolder'
    /opt/theforeman/tfm/root/usr/share/gems/gems/fog-vsphere-2.4.0/lib/fog/vsphere/requests/compute/create_vm.rb:29:in `create_vm'
    /opt/theforeman/tfm/root/usr/share/gems/gems/fog-vsphere-2.4.0/lib/fog/vsphere/models/compute/server.rb:300:in `save'
    /usr/share/foreman/app/models/compute_resources/foreman/model/vmware.rb:454:in `create_vm'
    /usr/share/foreman/app/models/concerns/orchestration/compute.rb:87:in `setCompute'
    /usr/share/foreman/app/models/concerns/orchestration.rb:222:in `execute'
    

Resolution

  • This problem is only happening when the Datacenters inside vCenter are present in a nested folder structure. It was further reported to the Red Hat Engineering team via This content is not included.Bugzilla 1717248 and has been fixed in Red Hat Satellite 6.6 and beyond.

  • If the upgrade to Satellite 6.6 or above is not possible, then as a workaround, please perform the steps below on the affected Satellite 6.5 server.

      --> Take a backup of this file as displayed below.
      
      # cp -p /opt/theforeman/tfm/root/usr/share/gems/gems/fog-vsphere-2.4.0/lib/fog/vsphere/models/compute/datacenter.rb ~/datacenter.rb_orig
    
      
      --> Verify this particular content of the file as displayed below.
    
      # grep -A1 "vm_folders" /opt/theforeman/tfm/root/usr/share/gems/gems/fog-vsphere-2.4.0/lib/fog/vsphere/models/compute/datacenter.rb
              def vm_folders(filters = {})
                service.folders({ datacenter: path.join('/'), type: :vm }.merge(filters))
      
      
      --> Edit the file above and modify the above section as below.
      
      # grep -A1 "vm_folders" /opt/theforeman/tfm/root/usr/share/gems/gems/fog-vsphere-2.4.0/lib/fog/vsphere/models/compute/datacenter.rb
              def vm_folders(filters = {})
      	  service.folders({ datacenter: name, type: :vm }.merge(filters))
      
      # katello-service restart
    
  • Attempt to build a new host using VMware as a Compute Resource and monitor the overall progress.

  • If the above workaround still doesn't fix the problem then open a support case with This content is not included.Red Hat Technical Support for further assistance.

For more KB articles/solutions related to Red Hat Satellite 6.x Provisioning Issues, please refer to the Consolidated Troubleshooting Article for Red Hat Satellite 6.x Provisioning related Issues

Diagnostic Steps

  • When the host provisioning fails, please monitor the /var/log/foreman/production.log.
2019-06-05T10:21:25 [I|app|410c69bf] Adding Compute instance for gina-meany.example.com
2019-06-05T10:21:25 [W|app|410c69bf] Failed to create a compute venter new (VMware) instance gina-meany.example.com: undefined method `sub' for nil:NilClass

NoMethodError: undefined method `sub' for nil:NilClass
/opt/theforeman/tfm/root/usr/share/gems/gems/fog-vsphere-2.4.0/lib/fog/vsphere/requests/compute/get_folder.rb:33:in `get_raw_folder'
/opt/theforeman/tfm/root/usr/share/gems/gems/fog-vsphere-2.4.0/lib/fog/vsphere/requests/compute/get_folder.rb:49:in `get_raw_vmfolder'
/opt/theforeman/tfm/root/usr/share/gems/gems/fog-vsphere-2.4.0/lib/fog/vsphere/requests/compute/create_vm.rb:29:in `create_vm'
/opt/theforeman/tfm/root/usr/share/gems/gems/fog-vsphere-2.4.0/lib/fog/vsphere/models/compute/server.rb:300:in `save'
/usr/share/foreman/app/models/compute_resources/foreman/model/vmware.rb:454:in `create_vm'
/usr/share/foreman/app/models/concerns/orchestration/compute.rb:87:in `setCompute'
/usr/share/foreman/app/models/concerns/orchestration.rb:222:in `execute'
/usr/share/foreman/app/models/concerns/orchestration.rb:145:in `block in process'
/usr/share/foreman/app/models/concerns/orchestration.rb:137:in `each'
/usr/share/foreman/app/models/concerns/orchestration.rb:137:in `process'
/usr/share/foreman/app/models/concerns/orchestration.rb:44:in `around_save_orchestration'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activesupport-5.2.1/lib/active_support/callbacks.rb:118:in `block in run_callbacks'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activesupport-5.2.1/lib/active_support/callbacks.rb:136:in `run_callbacks'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activesupport-5.2.1/lib/active_support/callbacks.rb:816:in `_run_save_callbacks'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/callbacks.rb:342:in `create_or_update'
......</snipped/>.....
/usr/share/foreman/lib/middleware/logging_context.rb:23:in `call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/rack-2.0.5/lib/rack/session/abstract/id.rb:232:in `context'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/rack-2.0.5/lib/rack/session/abstract/id.rb:226:in `call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/middleware/cookies.rb:670:in `call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activesupport-5.2.1/lib/active_support/callbacks.rb:98:in `run_callbacks'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/middleware/callbacks.rb:26:in `call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/middleware/debug_exceptions.rb:61:in `call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/railties-5.2.1/lib/rails/rack/logger.rb:38:in `call_app'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/railties-5.2.1/lib/rails/rack/logger.rb:28:in `call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/sprockets-rails-3.2.1/lib/sprockets/rails/quiet_assets.rb:13:in `call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/middleware/request_id.rb:27:in `call'
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.10.0.46/lib/katello/prevent_json_parsing.rb:12:in `call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/rack-2.0.5/lib/rack/method_override.rb:22:in `call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/rack-2.0.5/lib/rack/runtime.rb:22:in `call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activesupport-5.2.1/lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/middleware/executor.rb:14:in `call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/middleware/static.rb:127:in `call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/middleware/static.rb:127:in `call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/rack-2.0.5/lib/rack/sendfile.rb:111:in `call'
/opt/theforeman/tfm/root/usr/share/gems/gems/secure_headers-6.0.0/lib/secure_headers/middleware.rb:13:in `call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/railties-5.2.1/lib/rails/engine.rb:524:in `call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/railties-5.2.1/lib/rails/railtie.rb:190:in `public_send'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/railties-5.2.1/lib/rails/railtie.rb:190:in `method_missing'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/rack-2.0.5/lib/rack/urlmap.rb:68:in `block in call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/rack-2.0.5/lib/rack/urlmap.rb:53:in `each'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/rack-2.0.5/lib/rack/urlmap.rb:53:in `call'
/usr/share/gems/gems/passenger-4.0.18/lib/phusion_passenger/rack/thread_handler_extension.rb:77:in `process_request'
/usr/share/gems/gems/passenger-4.0.18/lib/phusion_passenger/request_handler/thread_handler.rb:140:in `accept_and_process_next_request'
/usr/share/gems/gems/passenger-4.0.18/lib/phusion_passenger/request_handler/thread_handler.rb:108:in `main_loop'
/usr/share/gems/gems/passenger-4.0.18/lib/phusion_passenger/request_handler.rb:441:in `block (3 levels) in start_threads'
/opt/theforeman/tfm/root/usr/share/gems/gems/logging-2.2.2/lib/logging/diagnostic_context.rb:474:in `block in create_with_logging_context'
2019-06-05T10:21:25 [W|app|410c69bf] Rolling back due to a problem: [#<Orchestration::Task:0x0000000011307e68 @name="Set up compute instance gina-meany.example.com", @id="Set up compute instance gina-meany.example.com", @status="failed", @priority=2, @action=[#<Host::Managed id: nil, name: "gina-meany.example.com", last_compile: nil, last_report: nil, updated_at: nil, created_at: nil, root_pass: "$5$rfqy2i0H$Jx8d9iHpfAnc0QRkEUio.3P79vyQ888LlkcwKt...", architecture_id: 1, operatingsystem_id: 6, environment_id: 4, ptable_id: 61, medium_id: nil, build: true, comment: "", disk: "", installed_at: nil, model_id: nil, hostgroup_id: 6, owner_id: 18, owner_type: "User", enabled: true, puppet_ca_proxy_id: 1, managed: true, use_image: nil, image_file: nil, uuid: nil, compute_resource_id: 16, puppet_proxy_id: 1, certname: nil, image_id: nil, organization_id: 1, location_id: 2, type: "Host::Managed", otp: nil, realm_id: 1, compute_profile_id: 1, provision_method: "build", grub_pass: "$5$rfqy2i0H$Jx8d9iHpfAnc0QRkEUio.3P79vyQ888LlkcwKt...", discovery_rule_id: nil, global_status: 0, lookup_value_matcher: "fqdn=gina-meany.example.com", openscap_proxy_id: 1, expired_on: nil, pxe_loader: "PXELinux BIOS", initiated_at: nil, build_errors: nil>, :setCompute], @created=1559694084.987138, @timestamp=2019-06-05 00:21:25 UTC>]
SBR
Product(s)
Components
Category

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.