Fail to cancel pending build for AIX - power box one foreman 2.3.1


We are failing to cancel builds for AIX hosts (power Architecture).
According to the error, the failure comes from and issue rendering the PXE template and using nim_attributes:

Failed to cancel pending build for [HOSTNAME] with the following errors: Unable to render ‘PXELinux default local boot’ template: undefined method nim_attributes' for #<Foreman::Renderer::Scope::Provisioning:0x00007f13266f20d0> Did you mean? aif_attributes waik_attributes, Unable to render 'PXEGrub2 default local boot' template: undefined method nim_attributes’ for #Foreman::Renderer::Scope::Provisioning:0x00007f13257ec630 Did you mean? aif_attributes waik_attributes, Unable to render ‘PXEGrub default local boot’ template: undefined method nim_attributes' for #<Foreman::Renderer::Scope::Provisioning:0x00007f1325d1a378> Did you mean? aif_attributes waik_attributes, Unable to render 'iPXE default local boot' template: undefined method nim_attributes’ for #Foreman::Renderer::Scope::Provisioning:0x00007f1326250248 Did you mean? aif_attributes waik_attributes

we tried to create a dummy provision template for this hostgroup, but we realized that we are missing something, even when the template is empty, when we switch to preview and switch to and AIX host, we get the same rendering error with not being able to find nim_attributes.
Rendering through linux box works well (we get preview of empty pxe template)

There was an error rendering the aix_MSE_PXElinux template: undefined method `nim_attributes’ for #Foreman::Renderer::Scope::Provisioning:0x00007f130bc17828 Did you mean? aif_attributes waik_attributes

Added photos of both previews (for aix box and linux box) and the code for the template.

We also tried to to hit the URL with available token and use to api to set build=false, both are not providing any error but host is still pending installation

Expected outcome:

We are expecting to be able to cancel pending aix hosts build

Foreman and Proxy versions:

Foreman and Proxy plugin versions:

foreman-tasks The goal of this plugin is to unify the way of showing task statuses across the Foreman instance. It defines Task model for keeping the information about the tasks and Lock for assigning the tasks to resources. The locking allows dealing with preventing multiple colliding tasks to be run on the same resource. It also optionally provides Dynflow infrastructure for using it for managing the tasks. Ivan Nečas 3.0.2
foreman_bootdisk Plugin for Foreman that creates iPXE-based boot disks to provision hosts without the need for PXE infrastructure. Dominic Cleal 17.0.2
foreman_discovery MaaS Discovery Plugin engine for Foreman Aditi Puntambekar, alongoldboim, Alon Goldboim, amirfefer, Amit Karsale, Amit Upadhye, Amos Benari, Avi Sharvit, Bryan Kearney, bshuster, Daniel Lobato, Daniel Lobato Garcia, Daniel Lobato García, Danny Smit, David Davis, Djebran Lezzoum, Dominic Cleal, Eric D. Helms, Ewoud Kohl van Wijngaarden, Frank Wall, Greg Sutcliffe, ChairmanTubeAmp, Ido Kanner, imriz, Imri Zvik, Ivan Nečas, Joseph Mitchell Magen, June Zhang, kgaikwad, Lars Berntzon, ldjebran, Leos Stejskal, Lukas Zapletal, Lukáš Zapletal, Marek Hulan, Marek Hulán, Martin Bačovský, Matt Jarvis, Michael Moll, Nick, odovzhenko, Ohad Levy, Ondrej Prazak, Ondřej Ezr, Ori Rabin, orrabin, Partha Aji, Petr Chalupa, Phirince Philip, Rahul Bajaj, Robert Antoni Buj Gelonch, Ron Lavi, Scubafloyd, Sean O'Keeffe, Sebastian Gräßl, Shimon Shtein, Shlomi Zadok, Stephen Benjamin, Swapnil Abnave, Thomas Gelf, Timo Goebel, Tomas Strych, Tom Caspy, Tomer Brisker, and Yann Cézard 16.3.4
foreman_hooks Plugin engine for Foreman that enables running custom hook scripts on Foreman events Dominic Cleal 0.3.17
foreman_host_extra_validator This plugin adds extra validations to a host. Timo Goebel 0.1.0
foreman_memcache Adds memcache support to foreman Ohad Levy 0.1.1
foreman_setup Plugin for Foreman that helps set up provisioning. Dominic Cleal 7.0.0
foreman_templates Engine to synchronise provisioning templates from GitHub Greg Sutcliffe 9.0.1

Distribution and version:

Other relevant data:

Foreman is trying to tell you there is a typo or something in your PXELinux template. I don’t see it attached, I can hardly know what is wrong. We do not ship a template named like this.

Thanks for the answer,
As we can see from my screenshot, the only thing there is in the template is:
echo “AIX”

This is why I’m trying to figure out where the nim_attributes is coming from.
You can see that from the output earlier on the issue:

‘PXELinux default local boot’ template: undefined method nim_attributes'
So we get the same error for PXELinux default local boot (which foreman uses when hostgroup does not have any templates.
That template does not include nim_attributes as well. We figure that it’s something that comes form the power architecture or the AIX operating system.

The error seems to stem from these two bits of code:

Not quite sure where that variable is intended to be defined, but it sure seems necessary.

Maybe a missing definition of nim_attributes in foreman/base.rb at 055489b7d4ad70f753c677e3065c9fc22d56f13e · theforeman/foreman · GitHub

Unfortunately I’m not sure my AIX is good enough to really say what the definition should be, maybe an empty definition is suitable just to avoid the exception.

Yup, good analysis, here is a patch to fix this: Fixes #33090 - skil AIX attributes loading by lzap · Pull Request #8684 · theforeman/foreman · GitHub

Warning: AIX provisioning seems to be untested for some time, you will likely run into more issues.

Thank you very much @stiege for the analysis and thank you @lzap for the patch and the heads up.

I rebased the patch it was not correct, should work now.