Skip to content

Commit 835f252

Browse files
authored
[Fixes #13621] UPSERT failure leaves task payload in PENDING (#13622)
* Set the correct status instead of PENDING * Fixing test
1 parent 70e8e0e commit 835f252

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

geonode/upload/celery_tasks.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -962,6 +962,9 @@ def upsert_data(self, execution_id, /, handler_module_path, action, **kwargs):
962962
layer_name = None # ensure defined even if an exception occurs
963963
# Updating status to running
964964
try:
965+
# we set the bulk is True to force the on_failure/on_success methods
966+
# to set the corresponding status in case the task fails before the layer_name creation
967+
self.bulk = True
965968
kwargs = kwargs.get("kwargs") if "kwargs" in kwargs else kwargs
966969

967970
orchestrator.update_execution_request_status(

geonode/upload/datastore.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def upsert_data(self, execution_id, task_name, **kwargs):
9696
result = self.handler().upsert_data(self.files, execution_id, **kwargs)
9797

9898
# register the task as RUNNING
99-
layer_name = result.pop("layer_name", None)
99+
layer_name = result.get("layer_name", None)
100100

101101
orchestrator.register_task_status(execution_id, layer_name, task_name, status="RUNNING")
102102

geonode/upload/tests/end2end/test_env2end_upsert.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ def test_import_shapefile_upsert(self):
215215
"update": 1,
216216
"create": 2,
217217
},
218+
"layer_name": "original",
218219
}
219220
self.assertDictEqual(expected, data)
220221
schema = ModelSchema.objects.filter(name=exec_obj.geonode_resource.alternate.split(":")[-1]).first()

0 commit comments

Comments
 (0)