foreman-rake apipie:cache:index command fails during the upgradation of Satellite Server to version 6.4 with the following error - Errno::EACCES: Permission denied @ rb_sysopen - /usr/share/foreman/public/apipie-cache/apidoc.html

Solution Verified - Updated

Environment

  • Red Hat Satellite 6.3

  • Red Hat Enterprise Linux 7.x

Issue

  • Upgradation to Red Hat Satellite 6.4 fails with the following error when foreman-rake apipie:cache:index command is executed:
Log file /usr/share/foreman/log/production.log cannot be opened. Falling back to STDOUT
 WARN  root : No appender set, logging to STDOUT
** Invoke apipie:cache:index (first_time)
** Execute apipie:cache:index
** Invoke apipie:cache (first_time)
** Invoke environment (first_time)
** Execute environment
...
** Execute apipie:cache
2019-01-09 09:28:12 -0500 | Started
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman_docker-4.1.0/app/controllers/api/v2/containers_controller.rb:107: warning: constant ::Fixnum is deprecated
2019-01-09 09:28:18 -0500 | Documents loaded...
2019-01-09 09:28:18 -0500 | Processing docs for
rake aborted!
Errno::EACCES: Permission denied @ rb_sysopen - /usr/share/foreman/public/apipie-cache/apidoc.html
/opt/theforeman/tfm/root/usr/share/gems/gems/apipie-rails-0.5.7/lib/tasks/apipie.rake:182:in `initialize'
/opt/theforeman/tfm/root/usr/share/gems/gems/apipie-rails-0.5.7/lib/tasks/apipie.rake:182:in `open'
/opt/theforeman/tfm/root/usr/share/gems/gems/apipie-rails-0.5.7/lib/tasks/apipie.rake:182:in `render_page'
...

Resolution

  • Alter the file owner permission on the following files:
# chown foreman:foreman /usr/share/foreman/public/apipie-cache/apidoc.html

# chown foreman:foreman /var/log/foreman/production.log
  • Execute the upgrade command again after the permissions have been modified as shown above.

For more KB articles/solutions related to Red Hat Satellite 6.x Installation/Upgrade/Update Issues, please refer to the Red Hat Satellite Consolidated Troubleshooting Article for Red Hat Satellite 6.x Installation/Upgrade/Update Issues.

Root Cause

  • Incorrect owner permission on /usr/share/foreman/public/apipie-cache/apidoc.html and /var/log/foreman/production.log files.

Diagnostic Steps

  • Errors found in satellite.log file:
[ERROR 2019-01-08T11:13:32 main]  /Stage[main]/Foreman/Foreman::Rake[apipie:cache:index]/Exec[foreman-rake-apipie:cache:index]: Failed to call refresh: '/usr/sbin/foreman-rake apipie:cache:index' returned 1 instead of one of [0]
[ERROR 2019-01-08T11:13:32 main]  /Stage[main]/Foreman/Foreman::Rake[apipie:cache:index]/Exec[foreman-rake-apipie:cache:index]: '/usr/sbin/foreman-rake apipie:cache:index' returned 1 instead of one of [0]
[ERROR 2019-01-08T11:13:32 main] /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/errors.rb:157:in `fail'
[ERROR 2019-01-08T11:13:32 main] /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/type/exec.rb:164:in `sync'
[ERROR 2019-01-08T11:13:32 main] /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/type/exec.rb:604:in `refresh'
...
[ERROR 2019-01-08T11:13:32 main] /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/command_line.rb:137:in `run'
[ERROR 2019-01-08T11:13:32 main] /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/command_line.rb:73:in `execute'
[ERROR 2019-01-08T11:13:32 main] /opt/puppetlabs/puppet/bin/puppet:5:in `<main>'
[ERROR 2019-01-08T11:14:18 main] Upgrade failed during the installation phase. Fix the error and re-run the upgrade.


[ERROR 2019-01-08T11:14:44 main] Errors encountered during run:
[ERROR 2019-01-08T11:14:44 main]  /Stage[main]/Foreman/Foreman::Rake[apipie:cache:index]/Exec[foreman-rake-apipie:cache:index]: Failed to call refresh: '/usr/sbin/foreman-rake apipie:cache:index' returned 1 instead of one of [0]
[ERROR 2019-01-08T11:14:44 main]  /Stage[main]/Foreman/Foreman::Rake[apipie:cache:index]/Exec[foreman-rake-apipie:cache:index]: '/usr/sbin/foreman-rake apipie:cache:index' returned 1 instead of one of [0]
[ERROR 2019-01-08T11:14:44 main] /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/errors.rb:157:in `fail'
[ERROR 2019-01-08T11:14:44 main] /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/type/exec.rb:164:in `sync'
[ERROR 2019-01-08T11:14:44 main] /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/type/exec.rb:604:in `refresh'
...
[ERROR 2019-01-08T11:14:44 main] /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application.rb:375:in `run'
[ERROR 2019-01-08T11:14:44 main] /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/command_line.rb:137:in `run'
[ERROR 2019-01-08T11:14:44 main] /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/command_line.rb:73:in `execute'
[ERROR 2019-01-08T11:14:44 main] /opt/puppetlabs/puppet/bin/puppet:5:in `<main>'
[ERROR 2019-01-08T11:14:44 main] Upgrade failed during the installation phase. Fix the error and re-run the upgrade.
  • When the above command - /usr/sbin/foreman-rake apipie:cache:index is executed with a --trace option, the following is shown:
