Skip to content

Commit dac763d

Browse files
authored
Don't save a task again if API can't run it (#813)
1 parent 93dadf9 commit dac763d

1 file changed

Lines changed: 62 additions & 8 deletions

File tree

images/assets/patches/0033-Adds-use-of-NewPulpcoreWorker-from-pulp_service.patch

Lines changed: 62 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
From f721dcadf3fd422743f7ee83b5e36ef8ca6fd197 Mon Sep 17 00:00:00 2001
22
From: Dennis Kliban <dkliban@redhat.com>
33
Date: Tue, 25 Nov 2025 11:06:48 -0500
4-
Subject: [PATCH 1/8] Adds use of NewPulpcoreWorker from pulp_service.
4+
Subject: [PATCH 1/9] Adds use of NewPulpcoreWorker from pulp_service.
55

66
This also adds Redis based locking for tasks and resources.
77
---
@@ -570,7 +570,7 @@ index c187bd919..3ef86ba19 100644
570570
From 6ac2f55c2aae9ee53da0d5f4cac4384bff84feb7 Mon Sep 17 00:00:00 2001
571571
From: Dennis Kliban <dkliban@redhat.com>
572572
Date: Fri, 12 Dec 2025 21:27:32 -0500
573-
Subject: [PATCH 2/8] fix releasing of locks for immediate tasks
573+
Subject: [PATCH 2/9] fix releasing of locks for immediate tasks
574574

575575
---
576576
pulpcore/tasking/tasks.py | 94 ++++++++++++++++++++++++++++++++++++---
@@ -727,7 +727,7 @@ index 3ef86ba19..6b7466980 100644
727727
From e70783f2bc64a99dda25c829ff133a0d059585e2 Mon Sep 17 00:00:00 2001
728728
From: Dennis Kliban <dkliban@redhat.com>
729729
Date: Fri, 12 Dec 2025 21:51:11 -0500
730-
Subject: [PATCH 3/8] Release locks in execute task
730+
Subject: [PATCH 3/9] Release locks in execute task
731731

732732
---
733733
pulpcore/tasking/tasks.py | 66 ++++++++++++---------------------------
@@ -828,7 +828,7 @@ index 6b7466980..9e9e6f6d7 100644
828828
From 75f249190eeef4acbae366bb2b5392d01643e41a Mon Sep 17 00:00:00 2001
829829
From: Dennis Kliban <dkliban@redhat.com>
830830
Date: Sat, 13 Dec 2025 05:46:49 -0500
831-
Subject: [PATCH 4/8] Make sure locks are released even if exceptions occur
831+
Subject: [PATCH 4/9] Make sure locks are released even if exceptions occur
832832
outside of execute_task.
833833

834834
---
@@ -932,7 +932,7 @@ index 9e9e6f6d7..2d854099c 100644
932932
From ab0cd196500334388f63087714bdb6b235ef7c50 Mon Sep 17 00:00:00 2001
933933
From: Dennis Kliban <dkliban@redhat.com>
934934
Date: Fri, 19 Dec 2025 14:26:52 -0500
935-
Subject: [PATCH 5/8] API workers acquire Task lock before executing task
935+
Subject: [PATCH 5/9] API workers acquire Task lock before executing task
936936

937937
---
938938
pulpcore/tasking/tasks.py | 142 +++++++++++++++++++++++++++-----------
@@ -1113,7 +1113,7 @@ index 2d854099c..3e7ee72d6 100644
11131113
From 5b024ec6e69c53ca897b2697507c0af1b1b70c83 Mon Sep 17 00:00:00 2001
11141114
From: Dennis Kliban <dkliban@redhat.com>
11151115
Date: Fri, 19 Dec 2025 14:59:28 -0500
1116-
Subject: [PATCH 6/8] Improve logging for resource lock release
1116+
Subject: [PATCH 6/9] Improve logging for resource lock release
11171117

11181118
---
11191119
pulpcore/tasking/tasks.py | 10 +++++++---
@@ -1173,7 +1173,7 @@ index 3e7ee72d6..a9e5c4885 100644
11731173
From d384eecf3d640cfb800a8aa7a80f1847b0d87ac1 Mon Sep 17 00:00:00 2001
11741174
From: Dennis Kliban <dkliban@redhat.com>
11751175
Date: Fri, 19 Dec 2025 21:23:28 -0500
1176-
Subject: [PATCH 7/8] Revert the set_guid() in immediate tasks
1176+
Subject: [PATCH 7/9] Revert the set_guid() in immediate tasks
11771177

11781178
---
11791179
pulpcore/tasking/tasks.py | 6 +-----
@@ -1217,7 +1217,7 @@ index a9e5c4885..23a3641ad 100644
12171217
From 46c224559161991c4ae29a537e94065acd18e73b Mon Sep 17 00:00:00 2001
12181218
From: Dennis Kliban <dkliban@redhat.com>
12191219
Date: Fri, 19 Dec 2025 23:00:16 -0500
1220-
Subject: [PATCH 8/8] Log task state after setting to running.
1220+
Subject: [PATCH 8/9] Log task state after setting to running.
12211221

12221222
---
12231223
pulpcore/tasking/tasks.py | 16 ++++++++++++++++
@@ -1260,3 +1260,57 @@ index 23a3641ad..e52be163d 100644
12601260
--
12611261
2.52.0
12621262

1263+
1264+
From 24f1d953a03bf7145e506fbcbabd920f822fead7 Mon Sep 17 00:00:00 2001
1265+
From: Dennis Kliban <dkliban@redhat.com>
1266+
Date: Sun, 21 Dec 2025 07:53:12 -0500
1267+
Subject: [PATCH 9/9] Don't save immediate Tasks a second time when resources
1268+
are not available
1269+
1270+
---
1271+
pulpcore/tasking/tasks.py | 8 --------
1272+
1 file changed, 8 deletions(-)
1273+
1274+
diff --git a/pulpcore/tasking/tasks.py b/pulpcore/tasking/tasks.py
1275+
index e52be163d..8725c3055 100644
1276+
--- a/pulpcore/tasking/tasks.py
1277+
+++ b/pulpcore/tasking/tasks.py
1278+
@@ -398,8 +398,6 @@ def dispatch(
1279+
"IMMEDIATE DISPATCH: Task %s resources not available, released task lock and deferring to worker",
1280+
task.pk
1281+
)
1282+
- task.app_lock = None
1283+
- task.save()
1284+
else:
1285+
# Resources not available and can't be deferred
1286+
redis_conn.delete(task_lock_key)
1287+
@@ -411,8 +409,6 @@ def dispatch(
1288+
"IMMEDIATE DISPATCH: Task %s could not acquire task lock, deferring to worker",
1289+
task.pk
1290+
)
1291+
- task.app_lock = None
1292+
- task.save()
1293+
else:
1294+
# Can't acquire task lock and can't be deferred
1295+
task.set_canceling()
1296+
@@ -483,8 +479,6 @@ async def adispatch(
1297+
"IMMEDIATE DISPATCH (async): Task %s resources not available, released task lock and deferring to worker",
1298+
task.pk
1299+
)
1300+
- task.app_lock = None
1301+
- await task.asave()
1302+
else:
1303+
# Resources not available and can't be deferred
1304+
redis_conn.delete(task_lock_key)
1305+
@@ -496,8 +490,6 @@ async def adispatch(
1306+
"IMMEDIATE DISPATCH (async): Task %s could not acquire task lock, deferring to worker",
1307+
task.pk
1308+
)
1309+
- task.app_lock = None
1310+
- await task.asave()
1311+
else:
1312+
# Can't acquire task lock and can't be deferred
1313+
task.set_canceling()
1314+
--
1315+
2.52.0
1316+

0 commit comments

Comments
 (0)