Bug #31345
Installer fails with NoMethodError: undefined method `permissions' for nil:NilClass
Difficulty:
Triaged:
No
Bugzilla link:
Pull request:
Description
Description of problem:
Satellite-installer fails at execution of '/usr/sbin/foreman-rake -- config -k 'remote_execution_cockpit_url' -v '/webcon/=%{host}''
New traceback: [ERROR 2020-10-15T11:38:35 verbose] Execution of '/usr/sbin/foreman-rake -- config -k 'remote_execution_cockpit_url' -v '/webcon/=%{host}'' returned 1: rake aborted! [ERROR 2020-10-15T11:38:35 verbose] NoMethodError: undefined method `permissions' for nil:NilClass [ERROR 2020-10-15T11:38:35 verbose] /usr/share/foreman/app/models/role.rb:161:in `block (2 levels) in add_permissions' [ERROR 2020-10-15T11:38:35 verbose] /usr/share/foreman/app/models/role.rb:160:in `each' [ERROR 2020-10-15T11:38:35 verbose] /usr/share/foreman/app/models/role.rb:160:in `block in add_permissions' [ERROR 2020-10-15T11:38:35 verbose] /usr/share/foreman/app/models/role.rb:157:in `each' [ERROR 2020-10-15T11:38:35 verbose] /usr/share/foreman/app/models/role.rb:157:in `add_permissions' [ERROR 2020-10-15T11:38:35 verbose] /usr/share/foreman/app/models/role.rb:207:in `add_permissions!' [ERROR 2020-10-15T11:38:35 verbose] /usr/share/foreman/app/services/foreman/plugin/role_lock.rb:54:in `block in update_plugin_role_permissions' [ERROR 2020-10-15T11:38:35 verbose] /usr/share/foreman/app/models/role.rb:86:in `ignore_locking' [ERROR 2020-10-15T11:38:35 verbose] /usr/share/foreman/app/services/foreman/plugin/role_lock.rb:52:in `update_plugin_role_permissions' [ERROR 2020-10-15T11:38:35 verbose] /usr/share/foreman/app/services/foreman/plugin/role_lock.rb:23:in `process_role' [ERROR 2020-10-15T11:38:35 verbose] /usr/share/foreman/app/services/foreman/plugin/role_lock.rb:12:in `block in register_role' [ERROR 2020-10-15T11:38:35 verbose] /usr/share/foreman/app/models/concerns/foreman/thread_session.rb:108:in `as' [ERROR 2020-10-15T11:38:35 verbose] /usr/share/foreman/app/models/concerns/foreman/thread_session.rb:114:in `as_anonymous_admin' [ERROR 2020-10-15T11:38:35 verbose] /usr/share/foreman/app/services/foreman/plugin/role_lock.rb:11:in `register_role' [ERROR 2020-10-15T11:38:35 verbose] /usr/share/foreman/app/registries/foreman/plugin.rb:302:in `block (2 levels) in role' [ERROR 2020-10-15T11:38:35 verbose] /opt/theforeman/tfm/root/usr/share/gems/gems/audited-4.9.0/lib/audited/auditor.rb:376:in `without_auditing' [ERROR 2020-10-15T11:38:35 verbose] /usr/share/foreman/app/registries/foreman/plugin.rb:301:in `block in role' [ERROR 2020-10-15T11:38:35 verbose] /opt/theforeman/tfm/root/usr/share/gems/gems/audited-4.9.0/lib/audited/auditor.rb:376:in `without_auditing' [ERROR 2020-10-15T11:38:35 verbose] /usr/share/foreman/app/registries/foreman/plugin.rb:300:in `role' [ERROR 2020-10-15T11:38:35 verbose] /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_discovery-16.1.2/lib/foreman_discovery/engine.rb:152:in `block (2 levels) in <class:Engine>' [ERROR 2020-10-15T11:38:35 verbose] /usr/share/foreman/app/registries/foreman/plugin.rb:78:in `instance_eval' [ERROR 2020-10-15T11:38:35 verbose] /usr/share/foreman/app/registries/foreman/plugin.rb:78:in `register' [ERROR 2020-10-15T11:38:35 verbose] /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_discovery-16.1.2/lib/foreman_discovery/engine.rb:45:in `block in <class:Engine>' Former (fixed) traceback: [ERROR 2020-09-23T13:10:59 verbose] Execution of '/usr/sbin/foreman-rake -- config -k 'remote_execution_cockpit_url' -v '/webcon/=%{host}'' returned 1: rake aborted! [ERROR 2020-09-23T13:10:59 verbose] NoMethodError: undefined method `permissions' for nil:NilClass [ERROR 2020-09-23T13:10:59 verbose] /usr/share/foreman/app/models/role.rb:161:in `block (2 levels) in add_permissions' [ERROR 2020-09-23T13:10:59 verbose] /usr/share/foreman/app/models/role.rb:160:in `each' [ERROR 2020-09-23T13:10:59 verbose] /usr/share/foreman/app/models/role.rb:160:in `block in add_permissions' [ERROR 2020-09-23T13:10:59 verbose] /usr/share/foreman/app/models/role.rb:157:in `each' [ERROR 2020-09-23T13:10:59 verbose] /usr/share/foreman/app/models/role.rb:157:in `add_permissions' [ERROR 2020-09-23T13:10:59 verbose] /usr/share/foreman/app/models/role.rb:207:in `add_permissions!' [ERROR 2020-09-23T13:10:59 verbose] /usr/share/foreman/app/services/foreman/plugin/role_lock.rb:54:in `block in update_plugin_role_permissions' [ERROR 2020-09-23T13:10:59 verbose] /usr/share/foreman/app/models/role.rb:86:in `ignore_locking' [ERROR 2020-09-23T13:10:59 verbose] /usr/share/foreman/app/services/foreman/plugin/role_lock.rb:52:in `update_plugin_role_permissions' [ERROR 2020-09-23T13:10:59 verbose] /usr/share/foreman/app/services/foreman/plugin/role_lock.rb:23:in `process_role' [ERROR 2020-09-23T13:10:59 verbose] /usr/share/foreman/app/services/foreman/plugin/role_lock.rb:12:in `block in register_role' [ERROR 2020-09-23T13:10:59 verbose] /usr/share/foreman/app/models/concerns/foreman/thread_session.rb:108:in `as' [ERROR 2020-09-23T13:10:59 verbose] /usr/share/foreman/app/models/concerns/foreman/thread_session.rb:114:in `as_anonymous_admin' [ERROR 2020-09-23T13:10:59 verbose] /usr/share/foreman/app/services/foreman/plugin/role_lock.rb:11:in `register_role' [ERROR 2020-09-23T13:10:59 verbose] /usr/share/foreman/app/registries/foreman/plugin.rb:302:in `block (2 levels) in role' [ERROR 2020-09-23T13:10:59 verbose] /opt/theforeman/tfm/root/usr/share/gems/gems/audited-4.9.0/lib/audited/auditor.rb:376:in `without_auditing' [ERROR 2020-09-23T13:10:59 verbose] /usr/share/foreman/app/registries/foreman/plugin.rb:301:in `block in role' [ERROR 2020-09-23T13:10:59 verbose] /opt/theforeman/tfm/root/usr/share/gems/gems/audited-4.9.0/lib/audited/auditor.rb:376:in `without_auditing' [ERROR 2020-09-23T13:10:59 verbose] /usr/share/foreman/app/registries/foreman/plugin.rb:300:in `role' [ERROR 2020-09-23T13:10:59 verbose] /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_openscap-4.0.3/lib/foreman_openscap/engine.rb:127:in `block (2 levels) in <class:Engine>' [ERROR 2020-09-23T13:10:59 verbose] /usr/share/foreman/app/registries/foreman/plugin.rb:78:in `instance_eval' [ERROR 2020-09-23T13:10:59 verbose] /usr/share/foreman/app/registries/foreman/plugin.rb:78:in `register' [ERROR 2020-09-23T13:10:59 verbose] /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_openscap-4.0.3/lib/foreman_openscap/engine.rb:49:in `block in <class:Engine>'
Related issues
Associated revisions
History
#1
Updated by The Foreman Bot over 2 years ago
- Status changed from New to Ready For Testing
- Pull request https://github.com/theforeman/foreman/pull/8142 added
#2
Updated by Tomer Brisker over 2 years ago
- Target version set to 2.3.0
- Assignee changed from Ondřej Ezr to Eric Helms
- Subject changed from Installer fails with NoMethodError: undefined method `permissions' for nil:NilClass to Installer fails with NoMethodError: undefined method `permissions' for nil:NilClass
#3
Updated by The Foreman Bot over 2 years ago
- Fixed in Releases 2.4.0 added
#4
Updated by Tomer Brisker over 2 years ago
- Fixed in Releases 2.3.0 added
- Fixed in Releases deleted (
2.4.0)
#5
Updated by Tomer Brisker over 2 years ago
- Related to Refactor #31391: Refactor role model to simplify adding permissions from plugins added
#6
Updated by Eric Helms over 2 years ago
- Status changed from Ready For Testing to Closed
Applied in changeset foreman|8a829dbcea60745e4489afde61b954e1f6a5cd97.
Fixes #31345: Fix permissions undefined for nil due to race condition
There is a race condition that can occur, most often in the installer,
when operations that load plugins are ran in parallel. This can lead
to a Role filter being created just after fetching the set of filters
but just before fetching the filter itself. When the code that
attempts to grab the filter from the set already in memory runs,
the filter is not found in the in-memory set and returns nil. Leading
to the user facing error.
This parallelization typically is only seen for new installations
given that is when multiple plugins are creating or updating roles.
This parallelization is predominantly present in the Passenger use
case as it tends to require multiple operations that load plugins
to occur at the same time. When plugins are loaded they ensure
that they are registered and that their role declarations are present
within Foreman. Thus, a situation that can cause this is Apache starting
up booting Passenger which causes plugins to load, and a rake task
such as apipie:cache:plugin which also loads plugins executing in parallel.
This effect is tended not to be seen with Puma setups because the
systemd service built around Puma does not signal completion until
the entire Foreman application has been loaded.