# /usr/sbin/foreman-rake apipie:cache:index --trace

/usr/share/foreman/lib/foreman.rb:8: warning: already initialized constant Foreman::UUID_REGEXP
/usr/share/foreman/lib/foreman.rb:8: warning: previous definition of UUID_REGEXP was here
/usr/share/foreman/lib/core_extensions.rb:182: warning: already initialized constant ActiveSupport::MessageEncryptor::DEFAULT_CIPHER
/opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activesupport-5.1.6/lib/active_support/message_encryptor.rb:22: warning: previous definition of DEFAULT_CIPHER was here
Log file /usr/share/foreman/log/production.log cannot be opened. Falling back to STDOUT
 WARN  root : No appender set, logging to STDOUT
** Invoke apipie:cache:index (first_time)
** Execute apipie:cache:index
** Invoke apipie:cache (first_time)
** Invoke environment (first_time)
** Execute environment
API controllers newer than Apipie cache! Run apipie:cache rake task to regenerate cache.
 WARN  app : Plugin foreman_theme_satellite has assets outside of its namespace, these will be ignored: Redhat-logo.svg, favicon.ico, header_logo.svg, login_bg.jpg, login_logo.svg, theme_client_side_branding.js.erb, theme_dashboard.js, satellite/bastion.scss, satellite/colors.scss, satellite/login.scss, satellite/patternfly_and_overrides.scss, satellite/topbar.scss, satellite/wizard.scss, theme.scss
 INFO  app : Current user: foreman_admin (administrator)
 INFO  app : Current user: foreman_admin (administrator)
 INFO  app : Current user: foreman_admin (administrator)
 INFO  app : Current user: foreman_admin (administrator)
 INFO  app : Current user: foreman_admin (administrator)
 INFO  app : Current user: foreman_admin (administrator)
 INFO  app : Current user: foreman_admin (administrator)
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.7.0.42/app/models/katello/concerns/content_facet_host_extensions.rb:7: warning: already initialized constant Katello::Concerns::ContentFacetHostExtensions::ERRATA_STATUS_MAP
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.7.0.42/app/models/katello/concerns/content_facet_host_extensions.rb:7: warning: previous definition of ERRATA_STATUS_MAP was here
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.7.0.42/app/models/katello/concerns/content_facet_host_extensions.rb:14: warning: already initialized constant Katello::Concerns::ContentFacetHostExtensions::TRACE_STATUS_MAP
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.7.0.42/app/models/katello/concerns/content_facet_host_extensions.rb:14: warning: previous definition of TRACE_STATUS_MAP was here
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.7.0.42/app/models/katello/concerns/subscription_facet_host_extensions.rb:13: warning: already initialized constant Katello::Concerns::SubscriptionFacetHostExtensions::SUBSCRIPTION_STATUS_MAP
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.7.0.42/app/models/katello/concerns/subscription_facet_host_extensions.rb:13: warning: previous definition of SUBSCRIPTION_STATUS_MAP was here
 INFO  app : Current user: foreman_admin (administrator)
 INFO  app : Current user: foreman_admin (administrator)
 INFO  app : Current user: foreman_admin (administrator)
 INFO  app : Current user: foreman_admin (administrator)
 INFO  app : Current user: foreman_admin (administrator)
 INFO  app : Current user: foreman_admin (administrator)
 INFO  app : Current user: foreman_admin (administrator)
 INFO  app : Current user: foreman_admin (administrator)
 INFO  app : Current user: foreman_admin (administrator)
 INFO  app : Current user: foreman_admin (administrator)
 INFO  app : Current user: foreman_admin (administrator)
 WARN  app : Plugin redhat_access has assets outside of its namespace, these will be ignored: insights/app.module.js, insights/application.js, insights/configuration.controller.js, insights/configuration.service.js, insights/views/configuration.html, insights/views/error.html, insights/views/help.html, insights/application.css, insights/insights.css
