theforeman / foreman_expire_hosts

Foreman plugin for limiting host lifetime
GNU General Public License v3.0
5 stars 12 forks source link

500 Internal Server Error - to_d' error (NoMethodError): undefined method `to_date' for nil:NilClass #80

Open markversfeld opened 4 months ago

markversfeld commented 4 months ago

Foreman throws the following error: "to_d' error (NoMethodError): undefined method `to_date' for nil:NilClass" at least when:

Also "host status" in overview page shows: NA/NA/NA/NA when no expiration date is set. Once the expiration date is set, the statuses will display as expected.

Installation and configuration:

Foreman Version:  3.10.0
Plugins:           
 1) Name:    foreman-tasks
    Version: 9.1.1
 2) Name:    foreman_ansible
    Version: 14.0.0
 3) Name:    foreman_bootdisk
    Version: 21.2.2
 4) Name:    foreman_expire_hosts
    Version: 8.2.0
 5) Name:    foreman_leapp
    Version: 1.2.0
 6) Name:    foreman_puppet
    Version: 6.2.0
 7) Name:    foreman_remote_execution
    Version: 13.0.0
 8) Name:    foreman_snapshot_management
    Version: 3.0.0
 9) Name:    foreman_templates
    Version: 9.4.0
 10)Name:    foreman_virt_who_configure
    Version: 0.5.20
 11)Name:    foreman_webhooks
    Version: 3.2.2
 12)Name:    katello
    Version: 4.12.1

Production log:

