Bug #20098

Cannot resolve user_data template with all kind of compute-resource

Added by Michael Simpkin 3 months ago. Updated 12 days ago.

Status:Closed
Priority:Normal
Assigned To:Daniel Lobato Garcia
Category:Compute resources
Target version:-
Difficulty: Bugzilla link:1468574
Found in release: Pull request:https://github.com/theforeman/foreman/pull/4827, https://github.com/theforeman/foreman/pull/4808
Story points-
Velocity based estimate-
Release1.15.4Release relationshipAuto

Description

This seems to be a problem with 1.15.0 and 1.15.1. I did a standard install on a new machine with everything local. When I try to create a new host, it is not able to resolve the user_data template. The following message appears in the log:
2017-06-20 11:13:20 2dd4694b [app] [I] Started POST "/hosts/template_used?provisioning=image" for 10.10.0.162 at 2017-
06-20 11:13:20 -0400
2017-06-20 11:13:20 2dd4694b [app] [I] Processing by HostsController#template_used as */*
2017-06-20 11:13:20 2dd4694b [app] [I] Parameters: {"utf8"=>"✓", "authenticity_token"=>"yv2pKrr9/2HXyU5gypJHwgwYYTZp
5YlrJ28gry7wKAR23xX4ZGvGd6u19VrFuwfE8SkrAjO3IFsDc0s6l/V9qg==", "host"=>{"name"=>"kurt-benites", "hostgroup_id"=>"8", "
compute_resource_id"=>"6", "puppetclass_ids"=>[""], "managed"=>"true", "progress_report_id"=>"[FILTERED]", "type"=>"Ho
st::Managed", "interfaces_attributes"=>{"0"=>{"_destroy"=>"0", "type"=>"Nic::Managed", "mac"=>"", "identifier"=>"", "n
ame"=>"kurt-benites", "domain_id"=>"4", "subnet_id"=>"8", "ip"=>"", "ip6"=>"", "managed"=>"1", "primary"=>"1", "provis
ion"=>"1", "virtual"=>"0", "tag"=>"", "attached_to"=>""}, "new_interfaces"=>{"_destroy"=>"1", "type"=>"Nic::Managed",
"mac"=>"", "identifier"=>"", "name"=>"", "domain_id"=>"", "subnet_id"=>"", "ip"=>"", "ip6"=>"", "managed"=>"1", "prima
ry"=>"0", "provision"=>"0", "virtual"=>"0", "tag"=>"", "attached_to"=>""}}, "compute_attributes"=>{"flavor_id"=>"m1.sm
all", "availability_zone"=>"", "subnet_id"=>"", "security_group_ids"=>[""], "managed_ip"=>"public", "image_id"=>"ami-1
3755605"}, "architecture_id"=>"4", "operatingsystem_id"=>"4", "provision_method"=>"image", "build"=>"1", "medium_id"=>
"", "pxe_loader"=>"", "disk"=>"", "root_pass"=>"[FILTERED]", "is_owned_by"=>"22-Users", "enabled"=>"1", "model_id"=>""
, "comment"=>"", "overwrite"=>"false"}, "capabilities"=>"image key_pair", "provider"=>"EC2", "fakepassword"=>"[FILTERE
D]", "bare_metal_capabilities"=>"build", "provisioning"=>"image"}
2017-06-20 11:13:20 2dd4694b [app] [I] Current user: michaels (administrator)
2017-06-20 11:13:20 2dd4694b [app] [W] Action failed | NoMethodError: undefined method `[]' for nil:NilClass | /usr/share/foreman/app/models/concerns/hostext/operating_system.rb:42:in `template_kinds' | /usr/share/foreman/app/models/concerns/hostext/operating_system.rb:25:in `available_template_kinds' | /usr/share/foreman/app/controllers/hosts_controller.rb:649:in `template_used'

If I follow the exact same steps using version 1.14.x, everything works as expected. I have also upgrade another separate instance from 1.14 to 1.15, and it ends up with the same issue.


Related issues

Related to Foreman - Bug #20374: Image templates don't resolve any more during host creation New 07/21/2017
Related to Foreman - Bug #18557: Image based provisioning broken New 02/18/2017
Duplicated by Foreman - Bug #20941: Resolve Templates button broken for image-based provisioning Duplicate 09/15/2017

Associated revisions

Revision b3fb472c
Added by Daniel Lobato Garcia 13 days ago

Fixes #20098 - Resolve template_used for image provisioning

At the moment, the method Hostext::OperatingSystem#template_kinds is
unable to handle image-based provisioning. If there is an image, it will
not be able to find it as 'self.compute_attributes' does not exist for
new hosts.

Creating the host always worked well, and the templates can be found
after clicking the 'submit' button. However, when you click on
'Resolve', you get an error 'undefined method []' as compute_attributes
does not exist.

This is fixed by ensuring the controller includes compute_attributes in
the 'temporary' host created to check the templates this.

To reproduce:

- Click on Hosts > New host
- Select a Compute Resource
- Select an OS, choose 'Image based' as provisioning method
- Select an image
- Click on 'Resolve' - you will see "No templates were configured"
- After applying the patch, you should see the finish/userdata template

History

#1 Updated by Emerik NICOLE 3 months ago

  • Subject changed from Cannot resolve user_data template with compute-resource-ec2 to Cannot resolve user_data template with compute-resource-vmware
  • Category set to Compute resources

Issues present with compute-resource-vmware too. I think for all compute-resource.

#2 Updated by Emerik NICOLE 3 months ago

  • Subject changed from Cannot resolve user_data template with compute-resource-vmware to Cannot resolve user_data template with all kind of compute-resource

#3 Updated by Emerik NICOLE 3 months ago

bug confirmed with compute-resource-vmware

#4 Updated by Michael Moll about 1 month ago

  • Related to Bug #20374: Image templates don't resolve any more during host creation added

#5 Updated by Daniel Lobato Garcia 24 days ago

  • Bugzilla link set to 1468574

#6 Updated by Daniel Lobato Garcia 22 days ago

  • Release set to 1.15.4

#7 Updated by Michael Moll 21 days ago

  • Related to Bug #18557: Image based provisioning broken added

#8 Updated by The Foreman Bot 21 days ago

  • Status changed from New to Ready For Testing
  • Assigned To set to Daniel Lobato Garcia
  • Pull request https://github.com/theforeman/foreman/pull/4808 added

#9 Updated by Ivan Necas 13 days ago

  • Status changed from Ready For Testing to Closed

#10 Updated by The Foreman Bot 13 days ago

  • Pull request https://github.com/theforeman/foreman/pull/4827 added

#11 Updated by Greg Sutcliffe 11 days ago

  • Duplicated by Bug #20941: Resolve Templates button broken for image-based provisioning added

Also available in: Atom PDF