Skip to content

Commit ae90fc7

Browse files
authored
Merge pull request #585 from iExecBlockchainComputing/release/8.4.0
Release/8.4.0
2 parents 622851b + 06a455f commit ae90fc7

21 files changed

+737
-499
lines changed

CHANGELOG.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,27 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
## [[8.4.0]](https://github.com/iExecBlockchainComputing/iexec-worker/releases/tag/v8.4.0) 2024-02-29
6+
7+
### New Features
8+
9+
- Retrieve Result Proxy JWT with `WorkerpoolAuthorization`. (#581)
10+
- Push Result Proxy JWT for IPFS to SMS. (#582)
11+
12+
### Quality
13+
14+
- `SconeConfiguration` class becomes immutable. (#577)
15+
- Fix `onTaskNotification` visibility and lower its complexity. (#578)
16+
- Throw a dedicated exception on empty parameters when authenticating to a docker registry. (#579)
17+
- Check replicate recoverability wih a dedicated check in `ReplicateRecoveryService`. (#580)
18+
19+
### Dependency Upgrades
20+
21+
- Upgrade to `iexec-common` 8.4.0. (#583)
22+
- Upgrade to `iexec-blockchain-adapter` 8.4.0. (#584)
23+
- Upgrade to `iexec-result-proxy` 8.4.0. (#584)
24+
- Upgrade to `iexec-sms` 8.5.0. (#584)
25+
526
## [[8.3.0]](https://github.com/iExecBlockchainComputing/iexec-worker/releases/tag/v8.3.0) 2024-01-11
627

728
### New Features

gradle.properties

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
version=8.3.0
2-
iexecCommonVersion=8.3.1
1+
version=8.4.0
2+
iexecCommonVersion=8.4.0
33
iexecCommonsContainersVersion=1.2.1
44
iexecCommonsPocoVersion=3.2.0
5-
iexecBlockchainAdapterVersion=8.3.0
6-
iexecResultVersion=8.3.0
7-
iexecSmsVersion=8.4.0
5+
iexecBlockchainAdapterVersion=8.4.0
6+
iexecResultVersion=8.4.0
7+
iexecSmsVersion=8.5.0
88

99
nexusUser
1010
nexusPassword

src/main/java/com/iexec/worker/Application.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020 IEXEC BLOCKCHAIN TECH
2+
* Copyright 2020-2024 IEXEC BLOCKCHAIN TECH
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -29,18 +29,19 @@
2929
import org.springframework.boot.CommandLineRunner;
3030
import org.springframework.boot.SpringApplication;
3131
import org.springframework.boot.autoconfigure.SpringBootApplication;
32+
import org.springframework.boot.context.properties.ConfigurationPropertiesScan;
3233
import org.springframework.cloud.openfeign.EnableFeignClients;
3334
import org.springframework.retry.annotation.EnableRetry;
3435
import org.springframework.scheduling.annotation.EnableAsync;
3536

3637
import java.util.List;
3738

38-
39-
@SpringBootApplication
40-
@EnableFeignClients
39+
@Slf4j
4140
@EnableRetry
4241
@EnableAsync
43-
@Slf4j
42+
@EnableFeignClients
43+
@SpringBootApplication
44+
@ConfigurationPropertiesScan
4445
public class Application implements CommandLineRunner {
4546

4647
@Autowired

src/main/java/com/iexec/worker/compute/ComputeManagerService.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2023 IEXEC BLOCKCHAIN TECH
2+
* Copyright 2020-2024 IEXEC BLOCKCHAIN TECH
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -41,7 +41,7 @@
4141
import java.time.temporal.ChronoUnit;
4242
import java.util.HashMap;
4343
import java.util.Map;
44-
44+
import java.util.function.Predicate;
4545

4646
@Slf4j
4747
@Service
@@ -225,4 +225,11 @@ public PostComputeResponse runPostCompute(TaskDescription taskDescription,
225225
return postComputeResponse;
226226
}
227227

228+
public boolean abort(String chainTaskId) {
229+
Predicate<String> containsChainTaskId = name -> name.contains(chainTaskId);
230+
long remaining = dockerService.stopRunningContainersWithNamePredicate(containsChainTaskId);
231+
log.info("Stopped task containers [chainTaskId:{}, remaining:{}]", chainTaskId, remaining);
232+
return remaining == 0L;
233+
}
234+
228235
}

src/main/java/com/iexec/worker/docker/DockerService.java

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2023 IEXEC BLOCKCHAIN TECH
2+
* Copyright 2020-2024 IEXEC BLOCKCHAIN TECH
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -74,7 +74,7 @@ public DockerClientInstance getClient() {
7474
* <p>
7575
* e.g. for the image "registry.xyz/image:tag" we try to connect to
7676
* "registry.xyz" and for "iexechub/image:tag" we try to connect to docker.io.
77-
*
77+
*
7878
* @param imageName
7979
* @return an authenticated Docker client if credentials for the image's registry are
8080
* to be found, an unauthenticated client otherwise.
@@ -99,21 +99,20 @@ public DockerClientInstance getClient(String imageName) {
9999

100100
/**
101101
* Get a Docker client that is authenticated to the specified registry.
102-
*
103-
* @param registryAddress
104-
* @param registryUsername
105-
* @param registryPassword
106-
* @return
107-
* @throws Exception when on of the arguments is blank or when authentication fails
102+
*
103+
* @param registryAddress Registry address
104+
* @param registryUsername Username to authenticate on the registry
105+
* @param registryPassword Password to authenticate on the registry
106+
* @return An authenticated client
108107
*/
109108
public DockerClientInstance getClient(String registryAddress,
110109
String registryUsername,
111-
String registryPassword) throws Exception {
110+
String registryPassword) {
112111
if (StringUtils.isBlank(registryAddress) || StringUtils.isBlank(registryUsername)
113112
|| StringUtils.isBlank(registryPassword)) {
114113
log.error("Registry parameters are required [registry:{}, username:{}]",
115114
registryAddress, registryUsername);
116-
throw new Exception("All Docker registry parameters must be provided: "
115+
throw new IllegalArgumentException("All Docker registry parameters must be provided: "
117116
+ registryAddress);
118117
}
119118
return DockerClientFactory.getDockerClientInstance(
@@ -208,23 +207,25 @@ public void stopAllRunningContainers() {
208207
* the worker aborts a task and needs to stop its pre-compute, compute, or
209208
* post-compute containers. The container itself is not removed here as it is
210209
* removed by its watcher thread.
211-
*
210+
*
212211
* @param containerNamePredicate predicate that contains a condition on the
213212
* container name.
213+
* @return The remaining count of containers matching the provided predicate.
214214
*/
215-
public void stopRunningContainersWithNamePredicate(Predicate<String> containerNamePredicate) {
215+
public long stopRunningContainersWithNamePredicate(Predicate<String> containerNamePredicate) {
216216
log.info("Stopping containers with names matching the provided predicate");
217217
List.copyOf(runningContainersRecord).stream()
218218
.filter(containerNamePredicate)
219219
.forEach(this::stopRunningContainer);
220+
return List.copyOf(runningContainersRecord).stream()
221+
.filter(containerNamePredicate).count();
220222
}
221223

222224
/**
223-
* Stop a running container with the provided containerName and remove it from
224-
* running containers record. The container itself is not stopped here as it is
225-
* removed by its watcher thread.
226-
*
227-
* @param containerName
225+
* Stop a running container with the provided name and remove it from the running containers record.
226+
* The container itself is not stopped here as it is removed by its watcher thread.
227+
*
228+
* @param containerName Name of container to stop
228229
*/
229230
void stopRunningContainer(String containerName) {
230231
if (!getClient().isContainerPresent(containerName)) {
@@ -244,8 +245,8 @@ void stopRunningContainer(String containerName) {
244245

245246
/**
246247
* Get the record of running containers. Added originally for testing purposes.
247-
*
248-
* @return
248+
*
249+
* @return The current set of running containers
249250
*/
250251
Set<String> getRunningContainersRecord() {
251252
return runningContainersRecord;

src/main/java/com/iexec/worker/executor/TaskManagerService.java

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2023 IEXEC BLOCKCHAIN TECH
2+
* Copyright 2020-2024 IEXEC BLOCKCHAIN TECH
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -32,9 +32,9 @@
3232
import com.iexec.worker.compute.post.PostComputeResponse;
3333
import com.iexec.worker.compute.pre.PreComputeResponse;
3434
import com.iexec.worker.dataset.DataService;
35-
import com.iexec.worker.docker.DockerService;
3635
import com.iexec.worker.pubsub.SubscriptionService;
3736
import com.iexec.worker.result.ResultService;
37+
import com.iexec.worker.sms.SmsService;
3838
import com.iexec.worker.tee.TeeService;
3939
import com.iexec.worker.tee.TeeServicesManager;
4040
import com.iexec.worker.utils.LoggingUtils;
@@ -43,14 +43,12 @@
4343
import org.springframework.stereotype.Service;
4444

4545
import java.util.Optional;
46-
import java.util.function.Predicate;
4746

4847
import static com.iexec.common.replicate.ReplicateStatus.APP_DOWNLOAD_FAILED;
4948
import static com.iexec.common.replicate.ReplicateStatus.DATA_DOWNLOAD_FAILED;
5049
import static com.iexec.common.replicate.ReplicateStatusCause.*;
5150
import static java.util.Objects.requireNonNull;
5251

53-
5452
@Slf4j
5553
@Service
5654
public class TaskManagerService {
@@ -65,7 +63,7 @@ public class TaskManagerService {
6563
private final TeeServicesManager teeServicesManager;
6664
private final DataService dataService;
6765
private final ResultService resultService;
68-
private final DockerService dockerService;
66+
private final SmsService smsService;
6967
private final SubscriptionService subscriptionService;
7068
private final PurgeService purgeService;
7169
private final String workerWalletAddress;
@@ -78,7 +76,7 @@ public TaskManagerService(
7876
TeeServicesManager teeServicesManager,
7977
DataService dataService,
8078
ResultService resultService,
81-
DockerService dockerService,
79+
SmsService smsService,
8280
SubscriptionService subscriptionService,
8381
PurgeService purgeService,
8482
String workerWalletAddress) {
@@ -89,7 +87,7 @@ public TaskManagerService(
8987
this.teeServicesManager = teeServicesManager;
9088
this.dataService = dataService;
9189
this.resultService = resultService;
92-
this.dockerService = dockerService;
90+
this.smsService = smsService;
9391
this.subscriptionService = subscriptionService;
9492
this.purgeService = purgeService;
9593
this.workerWalletAddress = workerWalletAddress;
@@ -121,7 +119,12 @@ ReplicateActionResponse start(TaskDescription taskDescription) {
121119
log.error("TEE prerequisites are not met [chainTaskId: {}, issue: {}]", chainTaskId, teePrerequisitesIssue.get());
122120
return getFailureResponseAndPrintError(teePrerequisitesIssue.get(), context, chainTaskId);
123121
}
122+
123+
final WorkerpoolAuthorization workerpoolAuthorization = contributionService.getWorkerpoolAuthorization(chainTaskId);
124+
final String token = resultService.getIexecUploadToken(workerpoolAuthorization);
125+
smsService.pushToken(workerpoolAuthorization, token);
124126
}
127+
125128
return ReplicateActionResponse.success();
126129
}
127130

@@ -342,8 +345,9 @@ private ReplicateActionResponse contributeOrContributeAndFinalize(String chainTa
342345
context, chainTaskId);
343346
}
344347

348+
final WorkerpoolAuthorization workerpoolAuthorization = contributionService.getWorkerpoolAuthorization(chainTaskId);
345349
String callbackData = computedFile.getCallbackData();
346-
String resultLink = resultService.uploadResultAndGetLink(chainTaskId);
350+
String resultLink = resultService.uploadResultAndGetLink(workerpoolAuthorization);
347351
log.debug("contributeAndFinalize [contribution:{}, resultLink:{}, callbackData:{}]",
348352
contribution, resultLink, callbackData);
349353
Optional<ChainReceipt> oChainReceipt = iexecHubService.contributeAndFinalize(contribution, resultLink, callbackData);
@@ -418,16 +422,16 @@ ReplicateActionResponse reveal(String chainTaskId,
418422
}
419423

420424
ReplicateActionResponse uploadResult(String chainTaskId) {
421-
String resultLink = resultService.uploadResultAndGetLink(chainTaskId);
425+
final WorkerpoolAuthorization workerpoolAuthorization = contributionService.getWorkerpoolAuthorization(chainTaskId);
426+
String resultLink = resultService.uploadResultAndGetLink(workerpoolAuthorization);
422427
String context = "upload result";
423428
if (resultLink.isEmpty()) {
424429
return getFailureResponseAndPrintError(RESULT_LINK_MISSING,
425430
context, chainTaskId
426431
);
427432
}
428433

429-
ComputedFile computedFile =
430-
resultService.getComputedFile(chainTaskId);
434+
ComputedFile computedFile = resultService.getComputedFile(chainTaskId);
431435
String callbackData = computedFile != null ?
432436
computedFile.getCallbackData() : "";
433437

@@ -456,18 +460,18 @@ ReplicateActionResponse complete(String chainTaskId) {
456460
* related to the task in question, unsubscribe from the task's notifications,
457461
* then remove result folders.
458462
*
459-
* @param chainTaskId
460-
* @return
463+
* @param chainTaskId Task ID
464+
* @return {@literal true} if all cleanup operations went well, {@literal false} otherwise
461465
*/
462466
boolean abort(String chainTaskId) {
463467
log.info("Aborting task [chainTaskId:{}]", chainTaskId);
464-
Predicate<String> containsChainTaskId = name -> name.contains(chainTaskId);
465-
dockerService.stopRunningContainersWithNamePredicate(containsChainTaskId);
466-
log.info("Stopped task containers [chainTaskId:{}]", chainTaskId);
467468
subscriptionService.unsubscribeFromTopic(chainTaskId);
468-
boolean isSuccess = purgeService.purgeAllServices(chainTaskId);
469+
boolean allContainersStopped = computeManagerService.abort(chainTaskId);
470+
boolean allServicesPurged = purgeService.purgeAllServices(chainTaskId);
471+
final boolean isSuccess = allContainersStopped && allServicesPurged;
469472
if (!isSuccess) {
470-
log.error("Failed to abort task [chainTaskId:{}]", chainTaskId);
473+
log.error("Failed to abort task [chainTaskId:{}, containers:{}, services:{}]",
474+
chainTaskId, allContainersStopped, allServicesPurged);
471475
}
472476
return isSuccess;
473477
}

0 commit comments

Comments
 (0)