Skip to content

Commit

Permalink
Merge pull request #24 from iExecBlockchainComputing/release/1.1.0
Browse files Browse the repository at this point in the history
Release/1.1.0
  • Loading branch information
jbern0rd authored Sep 26, 2023
2 parents 3ed9762 + 7eb2a67 commit c859e3e
Show file tree
Hide file tree
Showing 19 changed files with 324 additions and 170 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@

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

## [[1.1.0]](https://github.com/iExecBlockchainComputing/iexec-commons-containers/releases/tag/v1.1.0) 2023-09-26

### New Features
- Move `ArgsUtils`, `SgxDriverMode` and `SgxUtils` classes from `iexec-common`. (#14)
### Bug Fixes
- Add missing `lombok.config` file. (#15)
- Use official `/dev/sgx_enclave` and `/dev/sgx_provision` devices. (#23)
### Quality
- Replace deprecated `ExecStartResultCallback` with `ResultCallback.Adapter` in `DockerClientInstance`. (#17)
- Upgrade to Gradle 8.2.1 with up-to-date plugins. (#19)
- Properly handle `InterruptedException` instances in `DockerClientInstance`. (#20)
- Several quality fixes (assertions, code smells, TODOs). (#21)
### Dependency Upgrades
- Add `maven-shared-utils:3.4.2` dependency. (#14)
- Remove `iexec-common` dependency. (#16)
- Upgrade to Spring Boot 2.7.14. (#18)
- Upgrade to `jenkins-library` 2.7.3. (#22)

## [[1.0.3]](https://github.com/iExecBlockchainComputing/iexec-commons-containers/releases/tag/v1.0.3) 2023-06-23

### Dependency Upgrades
Expand Down
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@Library('global-jenkins-library@2.2.3') _
@Library('global-jenkins-library@2.7.3') _
buildJavaProject(
buildInfo: getBuildInfo(),
integrationTestsEnvVars: [],
Expand Down
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,13 @@
# iexec-commons-containers
A Java library for handling containers

A Java library for handling containers.

## Overview

This repository is used in the [_iExec Worker_](https://github.com/iExecBlockchainComputing/iexec-worker).
It provides an API to manage Docker containers through the [_docker-java_](https://github.com/docker-java/docker-java/)
Java API client.

## License

This repository code is released under the [Apache License 2.0](LICENSE).
25 changes: 11 additions & 14 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
plugins {
id 'java-library'
id 'jacoco'
id 'org.sonarqube' version '3.3'
id 'org.sonarqube' version '4.2.1.3168'
id 'maven-publish'
id 'io.freefair.lombok' version '6.6.1'
id 'io.freefair.lombok' version '8.2.2'
}

group = 'com.iexec.commons'
Expand All @@ -28,38 +28,38 @@ repositories {
password nexusPassword
}
}
maven {
url 'https://jitpack.io'
}
}

// java-library plugin defines 'api' configuration
// 'api' configuration allows to expose dependencies with 'compile' scope in pom
// 'implementation' configuration allows to expose dependencies with 'runtime' scope in pom
dependencies {
implementation platform('org.springframework.boot:spring-boot-dependencies:2.6.14')

// iexec
implementation "com.iexec.common:iexec-common:$iexecCommonVersion"
implementation platform('org.springframework.boot:spring-boot-dependencies:2.7.14')

// docker
implementation "com.github.docker-java:docker-java:${dockerJavaVersion}"
// Using zerodep until docker client stops blocking after having called
// listContainersCmd() over httpclient5
implementation "com.github.docker-java:docker-java-transport-zerodep:${dockerJavaVersion}"

// apache commons.lang3
// apache commons-lang3
implementation 'org.apache.commons:commons-lang3:3.12.0'

// args utils
implementation 'org.apache.maven.shared:maven-shared-utils:3.4.2'

// tests
testImplementation 'org.junit.jupiter:junit-jupiter'
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
testImplementation 'org.mockito:mockito-junit-jupiter'
testImplementation 'org.assertj:assertj-core'
// spring-boot-test to capture test outputs
testImplementation 'org.springframework.boot:spring-boot-test'
// spring-test for ReflectionTestUtils
testImplementation 'org.springframework:spring-test'
testImplementation 'org.awaitility:awaitility'
// logback
testRuntimeOnly 'ch.qos.logback:logback-classic'
}

java {
Expand All @@ -86,14 +86,11 @@ test {
}
}

task itest {
tasks.register('itest') {
group 'Verification'
description 'Runs the integration tests.'
}

jacoco {
toolVersion = '0.8.7'
}
// sonarqube code coverage requires jacoco XML report
jacocoTestReport {
reports {
Expand Down
3 changes: 1 addition & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
version=1.0.3
iexecCommonVersion=8.2.1
version=1.1.0

nexusUser
nexusPassword
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
16 changes: 10 additions & 6 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,6 @@ done
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum

Expand Down Expand Up @@ -133,26 +130,29 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi

# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -197,6 +197,10 @@ if "$cygwin" || "$msys" ; then
done
fi


# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
Expand Down
3 changes: 3 additions & 0 deletions lombok.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# This file is generated by the 'io.freefair.lombok' Gradle plugin
config.stopBubbling = true
lombok.addLombokGeneratedAnnotation = true
40 changes: 40 additions & 0 deletions src/main/java/com/iexec/commons/containers/ArgsUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright 2020-2023 IEXEC BLOCKCHAIN TECH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.iexec.commons.containers;

import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.maven.shared.utils.cli.CommandLineException;
import org.apache.maven.shared.utils.cli.CommandLineUtils;

@Slf4j
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class ArgsUtils {
/*
* stringArgsToArrayArgs("1st_param 2nd_param '3rd param' \"4th param\"") gives
* ["1st_param", "2nd_param", "3rd param", "4th param"]
* */
public static String[] stringArgsToArrayArgs(String args) {
try {
return CommandLineUtils.translateCommandline(args);
} catch (CommandLineException e) {
log.error("Failed to translate string args to array [args:{}]", args);
}
return new String[0];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
package com.iexec.commons.containers;

import com.github.dockerjava.api.model.Device;
import com.iexec.common.sgx.SgxDriverMode;
import com.iexec.common.utils.ArgsUtils;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
Expand Down
47 changes: 47 additions & 0 deletions src/main/java/com/iexec/commons/containers/SgxDriverMode.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright 2022-2023 IEXEC BLOCKCHAIN TECH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.iexec.commons.containers;

import javax.annotation.Nonnull;

public enum SgxDriverMode {
NONE(),
LEGACY("/dev/isgx"),
NATIVE("/dev/sgx_enclave", "/dev/sgx_provision");

private final String[] devices;

SgxDriverMode(String... driverNames) {
this.devices = driverNames;
}

public String[] getDevices() {
return devices;
}

/**
* Returns {@literal false} if given {@link SgxDriverMode} is {@literal null}
* or {@link SgxDriverMode#NONE}, {@literal true} otherwise.
*
* @param driverMode {@link SgxDriverMode} object to check.
* @return {@literal false} if given {@link SgxDriverMode} is {@literal null}
* or {@link SgxDriverMode#NONE}, {@literal true} otherwise.
*/
public static boolean isDriverModeNotNone(@Nonnull SgxDriverMode driverMode) {
return driverMode != NONE;
}
}
27 changes: 27 additions & 0 deletions src/main/java/com/iexec/commons/containers/SgxUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright 2021-2023 IEXEC BLOCKCHAIN TECH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.iexec.commons.containers;

import lombok.AccessLevel;
import lombok.NoArgsConstructor;

@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class SgxUtils {
public static final String SGX_CGROUP_PERMISSIONS = "rwm";
public static final String LEGACY_SGX_DRIVER_PATH = "/sys/module/isgx/version";

}
Loading

0 comments on commit c859e3e

Please sign in to comment.