** Execute apipie:cache
2019-01-09 09:28:12 -0500 | Started
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman_docker-4.1.0/app/controllers/api/v2/containers_controller.rb:107: warning: constant ::Fixnum is deprecated
2019-01-09 09:28:18 -0500 | Documents loaded...
2019-01-09 09:28:18 -0500 | Processing docs for
rake aborted!
Errno::EACCES: Permission denied @ rb_sysopen - /usr/share/foreman/public/apipie-cache/apidoc.html
/opt/theforeman/tfm/root/usr/share/gems/gems/apipie-rails-0.5.7/lib/tasks/apipie.rake:182:in `initialize'
/opt/theforeman/tfm/root/usr/share/gems/gems/apipie-rails-0.5.7/lib/tasks/apipie.rake:182:in `open'
/opt/theforeman/tfm/root/usr/share/gems/gems/apipie-rails-0.5.7/lib/tasks/apipie.rake:182:in `render_page'
...
/opt/rh/rh-ruby24/root/usr/bin/rake:23:in `load'
/opt/rh/rh-ruby24/root/usr/bin/rake:23:in `<main>'
Tasks: TOP => apipie:cache
 INFO  dynflow : start terminating throttle_limiter...
 INFO  dynflow : start terminating client dispatcher...
 INFO  dynflow : stop listening for new events...
 INFO  dynflow : start terminating clock...
  • Check the file owner permissions using the namei -xl command as shown below:
# namei -xl /usr/share/foreman/public/apipie-cache/apidoc.html
f: /usr/share/foreman/public/apipie-cache/apidoc.html
Dr-xr-xr-x root      root    /
Drwxr-xr-x root      root    usr
drwxr-xr-x root      root    share
drwxr-xr-x root      root    foreman
lrwxrwxrwx root      root    public -> /var/lib/foreman/public
Dr-xr-xr-x root      root      /
Drwxr-xr-x root      root      var
drwxr-xr-x root      root      lib
drwxr-xr-x foreman   foreman   foreman
drwxr-xr-x foreman   foreman   public
drwxr-xr-x foreman   foreman apipie-cache
-rw-r--r-- qdrouterd foreman apidoc.html

# namei -xl /var/log/foreman/production.log
f: /var/log/foreman/production.log
Dr-xr-xr-x root      root    /
Drwxr-xr-x root      root    var
drwxr-xr-x root      root    log
drwxr-x--- foreman   foreman foreman
-rw-r--r-- qdrouterd foreman production.log
SBR
Product(s)
Components
Category

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.