Ticket #256 (closed defect: wontfix)

Opened 3 years ago

Last modified 3 years ago

CWD override does not work

Reported by: kparal Owned by: kparal
Priority: critical Milestone: 0.4.4
Component: core Keywords:
Cc: Blocked By:
Blocking:

Description

We recently pushed patch to read config files from CWD by default (5d37e59128c1913946c02e6a1d899a5576f37801). Then we pushed patch to initialize autoqa_conf variable in config.py, used e.g. by koji_utils.py. And that broke it. Because if you import such a module before running run_once() method (like rpmguard does), the CWD is not yet set, and the local autoqa.conf is not found.

The current workaround is to always have up-to-date /etc/autoqa/autoqa.conf on autotest clients (the same approach as always in the past).

Our current "change CWD" approach is now therefore useless. We have to find another way to copy and access config files. The best way would be to hack autotest to copy them directly to /etc (do we don't have to fight with CWD at all).

Ouch ouch.

Change History

comment:1 Changed 3 years ago by jlaska

My understanding is that we should first check autoqa.conf in CWD, then in the system location. As long as it's not crashing, and finding the system-wide config-file, is this working as expected? What does the failure look like?

comment:2 Changed 3 years ago by kparal

  • Owner set to kparal

No, it's not crashing, and yes, it is able to find system-wide config file. It's just not able to find local config file, since the CWD is not set properly. We can't set it from AutoQA code (it's needed before the first import, and the self object is available only in the run_once method). We could hack Autotest more, to set it before even executing our test object. I don't know if it's possible, I'll have a look into it.

comment:3 Changed 3 years ago by jlaska

Oh I see ... oops!

# ln -s python lib/autoqa
# PYTHONPATH=lib ./autoqa -h
Traceback (most recent call last):
  File "./autoqa", line 51, in <module>
    conf = cfg_parser.get_section('general', conf)
  File "/home/devel/jlaska/CVS/autoqa.git/lib/autoqa/config.py", line 80, in get_section
    items = dict(self.items(section))
  File "/usr/lib64/python2.7/ConfigParser.py", line 589, in items
    raise NoSectionError(section)
ConfigParser.NoSectionError: No section: 'general'

The following (lightly tested) patch at least addresses the traceback, and appears to load the autoqa.conf form CWD (when none exists in /etc/autoqa). Does this help?

diff --git a/autoqa b/autoqa
index f024a4a..0dc1213 100755
--- a/autoqa
+++ b/autoqa
@@ -31,9 +31,8 @@ import socket
 import copy
 import fnmatch
 from subprocess import call
-from autoqa.config import SingleConfigParser, getbool
+from autoqa.config import autoqa_conf, getbool
 
-cfgfile = '/etc/autoqa/autoqa.conf'
 # Hardcoded defaults for the 'general' section
 conf = {
     'local': 'false',
@@ -43,13 +42,8 @@ conf = {
     'autotest_server': socket.gethostname(),
 }
 
-# It would be nice to import autoqa_conf here (instead of parsing it manually),
-# but we need to modify it a little bit (in prep_controlfile) and ConfigParser
-# unfortunately doesn't support deepcopy
-cfg_parser = SingleConfigParser()
-cfg_parser.read(cfgfile)
-conf = cfg_parser.get_section('general', conf)
-conf = cfg_parser.get_section('notifications', conf)
+conf = autoqa_conf.get_section('general', conf)
+conf = autoqa_conf.get_section('notifications', conf)
 # we don't need to catch errors here, bcz we want autoqa to crash for invalid config
 
 def prep_controlfile(controlfile, extradata):
# PYTHONPATH=lib ./autoqa -h
Can't find hooks in /usr/share/autoqa. Check your installation.

comment:4 Changed 3 years ago by kparal

  • Status changed from new to closed
  • Resolution set to wontfix

Thanks to jlaska's patch 6a51e2cf60fb8ee0d5e550141f86a78d52e24260 we don't need to solve this problem any more. We no longer copy config files to tests directory, we copy them directly to /etc/autoqa.

Note: See TracTickets for help on using tickets.