#341 rpm_utils.get_dist_tag() doesn't understand EPEL dist tag
Closed: Invalid None Opened 7 years ago by kparal.

We should teach rpm_utils.get_dist_tag() to understand EPEL tags. Sinny Kumari standing behind task-libabigail requested this.

$ runtask -i SuperLUMT-3.1.0-5.el7  -t koji_build ../task-libabigail/libabigail.yml 
[libtaskotron] 10:42:03 INFO    Execution started at: 2016-04-14 10:42:03 UTC
[libtaskotron] 10:42:03 DEBUG   Using libtaskotron 0.4.10
[libtaskotron] 10:42:03 DEBUG   Parsed arguments: Namespace(arch=None, debug=False, item='SuperLUMT-3.1.0-5.el7', jobid='-1', libvirt=False, local=False, no_destroy=False, override=[], patch=None, ssh=None, ssh_privkey=None, task='../task-libabigail/libabigail.yml', type='koji_build', uuid='20160414_104203_592363')
[libtaskotron] 10:42:03 DEBUG   Using config file: /etc/taskotron/taskotron.yaml
[libtaskotron] 10:42:03 DEBUG   Using config profile: development
[libtaskotron] 10:42:03 INFO    Task artifacts will be saved in: /var/lib/taskotron/artifacts/20160414_104203_592363
[libtaskotron] 10:42:03 INFO    Checking installed state of 1 packages...
[libtaskotron] 10:42:06 CRITICAL Traceback (most recent call last):
  File "/home/kparal/devel/taskotron/env_taskotron/bin/runtask", line 9, in <module>
    load_entry_point('libtaskotron==0.4.4', 'console_scripts', 'runtask')()
  File "/home/kparal/devel/taskotron/libtaskotron/libtaskotron/main.py", line 163, in main
    overlord.start()
  File "/home/kparal/devel/taskotron/libtaskotron/libtaskotron/overlord.py", line 92, in start
    runner.execute()
  File "/home/kparal/devel/taskotron/libtaskotron/libtaskotron/executor.py", line 57, in execute
    self._run()
  File "/home/kparal/devel/taskotron/libtaskotron/libtaskotron/executor.py", line 91, in _run
    self._do_actions()
  File "/home/kparal/devel/taskotron/libtaskotron/libtaskotron/executor.py", line 129, in _do_actions
    self._do_single_action(action)
  File "/home/kparal/devel/taskotron/libtaskotron/libtaskotron/executor.py", line 150, in _do_single_action
    self.arg_data)
  File "/home/kparal/devel/taskotron/libtaskotron/libtaskotron/directives/koji_directive.py", line 188, in process
    disttag = rpm_utils.get_dist_tag(params['koji_build'])
  File "/home/kparal/devel/taskotron/libtaskotron/libtaskotron/ext/fedora/rpm_utils.py", line 254, in get_dist_tag
    raise exc.TaskotronValueError('Could not parse disttag from %s' % rpmstr)
TaskotronValueError: Could not parse disttag from SuperLUMT-3.1.0-5.el7

This ticket had assigned some Differential requests:
D944

It seems that this bug can be easily fixed by adding something like below into git_dist_tag

 matches = re.findall(r'\.(fc\d{1,2}|el\d{1})\.?', release)
    if not matches:
        raise exc.TaskotronValueError('Could not parse disttag from %s' % rpmstr)
    if matches[-1].startswith('el'):
        matches[-1]='fc24' #or something like fc23,etc
    return matches[-1]

The purpose is to parse the dist tag from the release tag, so something like fc24 or el7. If there's el7 as the dist tag, you should return el7. Why would you want to return fc24 instead?

Sorry,my fault,I failed to see the problem clearly.So the solution seems to be:
modify get_dist_tag

def get_dist_tag(rpmstr):
    release = rpmformat(rpmstr, 'r')
    matches = re.findall(r'\.(fc\d{1,2}|el\d{1})\.?', release)
    if not matches:
        raise exc.TaskotronValueError('Could not parse disttag from %s' % rpmstr)
    return matches[-1]

modify the code in koji_directive.py:

disttag = rpm_utils.get_dist_tag(params['koji_bodhi'])
            if disttag.startswith('f'):
                tag = disttag.replace('c', '')
            elif disttag == 'el7':
                tag = 'epel7'
            else:
                tag = 'dist-6E-epel'

and modify the code in distgit_directive.py if needed

def _download_file(self, package, path, localpath):
        pkgname = rpm_utils.rpmformat(package, fmt='n')
        dist_tag = rpm_utils.get_dist_tag(package)
        if dist_tag.startswith('f'):
                branch = dist_tag.replace('c', '')
            elif dist_tag == 'el7':
                branch = 'epel7'
            else:
                branch = dist_tag
        url = URL_FMT % (pkgname, path, branch)
        return file_utils.download(url, '.', localpath)

and considering that EPEL packages can use Fedora ,maybe we can modify the code in taskformula.py for users who prefer to use disposable VM :

 no_parse = False
try:
        distro_pa = rpm_utils.get_dist_tag(item)
# an error happens,using env['distro']=None ,env['release']=None 
    except exc.TaskotronValueError:
        no_parse = True
    if not env['distro'] and not no_parse:
        if item_type == 'koji_build':
            distro = distro_pa[:2]
            env['distro'] = {'fc': 'fedora'}.get(distro, None)
            if env['distro']:
                log.debug("Environment/distro inferred from %s:%r to %r" %
                          (item_type, item, env['distro']))
            else:
                log.debug("Environment/distro can not be inferred from %s:%r. "
                          "Using default." % (item_type, item))
        else:
            log.debug("Environment/distro can not be inferred for %r. Using default." %
                      item_type)

    if not env['release'] and not no_parse:
        if item_type == 'koji_build':
            if distro_pa.startswith('e'):
                distro_pa = None
            else:
                env['release'] = distro_pa[-2:]

I'm going to submit a diff,if all the modified code looks good: )

I'm not sure I follow, please create the diff, and we can discuss it there, having all the necessary context. Thank you!

I'm going to submit a diff,if all the modified code looks good: )

It's too hard to tell, because I can't see the changes easily. Please submit the diff right away. Tickets are a good place to discuss the overall strategy of resolving an issue, and Diffs are a good place to discuss code changes.

Please also try to include new unit tests with the patch, it will help you identify whether your code works properly even in corner cases, or not.

The usual workflow is that you assign this ticket to yourself to show that you're going to work on it (//Actions -> Assign/Claim//). Then create the diff, and either in the diff click //Edit Maniphest Tasks// and join the diff with this task, or click //Edit Differential Revisions// here in this task and join this task with the new diff.

! In #769#11407, @jskladan wrote:
I'm not sure I follow, please create the diff, and we can discuss it there, having all the necessary context. Thank you!
Sure,gonna to do.

! In #769#11409, @kparal wrote:
I'm going to submit a diff,if all the modified code looks good: )
It's too hard to tell, because I can't see the changes easily. Please submit the diff right away. Tickets are a good place to discuss the overall strategy of resolving an issue, and Diffs are a >good place to discuss code changes.Please also try to include new unit tests with the patch, it will help you identify whether your code works properly even in corner cases, or not.
Okay,sure thing: )
The usual workflow is that you assign this ticket to yourself to show that you're going to work on it (Actions -> Assign/Claim). Then create the diff, and either in the diff click Edit >Maniphest Tasks and join the diff with this task, or click Edit Differential Revisions here in this task and join this task with the new diff.
Thanks for your helpful information again.

Metadata Update from @kparal:
- Issue tagged with: easyfix

6 years ago

Login to comment on this ticket.

Metadata