#3777 CG: allow reimports into failed/cancelled builds
Merged by tkopecek. Opened by tkopecek.
tkopecek/koji issue3776  into  master

Download 3777.patch

Related: https://pagure.io/koji/issue/3776

I would allow this in such cases. Maybe further check that cg_id for existing builds is same as the current one?

It's a little unclear what the real use case is for allowing this (the issue seems to stem from a testing issue). That said, the code had the TODO there and our old import paths allow this.

I don't think that we need to check cg_id here. I'm not sure that a failed/canceled build is necessarily claimed by the cg. The build will be updated to the calling cg. Also note that the sanity checks and cleanup from recycle_build will be called later via new_build.

The remaining "TODO" line doesn't seem accurate.

Not from this PR, but we actually know that metadata['build'].get('build_id') evaluates to False here because of the earlier if clause, so that part of the check is redundant

Perhaps something like:

else:
    # no build reservation
    buildinfo = get_build(metadata['build'], strict=False)
    if buildinfo:
        if (koji.BUILD_STATES[buildinfo['state']] not in ('CANCELED', 'FAILED')):
            raise koji.GenericError("Build already exists: %r" % buildinfo)
        # note: the checks in recycle_build will also apply when we call new_build later

breaks a unit test, but the unit test is providing a nonsense mocked value

rebased onto 6ca2245ca182d3afe10dbd64e0df699d5db99cfb

:thumbsup:

Metadata Update from @tkopecek:
- Pull-request tagged with: testing-ready

Metadata Update from @mfilip:
- Pull-request tagged with: testing-done

Commit 11c3fe51 fixes this pull-request

Pull-Request has been merged by tkopecek

Metadata