From 58b240981f9ac02d521a6ca9323f6318274cc165 Mon Sep 17 00:00:00 2001 From: Ryan Waldheim Date: Mon, 15 Jun 2026 11:41:43 -0700 Subject: [PATCH 1/2] Block cluster allocations to repo if no allocation at the facility level --- schema.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/schema.py b/schema.py index cae3de8..babb1b0 100644 --- a/schema.py +++ b/schema.py @@ -1276,6 +1276,25 @@ def repoComputeAllocationUpsert(self, repo: RepoInput, repocompute: RepoComputeA clustername = repocompute.clustername if not info.context.db.find_clusters({"name": clustername}): raise Exception("Cannot find cluster with name " + clustername) + + # Validate facility has purchased resources on this cluster + facility_name = repo.facility + todaysdate = datetime.utcnow() + + purchase = info.context.db.collection("facility_compute_purchases").find_one({ + "facility": facility_name, + "clustername": clustername, + "start": {"$lte": todaysdate}, + "end": {"$gt": todaysdate}, + "servers": {"$gt": 0} + }) + + if not purchase: + raise Exception( + f"Cannot create allocation for cluster '{clustername}': " + f"Facility '{facility_name}' has not purchased compute resources on this cluster. " + f"Please contact your facility administrator to purchase resources first." + ) rc["clustername"] = clustername rc["start"] = repocompute.start.astimezone(pytz.utc) From 3b16926d9c4c7dadc829980ff904f8eac2c178db Mon Sep 17 00:00:00 2001 From: Ryan Waldheim Date: Mon, 15 Jun 2026 11:43:04 -0700 Subject: [PATCH 2/2] update message --- schema.py | 1 - 1 file changed, 1 deletion(-) diff --git a/schema.py b/schema.py index babb1b0..59d4de1 100644 --- a/schema.py +++ b/schema.py @@ -1293,7 +1293,6 @@ def repoComputeAllocationUpsert(self, repo: RepoInput, repocompute: RepoComputeA raise Exception( f"Cannot create allocation for cluster '{clustername}': " f"Facility '{facility_name}' has not purchased compute resources on this cluster. " - f"Please contact your facility administrator to purchase resources first." ) rc["clustername"] = clustername