Project

General

Profile

Bug #20098

Cannot resolve user_data template with all kind of compute-resource

Added by Michael Simpkin about 2 years ago. Updated about 1 year ago.

Status:
Closed
Priority:
Normal
Category:
Compute resources
Target version:
Team Backlog:
Fixed in Releases:
Found in Releases:

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 #18557: Image based provisioning brokenResolved2017-02-18
Has duplicate Foreman - Bug #20941: Resolve Templates button broken for image-based provisioningDuplicate2017-09-15
Has duplicate Foreman - Bug #20374: Image templates don't resolve any more during host creationDuplicate2017-07-21

Associated revisions

Revision b3fb472c (diff)
Added by Daniel Lobato Garcia almost 2 years 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

Revision 40c61742 (diff)
Added by Daniel Lobato Garcia almost 2 years 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

Revision e1017cf5 (diff)
Added by Daniel Lobato Garcia almost 2 years 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

Revision 2185c7cf (diff)
Added by Daniel Lobato Garcia almost 2 years ago

Refs #20098 - Remove save expectation for templates_used

In develop, the original #20098 change worked well because #20708 was
merged before. However in 1.15-stable, there are two tests that call
.save on an ActiveRecord model (Audited). This makes tests fail:

HostsControllerTest::#template_used.test_submit_multiple_rebuild_config_optimistic
HostsControllerTest::#template_used.test_submit_multiple_rebuild_config_pessimistic

History

#1 Updated by Emerik NICOLE about 2 years 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 about 2 years 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 about 2 years ago

bug confirmed with compute-resource-vmware

#4 Updated by Michael Moll about 2 years ago

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

#5 Updated by Daniel Lobato Garcia almost 2 years ago

  • Bugzilla link set to 1468574

#6 Updated by Daniel Lobato Garcia almost 2 years ago

  • Legacy Backlogs Release (now unused) set to 287

#7 Updated by Michael Moll almost 2 years ago

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

#8 Updated by The Foreman Bot almost 2 years ago

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

#9 Updated by Ivan Necas almost 2 years ago

  • Status changed from Ready For Testing to Closed

#10 Updated by The Foreman Bot almost 2 years ago

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

#11 Updated by Greg Sutcliffe almost 2 years ago

  • Has duplicate Bug #20941: Resolve Templates button broken for image-based provisioning added

#12 Updated by Daniel Lobato Garcia over 1 year ago

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

#13 Updated by Daniel Lobato Garcia over 1 year ago

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

Also available in: Atom PDF