Node.rb host - 500 Internal Server Error. Error is ignored and the execution continues

Hi all when I call node.rb host I get below error:

# /etc/puppetlabs/puppet/node.rb test-agent
test-agent: During the fact upload the server responded with: 500 Internal Server Error. Error is ignored and the execution continues.
{
  "error": {"message":"Internal Server Error: the server was unable to finish the request. This may be caused by unavailability of some required service, incorrect API call or a server-side bug. There may be more information in the server's logs."}
}
---
parameters:
  foreman_config_groups:
  - test-config-group
  puppetmaster: ''
  foreman_env: production
  foreman_hostname: test-agent
  foreman_fqdn: test-agent
  hostgroup: HG-hostgroup
  root_pw:
  foreman_subnets: []
  foreman_interfaces:
  - ip: 100.13.10.23
    ip6:
    mac: 00:50:56:a6:1e:de
    name: test-agent
    attrs:
      dhcp: ''
      mtu: 1500
      bindings:
      - address: 100.13.10.23
        netmask: 255.255.254.0
        network: 100.13.10.0
      bindings6:
      - address: fe80::c4a:ec63:1c8d:b68f
        netmask: 'ffff:ffff:ffff:ffff::'
        network: 'fe80::'
        scope6: link
      netmask: 255.255.254.0
      network: 10.136.160.0
      netmask6: 'ffff:ffff:ffff:ffff::'
      network6: 'fe80::'
      scope6: link
    virtual: false
    link: true
    identifier: Ethernet0
    managed: true
    primary: true
    provision: true
    subnet:
    subnet6:
    tag:
    attached_to:
    type: Interface
  domainname: 
  owner_name: 
  owner_email: 
  ssh_authorized_keys: []
  foreman_users:
    bar:
      firstname: 
      lastname: 
      mail:  
      description: ''
      fullname:  
      name:  
      ssh_authorized_keys: []
  host_packages: ''
  host_registration_insights: false
  host_registration_remote_execution: true
classes:
  create_machine:
  custom_sub:
environment: production

thanks for any suggestion

Foreman and Proxy versions: foreman 3.5.2 , foreman-proxy 3.5.2

Distribution and version: Ubuntu 20.04.4 LTS

it looks like this one: Bug #35619: Add kernel_version to reported data facet for use in new host UI OS card - Foreman

in production.log:

