From 2983ff52879e86b2d7f346ed1c8e869977dbdc75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Cordier?= Date: Fri, 12 May 2023 15:18:59 +0200 Subject: [PATCH 1/2] disable contribute and finalize when callback is filled --- .../java/com/iexec/core/workflow/ReplicateWorkflow.java | 4 +++- .../com/iexec/core/workflow/ReplicateWorkflowTests.java | 9 +++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/iexec/core/workflow/ReplicateWorkflow.java b/src/main/java/com/iexec/core/workflow/ReplicateWorkflow.java index 60f955ef6..ca0ac07fb 100644 --- a/src/main/java/com/iexec/core/workflow/ReplicateWorkflow.java +++ b/src/main/java/com/iexec/core/workflow/ReplicateWorkflow.java @@ -21,6 +21,7 @@ import com.iexec.commons.poco.notification.TaskNotificationType; import com.iexec.commons.poco.task.TaskDescription; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import java.util.Arrays; import java.util.LinkedHashMap; @@ -195,7 +196,8 @@ TaskNotificationType getNextActionWhenStatusAndCause(ReplicateStatus whenStatus, log.error("TaskDescription is null with a COMPUTED status, this case shouldn't happen"); return PLEASE_ABORT; } - if (taskDescription.isTeeTask()) { + // We must check CallBack is empty because there is an issue in poco (transaction is revert) + if (taskDescription.isTeeTask() && StringUtils.isEmpty(taskDescription.getCallback())) { return PLEASE_CONTRIBUTE_AND_FINALIZE; } } diff --git a/src/test/java/com/iexec/core/workflow/ReplicateWorkflowTests.java b/src/test/java/com/iexec/core/workflow/ReplicateWorkflowTests.java index 89f98263e..d311063cb 100644 --- a/src/test/java/com/iexec/core/workflow/ReplicateWorkflowTests.java +++ b/src/test/java/com/iexec/core/workflow/ReplicateWorkflowTests.java @@ -187,6 +187,15 @@ void shouldGetNextActionOnComputedWithoutTaskDescriptionShouldBePleaseAbort(){ .isEqualTo(PLEASE_ABORT); } + @Test + void shouldGetNextActionOnComputedWithTeeTaskAndCallBackShouldBePlease(){ + assertThat(replicateWorkflow + .getNextAction(COMPUTED, + null, + TaskDescription.builder().isTeeTask(true).callback("callback").build())) + .isEqualTo(PLEASE_CONTRIBUTE); + } + // endregion /* From e624e2ae09939bcaca6189ce2054196ef03c1410 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Cordier?= Date: Fri, 12 May 2023 16:09:39 +0200 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f382c0920..e5210e618 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ All notable changes to this project will be documented in this file. - Add ContributeAndFinalize to `ReplicateWorkflow`. (#574) - Add check for ContributeAndFinalize in `ReplicatesService`. (#576) - Add `running2Finalized2Completed` in `TaskUpdateManager`. (#577 #578) +- Disable `contributeAndFinalize` with CallBack. (#579) ### Bug Fixes - Prevent race condition on replicate update. (#568) ### Quality