Failed to cancel pending build

Hi everyone,

we have one location where we cannot cancel pending builds. As we try to cancel the build the following error occurs.

The Problem does appear only in one location but it’s bond to the foreman server, we don’t see any connection to the proxy.

The only way to “rebuild” the servers is to delete and recreate the whole server, which is not appealing in this case.

I don’t know how to fix this issue, as the error is very generic, any suggestions?

Problem:

Failed to cancel pending build for testhost.domain with the following errors: Deploy TFTP PXELinux Config for testhost.domain task failed with the following error: undefined method 'name' for nil:NilClass.

Expected outcome:

The build should be canceled as it’s done in every other location.

Foreman and Proxy versions:
1.20.1 on every instance

Foreman and Proxy plugin versions:
TFTP Plugin 1.20.1
Templates Plugin 1.20.1

Debug Output from the Foreman Server:

https://pastebin.com/gnDPxZCP

This looks like you do not have a default PXE provisioning template for the host - perhaps the template does not have the correct organization or location set for it?
The error message itself should be fixed as a side effect of https://github.com/theforeman/foreman/commit/2bb08e803257c0dedfd8ab3491ddf9ec6731db02#diff-b5b263f9941ca04848201fd93c83baa5R73 which will be in 1.21

Thanks for the quick response, the error that there were two templates missing I had before, so I added the missing templates and then got the other error.

I checked every template which is used by the host if it’s set to the correct location and organization, found none with wrong settings.

check the template set under Settings -> Provisioning -> global default [$relevant kind for host], and check that the locations it is assigned to include the host’s location.

Oh, god thanks for this advice.

It was one of those global / default templates, which wasn’t available in the location.

But I had a few which aren’t available in any location, so I’m still wondering why it was only affected by one location. I’m guessing it was added back in the days and was then removed somehow - but before it was assigned to the host or operatingssystem before.

But thanks alot :slight_smile:

Hallo,
I have the same problem now on 2 locations with the error:

Failed to cancel pending build for hostname.lan with the following errors: Deploy TFTP PXEGrub2 config for hostname.lan task failed with the following error: undefined method `name’ for nil:NilClass

The global default templates are set to all locations and still I can not cancel pending build?
Any other suggestions?

Expected outcome:

The build should be canceled as it’s done in every other location.

Foreman and Proxy versions:
1.20.1 on every instance

Foreman and Proxy plugin versions:
TFTP Plugin 1.20.1
Templates Plugin 1.20.1

Please share the full stack trace so we can see where it’s failing due to the same reason, and also check if the host has a different pxegrub2 template assigned from the default

Thanks for your response…the pxegrub2 template is Kickstart default PXEGrub2.
Where can i find the full stack trace that you need?

in /var/log/foreman/production.log

/var/log/foreman/production.log:
https://pastebin.com/8Zt3aKaf

Hello,

your PXEGrub2 local template which you set in Administer - Settings does not exist. Select an existing template. The error message should be something like “Template XYZ could not be found” but due to overlook in the rescue section it actually errors out on nil exception. This has been fixed in 1.21 already.

NoMethodError: undefined method `name' for nil:NilClass
/usr/share/foreman/app/models/concerns/orchestration/tftp.rb:76:in `rescue in default_pxe_render'

You can do the following patch to fix the error message to be correct:

diff --git a/app/models/concerns/orchestration/tftp.rb b/app/models/concerns/orchestration/tftp.rb
index 33f65d7f8..38715f059 100644
--- a/app/models/concerns/orchestration/tftp.rb
+++ b/app/models/concerns/orchestration/tftp.rb
@@ -73,7 +73,7 @@ module Orchestration::TFTP
     raise Foreman::Exception.new(N_("Template '%s' was not found"), template.name) unless template
     host.render_template(template: template)
   rescue => e
-    failure _("Unable to render '%{name}' template: %{e}") % { :name => template.name, :e => e }, e
+    failure _("Unable to render '%{name}' template: %{e}") % { :name => host.local_boot_template_name(kind), :e => e }, e
   end
 
   # Adds the host to the forward and reverse TFTP zones

Thanks…it works.
The upgrade to Foreman 1.21 will i done when Katello 3.11 is released.