2023-04-04T15:50:23 [I|app|d7b60101]   Parameters: {"facts"=>"[FILTERED]", "name"=>"test-agent", "certname"=>"test-agent", "apiv"=>"v2", "host"=>{"certname"=>"test-agent", "name"=>"test-agent"}}
2023-04-04T15:50:23 [I|app|d7b60101] Import facts for 'test-agent' completed. Added: 0, Updated: 2, Deleted 0 facts
2023-04-04T15:50:23 [W|app|d7b60101] Action failed
2023-04-04T15:50:23 [I|app|d7b60101] Backtrace for 'Action failed' error (ActiveModel::UnknownAttributeError): unknown attribute 'kernel_version' for HostFacets::ReportedDataFacet.
 d7b60101 | /usr/share/foreman/vendor/ruby/2.7.0/gems/activemodel-6.1.7.2/lib/active_model/attribute_assignment.rb:51:in `_assign_attribute'
 d7b60101 | /usr/share/foreman/vendor/ruby/2.7.0/gems/activerecord-6.1.7.2/lib/active_record/attribute_assignment.rb:21:in `block in _assign_attributes'
 d7b60101 | /usr/share/foreman/vendor/ruby/2.7.0/gems/activerecord-6.1.7.2/lib/active_record/attribute_assignment.rb:13:in `each'
 d7b60101 | /usr/share/foreman/vendor/ruby/2.7.0/gems/activerecord-6.1.7.2/lib/active_record/attribute_assignment.rb:13:in `_assign_attributes'
 d7b60101 | /usr/share/foreman/vendor/ruby/2.7.0/gems/activemodel-6.1.7.2/lib/active_model/attribute_assignment.rb:34:in `assign_attributes'
 d7b60101 | /usr/share/foreman/app/models/host_facets/reported_data_facet.rb:5:in `populate_fields_from_facts'
 d7b60101 | /usr/share/foreman/app/models/concerns/facets/base_host_extensions.rb:22:in `block in populate_facet_fields'
 d7b60101 | /usr/share/foreman/app/models/concerns/facets/base_host_extensions.rb:21:in `each'
 d7b60101 | /usr/share/foreman/app/models/concerns/facets/base_host_extensions.rb:21:in `populate_facet_fields'
 d7b60101 | /usr/share/foreman/app/models/host/managed.rb:473:in `populate_fields_from_facts'
 d7b60101 | /usr/share/foreman/app/services/host_fact_importer.rb:50:in `block (2 levels) in parse_facts'
 d7b60101 | /usr/share/foreman/app/services/foreman/telemetry_helper.rb:28:in `telemetry_duration_histogram'
 d7b60101 | /usr/share/foreman/app/services/host_fact_importer.rb:49:in `block in parse_facts'
 d7b60101 | /usr/share/foreman/app/services/host_fact_importer.rb:90:in `block in skipping_orchestration'
 d7b60101 | /usr/share/foreman/app/models/concerns/orchestration.rb:124:in `without_orchestration'
 d7b60101 | /usr/share/foreman/app/services/host_fact_importer.rb:89:in `skipping_orchestration'
 d7b60101 | /usr/share/foreman/app/services/host_fact_importer.rb:45:in `parse_facts'

Did you by any chance upgrade without running database migrations? Try running foreman-rake db:migrate and then systemctl restart foreman if it performed any migrations.

1 Like

Thanks for your answer @ekohl, I’ll do that right now.

I usually use those steps upgrade foreman @ekohl

so I run first:

# foreman-rake db:migrate
# systemctl restart foreman

and I still get the error!

# /etc/puppetlabs/puppet/node.rb test-agent
test-agent: During the fact upload the server responded with: 500 Internal Server Error. Error is ignored and the execution continues.
{
  "error": {"message":"Internal Server Error: the server was unable to finish the request. This may be caused by unavailability of some required service, incorrect API call or a server-side bug. There may be more information in the server's logs."}
}
---

production.log:

2023-04-04T20:07:50 [W|app|daebcd92] Action failed
2023-04-04T20:07:50 [I|app|daebcd92] Backtrace for 'Action failed' error (ActiveModel::UnknownAttributeError): unknown attribute 'kernel_version' for HostFacets::ReportedDataFacet.
 daebcd92 | /usr/share/foreman/vendor/ruby/2.7.0/gems/activemodel-6.1.7.2/lib/active_model/attribute_assignment.rb:51:in `_assign_attribute'
 daebcd92 | /usr/share/foreman/vendor/ruby/2.7.0/gems/activerecord-6.1.7.2/lib/active_record/attribute_assignment.rb:21:in `block in _assign_attributes'
 daebcd92 | /usr/share/foreman/vendor/ruby/2.7.0/gems/activerecord-6.1.7.2/lib/active_record/attribute_assignment.rb:13:in `each'
 daebcd92 | /usr/share/foreman/vendor/ruby/2.7.0/gems/activerecord-6.1.7.2/lib/active_record/attribute_assignment.rb:13:in `_assign_attributes'
 daebcd92 | /usr/share/foreman/vendor/ruby/2.7.0/gems/activemodel-6.1.7.2/lib/active_model/attribute_assignment.rb:34:in `assign_attributes'
 daebcd92 | /usr/share/foreman/app/models/host_facets/reported_data_facet.rb:5:in `populate_fields_from_facts'
 daebcd92 | /usr/share/foreman/app/models/concerns/facets/base_host_extensions.rb:22:in `block in populate_facet_fields'
 daebcd92 | /usr/share/foreman/app/models/concerns/facets/base_host_extensions.rb:21:in `each'
 daebcd92 | /usr/share/foreman/app/models/concerns/facets/base_host_extensions.rb:21:in `populate_facet_fields'
 daebcd92 | /usr/share/foreman/app/models/host/managed.rb:473:in `populate_fields_from_facts'

you are right @ekohl , on my test-system I see all columns like below:

foreman=# select * from host_facets_reported_data_facets;
 id | host_id |      boot_time      |         created_at         |         updated_at         | virtual | sockets | cores | ram  | disks_total  |  kernel_version   |       bios_vendor        | bios_release_date | bios_version
----+---------+---------------------+----------------------------+----------------------------+---------+---------+-------+------+--------------+-------------------+--------------------------+-------------------+--------------

on my prod-system, there are many columns are not available:

foreman=# select * from host_facets_reported_data_facets;
 id  | host_id |      boot_time      |         created_at         |         updated_at         | virtual | sockets | cores |  ram  | disks_total
-----+---------+---------------------+----------------------------+----------------------------+---------+---------+-------+-------+-------------

How can I solve it ?

after upgrade to Foreman 3.6 all works good.