Project

General

Profile

Bug #28948

service commands break on pulp3 box when /etc/pulp/settings.py isn't formatted correctly

Added by John Mitsch almost 2 years ago. Updated almost 2 years ago.

Status:
Ready For Testing
Priority:
Normal
Assignee:
Category:
-
Target version:
-
Difficulty:
Triaged:
No
Bugzilla link:
Fixed in Releases:
Found in Releases:

Description

Currently this is breaking in a dev box:

[vagrant@centos7-katello-devel-stable foreman_maintain{master}]$ foreman_maintain_scl service status
Running Status Services
================================================================================
Get status of applicable services:

Displaying the following service(s):                                  [FAIL]
undefined method `+' for nil:NilClass
--------------------------------------------------------------------------------
Scenario [Status Services] failed.

The following steps ended up in failing state:

  [service-status]

Resolve the failed steps and rerun
the command. In case the failures are false positives,
use --whitelist="service-status" 

Foreman-maintain reads from /etc/pulp/settings.py (PULPCORE_DB_CONFIG variable here) https://github.com/theforeman/foreman_maintain/blob/master/definitions/features/pulpcore_database.rb def load_configuration
full_config = File.read(PULPCORE_DB_CONFIG).split(/[\s,':]/).reject(&:empty?) @configuration = {}
@configuration['adapter'] = 'postgresql'
@configuration['host'] = full_config[full_config.index('HOST') + 1]
@configuration['port'] = full_config[full_config.index('PORT') + 1]
@configuration['database'] = full_config[full_config.index('NAME') + 1]
@configuration['username'] = full_config[full_config.index('USER') + 1]
@configuration['password'] = full_config[full_config.index('PASSWORD') + 1]
@configuration
end

In /etc/pulp/settings.py, this info is in `DATABASES` on a single line
[vagrant@centos7-katello-devel-stable foreman_maintain{master}]$ sudo cat /etc/pulp/settings.py
DATABASES = {"default": {"HOST": "localhost", "ENGINE": "django.db.backends.postgresql_psycopg2", "NAME": "pulp", "USER": "pulp", "PASSWORD": "pulp", "PORT": 7878}}
SECRET_KEY = "secret"
CONTENT_ORIGIN = "centos7-katello-devel-stable.example.com"
TOKEN_AUTH_DISABLED = True
REMOTE_USER_ENVIRON_NAME = "HTTP_REMOTE_USER"
ANSIBLE_API_HOSTNAME = "centos7-katello-devel-stable.example.com"
ANSIBLE_CONTENT_HOSTNAME = "https://centos7-katello-devel-stable.example.com/pulp_ansible/content/"
PULP2_MONGODB = {"name": "pulp_database", "seeds": "localhost:27017"}

There is a workaround for a more forgiving way to parse a config file by changing the `split` method to be `split(/[\s,'":]/)` in pulpcore_database.rb

Ideally we figure out a more robust way of parsing the file or convert it into a parseable format

Associated revisions

Revision e51ddcb5 (diff)
Added by John Mitsch almost 2 years ago

Refs #28948 - Make pulp settings parsing more robust

There is some more detail in the issue, but basically we are parsing a python file to get the pulp db settings. We should come up with a better solution but this change will make things more robust for now and fix the 'service' commands in the development environment.

History

#1 Updated by John Mitsch almost 2 years ago

  • Description updated (diff)

#2 Updated by The Foreman Bot almost 2 years ago

  • Assignee set to John Mitsch
  • Status changed from New to Ready For Testing
  • Pull request https://github.com/theforeman/foreman_maintain/pull/314 added

Also available in: Atom PDF