fix CGRefundBuild to release build properly

CGInitBuild will fail on already existing build (even canceled/failed),
so it can't be used to reuse previously refunded nvr.

CGRefund build doesn't delete reservation. Having reservation token for
build which is no more in BUILDING doesn't make much sense and blocks
and reservation of same NVR.

Fixes: https://pagure.io/koji/issue/1852
This commit is contained in:
Tomas Kopecek 2019-12-03 11:47:51 +01:00
parent 64c5348f1e
commit 20b91e85a0

View file

@ -5809,7 +5809,7 @@ def cg_init_build(cg, data):
data['cg_id'] = cg_id
# CGs shouldn't have to worry about epoch
data.setdefault('epoch', None)
build_id = new_build(data, strict=True)
build_id = new_build(data, strict=False)
# store token
token = generate_token()
insert = InsertProcessor(table='build_reservations')
@ -5855,6 +5855,7 @@ def cg_refund_build(cg, build_id, token, state=koji.BUILD_STATES['FAILED']):
binfo = get_build(build_id, strict=True)
koji.plugin.run_callbacks('postBuildStateChange', attribute='state',
old=koji.BUILD_STATES['BUILDING'], new=state, info=binfo)
clear_reservation(build_id)
def cg_import(metadata, directory, token=None):