2024-06-26T08:49:29 [W|app|bc6ec82d] undefined method `to_date' for nil:NilClass
 bc6ec82d | Did you mean?  to_d
2024-06-26T08:49:29 [I|app|bc6ec82d] Backtrace for 'undefined method `to_date' for nil:NilClass
 bc6ec82d | Did you mean?  to_d' error (NoMethodError): undefined method `to_date' for nil:NilClass
 bc6ec82d | Did you mean?  to_d
 bc6ec82d | /usr/share/gems/gems/foreman_expire_hosts-8.2.0/app/models/host_status/expiration_status.rb:44:in `to_label'
 bc6ec82d | /usr/share/foreman/app/controllers/hosts_controller.rb:676:in `block in statuses'
 bc6ec82d | /usr/share/gems/gems/activerecord-6.1.7.8/lib/active_record/relation/delegation.rb:88:in `each'
 bc6ec82d | /usr/share/gems/gems/activerecord-6.1.7.8/lib/active_record/relation/delegation.rb:88:in `each'
 bc6ec82d | /usr/share/foreman/app/controllers/hosts_controller.rb:672:in `map'
 bc6ec82d | /usr/share/foreman/app/controllers/hosts_controller.rb:672:in `statuses'
 bc6ec82d | /usr/share/gems/gems/actionpack-6.1.7.8/lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
 bc6ec82d | /usr/share/gems/gems/actionpack-6.1.7.8/lib/abstract_controller/base.rb:228:in `process_action'
 bc6ec82d | /usr/share/gems/gems/actionpack-6.1.7.8/lib/action_controller/metal/rendering.rb:30:in `process_action'
 bc6ec82d | /usr/share/gems/gems/actionpack-6.1.7.8/lib/abstract_controller/callbacks.rb:42:in `block in process_action'
 bc6ec82d | /usr/share/gems/gems/activesupport-6.1.7.8/lib/active_support/callbacks.rb:117:in `block in run_callbacks'
 bc6ec82d | /usr/share/foreman/app/controllers/concerns/foreman/controller/timezone.rb:10:in `set_timezone'
 bc6ec82d | /usr/share/gems/gems/activesupport-6.1.7.8/lib/active_support/callbacks.rb:126:in `block in run_callbacks'
 bc6ec82d | /usr/share/foreman/app/models/concerns/foreman/thread_session.rb:32:in `clear_thread'
 bc6ec82d | /usr/share/gems/gems/activesupport-6.1.7.8/lib/active_support/callbacks.rb:126:in `block in run_callbacks'
 bc6ec82d | /usr/share/foreman/app/controllers/concerns/foreman/controller/topbar_sweeper.rb:12:in `set_topbar_sweeper_controller'
 bc6ec82d | /usr/share/gems/gems/activesupport-6.1.7.8/lib/active_support/callbacks.rb:126:in `block in run_callbacks'
 bc6ec82d | /usr/share/gems/gems/audited-5.4.3/lib/audited/sweeper.rb:16:in `around'
 bc6ec82d | /usr/share/gems/gems/activesupport-6.1.7.8/lib/active_support/callbacks.rb:126:in `block in run_callbacks'
 bc6ec82d | /usr/share/gems/gems/audited-5.4.3/lib/audited/sweeper.rb:16:in `around'
 bc6ec82d | /usr/share/gems/gems/activesupport-6.1.7.8/lib/active_support/callbacks.rb:126:in `block in run_callbacks'
 bc6ec82d | /usr/share/gems/gems/activesupport-6.1.7.8/lib/active_support/callbacks.rb:137:in `run_callbacks'
 bc6ec82d | /usr/share/gems/gems/actionpack-6.1.7.8/lib/abstract_controller/callbacks.rb:41:in `process_action'
 bc6ec82d | /usr/share/gems/gems/actionpack-6.1.7.8/lib/action_controller/metal/rescue.rb:22:in `process_action'
 bc6ec82d | /usr/share/gems/gems/actionpack-6.1.7.8/lib/action_controller/metal/instrumentation.rb:34:in `block in process_action'
 bc6ec82d | /usr/share/gems/gems/activesupport-6.1.7.8/lib/active_support/notifications.rb:203:in `block in instrument'
 bc6ec82d | /usr/share/gems/gems/activesupport-6.1.7.8/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
 bc6ec82d | /usr/share/gems/gems/activesupport-6.1.7.8/lib/active_support/notifications.rb:203:in `instrument'
 bc6ec82d | /usr/share/gems/gems/actionpack-6.1.7.8/lib/action_controller/metal/instrumentation.rb:33:in `process_action'
 bc6ec82d | /usr/share/gems/gems/actionpack-6.1.7.8/lib/action_controller/metal/params_wrapper.rb:249:in `process_action'
 bc6ec82d | /usr/share/gems/gems/activerecord-6.1.7.8/lib/active_record/railties/controller_runtime.rb:27:in `process_action'
 bc6ec82d | /usr/share/gems/gems/actionpack-6.1.7.8/lib/abstract_controller/base.rb:165:in `process'
 bc6ec82d | /usr/share/gems/gems/actionview-6.1.7.8/lib/action_view/rendering.rb:39:in `process'
 bc6ec82d | /usr/share/gems/gems/actionpack-6.1.7.8/lib/action_controller/metal.rb:190:in `dispatch'
 bc6ec82d | /usr/share/gems/gems/actionpack-6.1.7.8/lib/action_controller/metal.rb:254:in `dispatch'
 bc6ec82d | /usr/share/gems/gems/actionpack-6.1.7.8/lib/action_dispatch/routing/route_set.rb:50:in `dispatch'
 bc6ec82d | /usr/share/gems/gems/actionpack-6.1.7.8/lib/action_dispatch/routing/route_set.rb:33:in `serve'
 bc6ec82d | /usr/share/gems/gems/actionpack-6.1.7.8/lib/action_dispatch/journey/router.rb:50:in `block in serve'
 bc6ec82d | /usr/share/gems/gems/actionpack-6.1.7.8/lib/action_dispatch/journey/router.rb:32:in `each'
 bc6ec82d | /usr/share/gems/gems/actionpack-6.1.7.8/lib/action_dispatch/journey/router.rb:32:in `serve'
 bc6ec82d | /usr/share/gems/gems/actionpack-6.1.7.8/lib/action_dispatch/routing/route_set.rb:842:in `call'
 bc6ec82d | /usr/share/gems/gems/katello-4.12.1/lib/katello/middleware/organization_created_enforcer.rb:18:in `call'
 bc6ec82d | /usr/share/gems/gems/katello-4.12.1/lib/katello/middleware/event_daemon.rb:10:in `call'
 bc6ec82d | /usr/share/gems/gems/actionpack-6.1.7.8/lib/action_dispatch/middleware/static.rb:24:in `call'
 bc6ec82d | /usr/share/gems/gems/actionpack-6.1.7.8/lib/action_dispatch/middleware/static.rb:24:in `call'
 bc6ec82d | /usr/share/gems/gems/apipie-dsl-2.6.2/lib/apipie_dsl/static_dispatcher.rb:67:in `call'
 bc6ec82d | /usr/share/gems/gems/apipie-rails-1.3.0/lib/apipie/static_dispatcher.rb:74:in `call'
 bc6ec82d | /usr/share/gems/gems/actionpack-6.1.7.8/lib/action_dispatch/middleware/static.rb:24:in `call'
 bc6ec82d | /usr/share/gems/gems/actionpack-6.1.7.8/lib/action_dispatch/middleware/static.rb:24:in `call'
 bc6ec82d | /usr/share/gems/gems/actionpack-6.1.7.8/lib/action_dispatch/middleware/static.rb:24:in `call'
 bc6ec82d | /usr/share/gems/gems/actionpack-6.1.7.8/lib/action_dispatch/middleware/static.rb:24:in `call'
 bc6ec82d | /usr/share/gems/gems/actionpack-6.1.7.8/lib/action_dispatch/middleware/static.rb:24:in `call'
 bc6ec82d | /usr/share/gems/gems/actionpack-6.1.7.8/lib/action_dispatch/middleware/static.rb:24:in `call'
 bc6ec82d | /usr/share/gems/gems/actionpack-6.1.7.8/lib/action_dispatch/middleware/static.rb:24:in `call'
 bc6ec82d | /usr/share/gems/gems/actionpack-6.1.7.8/lib/action_dispatch/middleware/static.rb:24:in `call'
 bc6ec82d | /usr/share/gems/gems/actionpack-6.1.7.8/lib/action_dispatch/middleware/static.rb:24:in `call'
 bc6ec82d | /usr/share/gems/gems/actionpack-6.1.7.8/lib/action_dispatch/middleware/static.rb:24:in `call'
 bc6ec82d | /usr/share/gems/gems/actionpack-6.1.7.8/lib/action_dispatch/middleware/static.rb:24:in `call'
 bc6ec82d | /usr/share/foreman/lib/foreman/middleware/libvirt_connection_cleaner.rb:9:in `call'
 bc6ec82d | /usr/share/foreman/lib/foreman/middleware/telemetry.rb:10:in `call'
 bc6ec82d | /usr/share/gems/gems/apipie-rails-1.3.0/lib/apipie/middleware/checksum_in_headers.rb:27:in `call'
 bc6ec82d | /usr/share/gems/gems/rack-2.2.8/lib/rack/tempfile_reaper.rb:15:in `call'
 bc6ec82d | /usr/share/gems/gems/rack-2.2.8/lib/rack/etag.rb:27:in `call'
 bc6ec82d | /usr/share/gems/gems/rack-2.2.8/lib/rack/conditional_get.rb:27:in `call'
 bc6ec82d | /usr/share/gems/gems/rack-2.2.8/lib/rack/head.rb:12:in `call'
 bc6ec82d | /usr/share/gems/gems/actionpack-6.1.7.8/lib/action_dispatch/http/permissions_policy.rb:22:in `call'
 bc6ec82d | /usr/share/gems/gems/actionpack-6.1.7.8/lib/action_dispatch/http/content_security_policy.rb:19:in `call'
 bc6ec82d | /usr/share/foreman/lib/foreman/middleware/logging_context_session.rb:22:in `call'
 bc6ec82d | /usr/share/gems/gems/rack-2.2.8/lib/rack/session/abstract/id.rb:266:in `context'
 bc6ec82d | /usr/share/gems/gems/rack-2.2.8/lib/rack/session/abstract/id.rb:260:in `call'
 bc6ec82d | /usr/share/gems/gems/actionpack-6.1.7.8/lib/action_dispatch/middleware/cookies.rb:697:in `call'
 bc6ec82d | /usr/share/gems/gems/actionpack-6.1.7.8/lib/action_dispatch/middleware/callbacks.rb:27:in `block in call'
 bc6ec82d | /usr/share/gems/gems/activesupport-6.1.7.8/lib/active_support/callbacks.rb:98:in `run_callbacks'
 bc6ec82d | /usr/share/gems/gems/actionpack-6.1.7.8/lib/action_dispatch/middleware/callbacks.rb:26:in `call'
 bc6ec82d | /usr/share/gems/gems/actionpack-6.1.7.8/lib/action_dispatch/middleware/actionable_exceptions.rb:18:in `call'
 bc6ec82d | /usr/share/gems/gems/actionpack-6.1.7.8/lib/action_dispatch/middleware/debug_exceptions.rb:29:in `call'
 bc6ec82d | /usr/share/gems/gems/actionpack-6.1.7.8/lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
 bc6ec82d | /usr/share/gems/gems/railties-6.1.7.8/lib/rails/rack/logger.rb:37:in `call_app'
 bc6ec82d | /usr/share/gems/gems/railties-6.1.7.8/lib/rails/rack/logger.rb:28:in `call'
 bc6ec82d | /usr/share/gems/gems/sprockets-rails-3.4.2/lib/sprockets/rails/quiet_assets.rb:13:in `call'
 bc6ec82d | /usr/share/foreman/lib/foreman/middleware/logging_context_request.rb:11:in `call'
 bc6ec82d | /usr/share/gems/gems/actionpack-6.1.7.8/lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
 bc6ec82d | /usr/share/gems/gems/request_store-1.6.0/lib/request_store/middleware.rb:19:in `call'
 bc6ec82d | /usr/share/gems/gems/actionpack-6.1.7.8/lib/action_dispatch/middleware/request_id.rb:26:in `call'
 bc6ec82d | /usr/share/gems/gems/katello-4.12.1/lib/katello/prevent_json_parsing.rb:12:in `call'
 bc6ec82d | /usr/share/gems/gems/rack-2.2.8/lib/rack/method_override.rb:24:in `call'
 bc6ec82d | /usr/share/gems/gems/rack-2.2.8/lib/rack/runtime.rb:22:in `call'
 bc6ec82d | /usr/share/gems/gems/activesupport-6.1.7.8/lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
 bc6ec82d | /usr/share/gems/gems/actionpack-6.1.7.8/lib/action_dispatch/middleware/executor.rb:14:in `call'
 bc6ec82d | /usr/share/gems/gems/rack-2.2.8/lib/rack/sendfile.rb:110:in `call'
 bc6ec82d | /usr/share/gems/gems/actionpack-6.1.7.8/lib/action_dispatch/middleware/ssl.rb:77:in `call'
 bc6ec82d | /usr/share/gems/gems/actionpack-6.1.7.8/lib/action_dispatch/middleware/host_authorization.rb:142:in `call'
 bc6ec82d | /usr/share/gems/gems/secure_headers-6.5.0/lib/secure_headers/middleware.rb:11:in `call'
 bc6ec82d | /usr/share/gems/gems/railties-6.1.7.8/lib/rails/engine.rb:539:in `call'
 bc6ec82d | /usr/share/gems/gems/railties-6.1.7.8/lib/rails/railtie.rb:207:in `public_send'
 bc6ec82d | /usr/share/gems/gems/railties-6.1.7.8/lib/rails/railtie.rb:207:in `method_missing'
 bc6ec82d | /usr/share/gems/gems/rack-2.2.8/lib/rack/urlmap.rb:74:in `block in call'
 bc6ec82d | /usr/share/gems/gems/rack-2.2.8/lib/rack/urlmap.rb:58:in `each'
 bc6ec82d | /usr/share/gems/gems/rack-2.2.8/lib/rack/urlmap.rb:58:in `call'
 bc6ec82d | /usr/share/gems/gems/puma-6.4.2/lib/puma/configuration.rb:272:in `call'
 bc6ec82d | /usr/share/gems/gems/puma-6.4.2/lib/puma/request.rb:100:in `block in handle_request'
 bc6ec82d | /usr/share/gems/gems/puma-6.4.2/lib/puma/thread_pool.rb:378:in `with_force_shutdown'
 bc6ec82d | /usr/share/gems/gems/puma-6.4.2/lib/puma/request.rb:99:in `handle_request'
 bc6ec82d | /usr/share/gems/gems/puma-6.4.2/lib/puma/server.rb:464:in `process_client'
 bc6ec82d | /usr/share/gems/gems/puma-6.4.2/lib/puma/server.rb:245:in `block in run'
 bc6ec82d | /usr/share/gems/gems/puma-6.4.2/lib/puma/thread_pool.rb:155:in `block in spawn_thread'
 bc6ec82d | /usr/share/gems/gems/logging-2.3.1/lib/logging/diagnostic_context.rb:474:in `block in create_with_logging_context'
2024-06-26T08:49:29 [I|app|bc6ec82d]   Rendered common/500.html.erb (Duration: 1.9ms | Allocations: 825)
2024-06-26T08:49:29 [I|app|bc6ec82d] Completed 500 Internal Server Error in 20ms (Views: 2.5ms | ActiveRecord: 3.2ms | Allocations: 4569)

No more rendering errors after removing expire_hosts plugin