From 2033439a9165217deb5c8d0656526619a95f3fb0 Mon Sep 17 00:00:00 2001 From: Tomas Kopecek Date: Dec 20 2019 10:40:31 +0000 Subject: raise GenericError on existing build reservation Fixes: https://pagure.io/koji/issue/1888 --- diff --git a/hub/kojihub.py b/hub/kojihub.py index 5f8c3cd..9b7e502 100644 --- a/hub/kojihub.py +++ b/hub/kojihub.py @@ -5795,7 +5795,7 @@ def clear_reservation(build_id): def cg_init_build(cg, data): """Create (reserve) a build_id for given data. - If build already exists, init_build will raise GenericError + If build or reservation already exists, init_build will raise GenericError :param str cg: content generator name :param dict data: build data same as for new_build, for given usecase @@ -5812,6 +5812,11 @@ def cg_init_build(cg, data): # CGs shouldn't have to worry about epoch data.setdefault('epoch', None) build_id = new_build(data, strict=False) + + # check potentially existing token + if get_reservation_token(build_id): + raise koji.GenericError("Build is already reserved") + # store token token = generate_token() insert = InsertProcessor(table='build_reservations')