allow some missing path sections in runroot config
Fixes: https://pagure.io/koji/issue/527 Before path sections were expected to have zero-based numbering. If some item was missing, parsing ended there. Now we are more benevolent and we pick all path\d+ sections and sort them by ordering number.
This commit is contained in:
parent
675e854ac0
commit
032e2aaddd
2 changed files with 8 additions and 6 deletions
|
|
@ -5,6 +5,7 @@ import koji
|
||||||
import ConfigParser
|
import ConfigParser
|
||||||
import os
|
import os
|
||||||
import platform
|
import platform
|
||||||
|
import re
|
||||||
|
|
||||||
import koji.tasks
|
import koji.tasks
|
||||||
from koji.tasks import scan_mounts
|
from koji.tasks import scan_mounts
|
||||||
|
|
@ -63,11 +64,10 @@ class RunRootTask(koji.tasks.BaseTaskHandler):
|
||||||
if cp.has_option('paths', 'path_subs'):
|
if cp.has_option('paths', 'path_subs'):
|
||||||
self.config['path_subs'] = [x.split(',') for x in cp.get('paths', 'path_subs').split('\n')]
|
self.config['path_subs'] = [x.split(',') for x in cp.get('paths', 'path_subs').split('\n')]
|
||||||
|
|
||||||
count = 0
|
# path section are in form 'path%d' while order is important as some
|
||||||
while True:
|
# paths can be mounted inside other mountpoints
|
||||||
section_name = 'path%d' % count
|
path_sections = [p for p in cp.sections() if re.match('path\d+', p)]
|
||||||
if not cp.has_section(section_name):
|
for section_name in sorted(path_sections, key=lambda x: int(x[4:])):
|
||||||
break
|
|
||||||
try:
|
try:
|
||||||
self.config['paths'].append({
|
self.config['paths'].append({
|
||||||
'mountpoint': cp.get(section_name, 'mountpoint'),
|
'mountpoint': cp.get(section_name, 'mountpoint'),
|
||||||
|
|
@ -77,7 +77,6 @@ class RunRootTask(koji.tasks.BaseTaskHandler):
|
||||||
})
|
})
|
||||||
except ConfigParser.NoOptionError:
|
except ConfigParser.NoOptionError:
|
||||||
raise koji.GenericError("bad config: missing options in %s section" % section_name)
|
raise koji.GenericError("bad config: missing options in %s section" % section_name)
|
||||||
count += 1
|
|
||||||
|
|
||||||
for path in self.config['default_mounts'] + self.config['safe_roots'] + [x[0] for x in self.config['path_subs']]:
|
for path in self.config['default_mounts'] + self.config['safe_roots'] + [x[0] for x in self.config['path_subs']]:
|
||||||
if not path.startswith('/'):
|
if not path.startswith('/'):
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,9 @@ class FakeConfigParser(object):
|
||||||
def read(self, path):
|
def read(self, path):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def sections(self):
|
||||||
|
return self.CONFIG.keys()
|
||||||
|
|
||||||
def has_option(self, section, key):
|
def has_option(self, section, key):
|
||||||
return section in self.CONFIG and key in self.CONFIG[section]
|
return section in self.CONFIG and key in self.CONFIG[section]
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue