Cannot add repository after creating product " nil smart_proxy passed to PulpSelector"

Problem:
Warning: An error occured while loading module hammer_cli_foreman_remote_execution.
ERROR:
Could not create the repository:
nil smart_proxy passed to PulpSelector

Expected outcome:
Coulnot add repository for the product centos 8

Foreman and Proxy versions:

Foreman and Proxy plugin versions:
foreman 2.0.3
Katello 3.15

Any help may be appreciated ?

Hi @eckris1

What were you doing when this error occurred? Could you provide a bit more detail? What were the previous steps?

Hello mcorr,
Thanks for your response.
I am getting the above said error while adding repository using either hammer cli or through GUI.


[root@ansible ~]# hammer repository create --organization ‘mmv’ --product ‘CentOS8’ \

–name ‘CentOS 8 BaseOS’ --label ‘CentOS8_BaseOS’
–content-type ‘yum’ --download-policy ‘on_demand’
–gpg-key ‘RPM-GPG-KEY-CentOS-8’
–url ‘http://mirror.centos.org/centos-8/8.2.2004/BaseOS/x86_64/os/
–mirror-on-sync ‘no’
Warning: An error occured while loading module hammer_cli_foreman_remote_execution.
Could not create the repository:
nil smart_proxy passed to PulpSelector


Here you go for mt org list
[root@ansible ~]# hammer organization list

Warning: An error occured while loading module hammer_cli_foreman_remote_execution.
—|----------------------|----------------------|-------------|---------------------

ID TITLE NAME DESCRIPTION LABEL
1 Default Organization Default Organization Default_Organization
3 mmv mmv mmv
---------------------- ---------------------- ------------- ---------------------

Hey @eckris1

The first thing that strikes me as wrong here is I think that Foreman automatically completes the Label field based on what you have entered for Name .

Edit: Perhaps that has nothing to do with it since it is happening through the UI also.

Anyone have any ideas?

Hi @eckris1,

Would you mind posting the full error stacktrace from /var/log/foreman/production.log?

Do you see any errors on your main smart proxy’s Logs tab?

1 Like

Getting these errors repeatedly while running adding repo under /var/log/foreman/production.log

