Project

General

Profile

Actions

Bug #23869

closed

Non admin cannot provision hosts from discovery into custom organization

Added by Konstantin R almost 6 years ago. Updated over 5 years ago.

Status:
Resolved
Priority:
Normal
Assignee:
-
Category:
Discovery plugin
Difficulty:
Triaged:
No
Fixed in Releases:
Found in Releases:

Description

Hello,
I have a couple of users all of the are organization admins, but they can't provision any hosts from discovery and facing errors below:

2018-06-08 19:10:57 2fa0b03a [app] [D] Setting current user thread-local variable to foreman_api_admin
2018-06-08 19:10:57 2fa0b03a [app] [D] Cache delete: _session_id:0d8b8196a5d2432ebb0a44e9a9673d7a
2018-06-08 19:10:57 5476b17d [app] [D] Setting current location thread-local variable to none
2018-06-08 19:10:57 5476b17d [app] [D] Setting current organization thread-local variable to Linux
2018-06-08 19:10:57 2fa0b03a [app] [D] Cache read: _session_id:0d8b8196a5d2432ebb0a44e9a9673d7a
2018-06-08 19:10:57 2fa0b03a [app] [D] Cache read: idle_timeout
2018-06-08 19:10:57 5476b17d [app] [W] Action failed | ActiveRecord::SubclassNotFound: Invalid single-table inheritance type: Host::Discovered is not a subclass of Host::Managed | /opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/inheritance.rb:203:in `find_sti_class' | /opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/inheritance.rb:177:in `discriminate_class_for_record' | /opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/persistence.rb:67:in `instantiate' | /opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/querying.rb:50:in `block (2 levels) in find_by_sql' | /opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/result.rb:55:in `block in each' | /opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/result.rb:55:in `each' | /opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/result.rb:55:in `each' | /opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/querying.rb:50:in `map' | /opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/querying.rb:50:in `block in find_by_sql' | /opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activesupport-5.1.4/lib/active_support/notifications/instrumenter.rb:21:in `instrument' | /opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/querying.rb:49:in `find_by_sql' | /opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/relation.rb:667:in `exec_queries' | /opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/relation.rb:546:in `load' | /opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/relation.rb:255:in `records' | /opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/relation/delegation.rb:39:in `each' | /usr/share/foreman/app/services/authorizer_cache.rb:12:in `include?' | /usr/share/foreman/app/services/authorizer_cache.rb:12:in `collection_cache_lookup' | /usr/share/foreman/app/services/authorizer.rb:20:in `can?' | /usr/share/foreman/app/models/concerns/authorizable.rb:12:in `check_permissions_after_save' | /opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activesupport-5.1.4/lib/active_support/callbacks.rb:413:in `block in make_lambda' | /opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activesupport-5.1.4/lib/active_support/callbacks.rb:235:in `block in halting_and_conditional' | /opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activesupport-5.1.4/lib/active_support/callbacks.rb:511:in `block in invoke_after' | /opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activesupport-5.1.4/lib/active_support/callbacks.rb:511:in `each' | /opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activesupport-5.1.4/lib/active_support/callbacks.rb:511:in `invoke_after' | /opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activesupport-5.1.4/lib/active_support/callbacks.rb:122:in `block in run_callbacks' | /opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activesupport-5.1.4/lib/active_support/callbacks.rb:135:in `run_callbacks' | /opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activesupport-5.1.4/lib/active_support/callbacks.rb:827:in `_run_save_callbacks' | /opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/callbacks.rb:336:in `create_or_update' | /opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/persistence.rb:129:in `save' | /opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/validations.rb:44:in `save' | /opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/attribute_methods/dirty.rb:35:in `save' | /opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/transactions.rb:308:in `block (2 levels) in save' | /opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/transactions.rb:384:in `block in with_transaction_returning_status' | /opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract/database_statements.rb:235:in `block in transaction' | /opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract/transaction.rb:194:in `block in within_new_transaction' | /opt/rh/rh-ruby24/root/usr/share/ruby/monitor.rb:214:in `mon_synchronize' | /opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract/transaction.rb:191:in `within_new_transaction' | /opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract/database_statements.rb:235:in `transaction' | /opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/transactions.rb:210:in `transaction' | /opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/transactions.rb:381:in `with_transaction_returning_status' | /opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/transactions.rb:308:in `block in save' | /opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/transactions.rb:323:in `rollback_active_record_state!' | /opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/transactions.rb:307:in `save' | /opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/suppressor.rb:42:in `save' | /usr/share/foreman/app/models/concerns/foreman/sti.rb:26:in `save' | /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_discovery-11.0.0/app/controllers/discovered_hosts_controller.rb:78:in `block in perform_update' | /usr/share/foreman/app/models/taxonomy.rb:67:in `block in no_taxonomy_scope' | /usr/share/foreman/app/models/taxonomy.rb:74:in `block (2 levels) in as_taxonomy' | /usr/share/foreman/app/models/concerns/foreman/thread_session.rb:168:in `as_location' | /usr/share/foreman/app/models/taxonomy.rb:73:in `block in as_taxonomy'

Wish Auto-discovery provisioning I see another error:
I can’t provisioned discovered machines with this error:
2018-06-08 17:40:06 ef49230f [app] [E] Auto provisioning failed: Owner There is no owner with id 1 and type User
2018-06-08 17:40:06 ef49230f [app] [W] Failed to auto provision host host.example.com

Only `Admin` Checkbox allow to provision new hosts.
Can somebody look a this?

Thank you

Actions #1

Updated by Konstantin R almost 6 years ago

I found how to reproduce this issue. Happens when I use custom fact foreman_organization with discovery to place different hosts under different organization.
Steps to reproduce:
1. Create two organizations A & B
2. Foreman proxy has to have discovery with two profiles with zips with foreman_organization="A" in first zip & foreman_organization="B" in second zip
3. Boot discovery host with organization B (You'll see the error above & won't be able to provision/create host)
4. Boot discovery host with organization A - everything works fine

Thanks

Actions #2

Updated by Konstantin R almost 6 years ago

With discovery to org A boot doesn't work either

Actions #3

Updated by Konstantin R almost 6 years ago

Yes,
Looks like if user an org admin & at least one node is discovered user loses ability to create/provision new nodes and faces an error above

Actions #4

Updated by Lukas Zapletal almost 6 years ago

  • Project changed from Foreman to Discovery
  • Subject changed from Non admin cannot provision hosts from discovery to Non admin cannot provision hosts from discovery into custom organization
  • Category set to Discovery plugin
  • Priority changed from Urgent to Normal

I wish I could - currently working on 1.18 release, got full plate. Check your taxonomy - ALL resources that are linked to your rule/hostgroup must have correct taxonomy. Use Organization - Mismatches report to verify taxonomy as well.

Actions #5

Updated by Konstantin R almost 6 years ago

Hi Lukas,
No any org mismatches.
This problem doesn't exist on 1.16. Actually I even provisioned a new 1.16 without orgs and another one 1.17 without any orgs. I see an error in 1.17 only.
So this problem was introduced in 1.17
Thanks

Actions #6

Updated by Lukas Zapletal over 5 years ago

Konstantin, can you try to apply this patch if it helps? It is small: https://projects.theforeman.org/issues/21465/

Report here, thank you.

Actions #7

Updated by Konstantin R over 5 years ago

  • Status changed from New to Resolved

Yes, it fixes the problem!
Thank you

Actions

Also available in: Atom PDF