#558 Fix default subject_types configuration path
Merged 4 years ago by lholecek. Opened 4 years ago by lholecek.
lholecek/greenwave fix-default-subject-types-dir  into  master

file modified
+1
@@ -31,6 +31,7 @@ 

  # This will allow a non-root user to install a custom root CA at run-time

  RUN chmod 777 /etc/pki/tls/certs/ca-bundle.crt

  COPY . .

+ ENV GREENWAVE_SUBJECT_TYPES_DIR /src/conf/subject_types

  RUN pip3 install . --no-deps

  # Remove the default fedmsg config files included in the repo

  RUN rm -rf ./fedmsg.d

file modified
+3
@@ -98,6 +98,9 @@ 

      if os.environ.get('SECRET_KEY'):

          config['SECRET_KEY'] = os.environ['SECRET_KEY']

  

+     if os.environ.get('GREENWAVE_SUBJECT_TYPES_DIR'):

+         config['SUBJECT_TYPES_DIR'] = os.environ['GREENWAVE_SUBJECT_TYPES_DIR']

+ 

      return config

  

  

file modified
-2
@@ -1,7 +1,6 @@ 

  # -*- coding: utf-8 -*-

  # SPDX-License-Identifier: GPL-2.0+

  

- import glob

  import os

  import re

  from setuptools import setup, find_packages
@@ -101,6 +100,5 @@ 

      """,

      data_files=[

          ('/etc/fedmsg.d/', ['fedmsg.d/resultsdb.py', 'fedmsg.d/waiverdb.py']),

-         ('conf/subject_types/', glob.glob('conf/subject_types/*')),

      ]

  )

Default configuration path for subject_types in message consumers is
invalid because subject_types directory is not installed in /usr/lib*.

Falls back to /src/conf base configuration directory.

Signed-off-by: Lukas Holecek hluk@email.cz

Hmm, actually this is relative path. Oops. It should be /src/conf/....

Probably better solution would be an env variable set for the container. What do you think?

The environment variable seems like a good idea yes. Flexible and should be fairly straight forward

rebased onto c18346e

4 years ago

Nice and easy, :thumbsup: for me

Just one thing: Should we add a log.info(f"Loading files from {source}") or so?

Just one thing: Should we add a log.info(f"Loading files from {source}") or so?

There is:

log.debug("config: Loading subject types from %r", subject_types_dir)

Would it make sense to change it to info log level?

Hm, if there is already one cool, but I did not see it in the logs of the consumer pod (and looking at kibana I'm still not seeing it :().
I don't think it's worth changing the log level.

With the help of @asaleh who came up with the right kibana syntax:

 kubernetes.labels.deploymentconfig:"greenwave-fedmsg-consumers" AND message:"Loading"

I can now see the log message:

[greenwave.app_factory DEBUG] config: Loading subject types from '/usr/local/lib/python3.7/site-packages/conf/subject_types'

So +1 for me

Pull-Request has been merged by lholecek

4 years ago