[root@ansible ~]# vi /var/log/foreman/production.log
[root@ansible ~]# cat /var/log/foreman/production.log | grep -i error
2020-10-22T09:08:19 [E|bac|] nil smart_proxy passed to PulpSelector (RuntimeError)
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.4.6/lib/dynflow/action.rb:475:in block in with_error_handling' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.4.6/lib/dynflow/action.rb:475:in with_error_handling’
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.4.6/lib/dynflow/action.rb:475:in block in with_error_handling' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.4.6/lib/dynflow/action.rb:475:in with_error_handling’
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.4.6/lib/dynflow/middleware/common/transaction.rb:17:in block in rollback_on_error' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.4.6/lib/dynflow/middleware/common/transaction.rb:16:in rollback_on_error’
/usr/share/foreman/lib/foreman/middleware/catch_json_parse_errors.rb:9:in call' 2020-10-22T09:08:19 [E|bac|] nil smart_proxy passed to PulpSelector (RuntimeError) /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.4.6/lib/dynflow/action.rb:475:in block in with_error_handling’
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.4.6/lib/dynflow/action.rb:475:in with_error_handling' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.4.6/lib/dynflow/action.rb:475:in block in with_error_handling’
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.4.6/lib/dynflow/action.rb:475:in with_error_handling' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.4.6/lib/dynflow/middleware/common/transaction.rb:17:in block in rollback_on_error’
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.4.6/lib/dynflow/middleware/common/transaction.rb:16:in rollback_on_error' /usr/share/foreman/lib/foreman/middleware/catch_json_parse_errors.rb:9:in call’
2020-10-22T09:08:19 [I|bac|] Task {label: Actions::Katello::Repository::CreateRoot, id: cbda4f7b-f6e7-450b-a1a0-5b0bcc057379, execution_plan_id: 0961e553-c56c-4df0-901d-bfd425c8ec15} state changed: stopped result: error
2020-10-22T09:08:19 [I|bac|] Task {label: Actions::Katello::Repository::CreateRoot, id: cbda4f7b-f6e7-450b-a1a0-5b0bcc057379, execution_plan_id: 0961e553-c56c-4df0-901d-bfd425c8ec15} state changed: stopped result: error
2020-10-22T09:08:19 [E|app|] RuntimeError: nil smart_proxy passed to PulpSelector
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.4.6/lib/dynflow/action.rb:475:in block in with_error_handling' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.4.6/lib/dynflow/action.rb:475:in with_error_handling’
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.4.6/lib/dynflow/action.rb:475:in block in with_error_handling' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.4.6/lib/dynflow/action.rb:475:in with_error_handling’
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.4.6/lib/dynflow/middleware/common/transaction.rb:17:in block in rollback_on_error' /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.4.6/lib/dynflow/middleware/common/transaction.rb:16:in rollback_on_error’
/usr/share/foreman/lib/foreman/middleware/catch_json_parse_errors.rb:9:in `call’
2020-10-22T09:08:19 [I|app|] Completed 500 Internal Server Error in 767ms (Views: 0.7ms | ActiveRecord: 142.8ms)
2020-10-22T09:08:23 [E|bac|] nil smart_proxy passed to PulpSelector (RuntimeError)

Thanks. In the Foreman Rails console (sudo foreman-rake console), do you mind showing me the output of SmartProxy.pulp_primary ?

Thanks iballou.
Didn’t see any output while running /usr/sbin/foreman-rake.
instead ran the following not seeing any info about SmartProxy_pulp_primary
[root@ansible ~]# /usr/sbin/foreman-rake -v
rake aborted!
ActiveRecord::ProtectedEnvironmentError: You are attempting to run a destructive action against your ‘production’ database.
If you are sure you want to continue, run the same command with the environment variable:
DISABLE_DATABASE_ENVIRONMENT_CHECK=1
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/tasks/database_tasks.rb:61:in check_protected_environments!' /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/railties/databases.rake:13:in block (2 levels) in <top (required)>’
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/railties/databases.rake:345:in block (3 levels) in <top (required)>' /opt/rh/rh-ruby25/root/usr/share/gems/gems/rake-12.3.0/exe/rake:27:in <top (required)>’
Tasks: TOP => db:test:load => db:test:purge => db:check_protected_environments
(See full trace by running task with --trace)
[root@ansible ~]# /usr/sbin/foreman-rake --execute
rake aborted!
OptionParser::MissingArgument: missing argument: --execute

which SmartProxy.pulp_primary
/usr/bin/which: no SmartProxy.pulp_primary in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/opt/puppetlabs/bin:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.262.b10-0.el7_8.x86_64/jre/bin:/root/bin)

Hi @eckris1,

What I meant was for you to open the Foreman Rails console by running:

sudo foreman-rake console

Once the interactive console launches, I’d like to see what pops up for:

SmartProxy.pulp_master

(I missed that you were on Katello 3.15, which is why I’m requesting for pulp_master now instead of pulp_primary. We had a name change recently in newer versions of Katello.)

If SmartProxy.pulp_master returns nil here, I’m suspecting that your main smart proxy isn’t set up properly.

Thanks iballou.
You correct !

[root@ansible ~]# foreman-rake console
Loading production environment (Rails 5.2.1)
irb(main):001:0> SmartProxy.pulp_master
=> nil
irb(main):002:0>

Can you Let me know how to setup the same ?

Thanks in advance
Kris

Iballou,
Re-ran the foreman-installer for smartproxy it resolved the issue.

[root@ansible ~]# foreman-installer \

–enable-foreman-proxy
–foreman-proxy-tftp=true
–foreman-proxy-tftp-servername=192.xx.xx.xx
–foreman-proxy-dhcp=true
–foreman-proxy-dhcp-interface=ens192
–foreman-proxy-dhcp-gateway=192.xx.xx.xx
–foreman-proxy-dns=true
–foreman-proxy-dns-interface=ens192
–foreman-proxy-dns-zone=lab.local
–foreman-proxy-dns-reverse=1.168.192.in-addr.arpa
–foreman-proxy-dns-forwarders=192.168.xx.xx
–foreman-proxy-foreman-base-url=https://ansible.lab.local
–foreman-proxy-trusted-hosts=ansible.lab.local
–foreman-proxy-oauth-consumer-key=4RQVUGKLtPMa5mh7fVswoESpqVn3gvav
–foreman-proxy-oauth-consumer-secret=uDeNZsjituQAXGnZEGQVkZZab7HEZcHp

after running i can able to add repositiories
Did the same thing while installing it didn’t configure as expected.
After re-ran:
[root@ansible ~]# ./repo-creation
Repository created.
Base OS REPO Created
Repository created.
APPSTREAM OS REPO Created
Repository created.
Powertoll REPO Created
Repository created.
CentOSPlus REPO Created
Repository created.
CentOS8_Extras REPO Created

1 Like