From 7b0ae0056865e1b006628e3519f1741b19171506 Mon Sep 17 00:00:00 2001 From: Tomas Kopecek Date: Dec 03 2019 10:47:51 +0000 Subject: 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 --- diff --git a/hub/kojihub.py b/hub/kojihub.py index 51d5e2f..95ea163 100644 --- a/hub/kojihub.py +++ b/hub/kojihub.py @@ -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):