-
Notifications
You must be signed in to change notification settings - Fork 566
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CRaC POC #5616
Closed
Closed
CRaC POC #5616
Changes from 4 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
f8880cd
POC
danielkec e1a05b0
CRaC POC
danielkec 00df07c
Workaround for: Error (criu/cr-dump.c:203): 18 has rseq but kernel la…
danielkec dc26e26
Cleanup
danielkec f184291
Minikube example
danielkec 475e906
CRaC K8s POC
danielkec 5e22b6b
CRaC K8s POC
danielkec 1415b0d
Client tracing interceptor no longer clears exception (#5601)
Verdent 10e4d9c
5496 flatMapCompletionStage javadoc fix (#5622)
danielkec aa2c94e
Update owasp dependency-check version. Add fp suppressions. Remove ol…
barchetta 62e554f
Use Hamcrest assertions instead of JUnit in tests/functional/jax-rs-m…
Captain1653 56fc41e
WebServer.Builder media support methods with Supplier variants (#5632)
aserkes f811986
[3.x] Various metrics test improvements to avoid intermittent failure…
tjquinno 3e76f64
Adding feature file for MP native image. (#5652)
tomas-langer e582e0b
Native image
danielkec a27e5fb
Startup time measurement
danielkec File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# | ||
# Copyright (c) 2022 Oracle and/or its affiliates. | ||
# | ||
# 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. | ||
# | ||
|
||
|
||
# TODO: docker buildx with priviledged access? - https://docs.docker.com/engine/reference/commandline/buildx_build/#allow |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# | ||
# Copyright (c) 2022 Oracle and/or its affiliates. | ||
# | ||
# 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. | ||
# | ||
|
||
# TODO: native image for comparison |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# | ||
# Copyright (c) 2022 Oracle and/or its affiliates. | ||
# | ||
# 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. | ||
# | ||
FROM ubuntu:22.04 as ubuntu-crac | ||
|
||
WORKDIR /usr/share | ||
|
||
ENV CRAC_ARTEFACT=openjdk-17-crac+3_linux-x64 | ||
ENV JAVA_HOME=/usr/share/$CRAC_ARTEFACT | ||
|
||
# Install CRaC | ||
RUN apt-get -qq update && apt-get install -y wget \ | ||
&& wget -q https://github.com/CRaC/openjdk-builds/releases/download/17-crac%2B3/$CRAC_ARTEFACT.tar.gz \ | ||
&& tar zxf $CRAC_ARTEFACT.tar.gz \ | ||
&& ln -s $JAVA_HOME/bin/java /bin/ | ||
|
||
FROM ubuntu-crac | ||
WORKDIR /helidon | ||
|
||
ADD target/*.jar . | ||
ADD target/libs libs | ||
ADD runtimeCRaC.sh . | ||
RUN chmod +x ./runtimeCRaC.sh | ||
|
||
ENTRYPOINT ["./runtimeCRaC.sh"] | ||
|
||
EXPOSE 7001 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Helidon MP on CRaC | ||
[Coordinated Restore at Checkpoint](https://wiki.openjdk.org/display/crac) | ||
|
||
|
||
## Runtime CRaC | ||
Standard docker build doesn't support privileged access to the host machine kernel, | ||
therefore CRaC checkpoint needs to be created in runtime. | ||
|
||
```bash | ||
mvn clean package | ||
docker build -t crac-runtime-helloworld . -f Dockerfile.runtime_crac | ||
# First time ran, checkpoint is created, stop with Ctrl-C | ||
docker run --privileged -p 7001:7001 --name crac-runtime-helloworld crac-runtime-helloworld | ||
# Second time starting from checkpoint, stop with Ctrl-C | ||
docker start -i crac-runtime-helloworld | ||
``` | ||
|
||
## Buildtime CRaC | ||
Docker buildx ... | ||
|
||
[//]: # (TODO docker buildx with privileged access?) | ||
|
||
### Exercise the app | ||
``` | ||
curl -X GET http://localhost:7001/helloworld | ||
curl -X GET http://localhost:7001/helloworld/earth | ||
curl -X GET http://localhost:7001/another | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
|
||
Copyright (c) 2018, 2022 Oracle and/or its affiliates. | ||
|
||
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. | ||
|
||
--> | ||
|
||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns="http://maven.apache.org/POM/4.0.0" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>io.helidon.applications</groupId> | ||
<artifactId>helidon-mp</artifactId> | ||
<version>3.0.3-SNAPSHOT</version> | ||
<relativePath>../../../applications/mp/pom.xml</relativePath> | ||
</parent> | ||
<groupId>io.helidon.examples.microprofile</groupId> | ||
<artifactId>helidon-examples-microprofile-hello-world-implicit</artifactId> | ||
<name>Helidon Microprofile Examples Implicit Hello World</name> | ||
|
||
<description> | ||
Microprofile example with implicit bootstrapping (cdi.Main(new String[0]) | ||
</description> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.helidon.microprofile.bundles</groupId> | ||
<artifactId>helidon-microprofile</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss</groupId> | ||
<artifactId>jandex</artifactId> | ||
<scope>runtime</scope> | ||
<optional>true</optional> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.helidon.microprofile.tests</groupId> | ||
<artifactId>helidon-microprofile-tests-junit5</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-api</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.hamcrest</groupId> | ||
<artifactId>hamcrest-all</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-dependency-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>copy-libs</id> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/bin/bash -e | ||
|
||
# | ||
# Copyright (c) 2022 Oracle and/or its affiliates. | ||
# | ||
# 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. | ||
# | ||
|
||
if [ ! -d "./cr" ]; | ||
then | ||
echo "==== Creating CRaC checkpoint ====" | ||
echo "=== Checking CRIU compatibility(don't forget --privileged) ===" | ||
$JAVA_HOME/lib/criu check | ||
|
||
echo "=== Checking glibc version ===" | ||
# glibc version higher than 2.34.9000-29 are known to have problems with rseq | ||
# on some kernels, workaround GLIBC_TUNABLES=glibc.pthread.rseq=0 | ||
ldd --version | grep ldd | ||
# Workaround for https://github.com/checkpoint-restore/criu/issues/1696 | ||
# see https://github.com/checkpoint-restore/criu/pull/1706 | ||
export GLIBC_TUNABLES=glibc.pthread.rseq=0 | ||
|
||
echo "=== Pre-starting Helidon MP app ===" | ||
set +e | ||
$JAVA_HOME/bin/java -XX:CRaCCheckpointTo=cr -jar ./*.jar | ||
set -e | ||
|
||
echo "=== CRaC checkpoint created, checking log dump for errors ===" | ||
cat ./cr/dump*.log | grep "Warn\|Err\|succ" | ||
fi | ||
echo "==== Starting directly from CRaC checkpoint ====" | ||
exec $JAVA_HOME/bin/java -XX:CRaCRestoreFrom=cr | ||
|
107 changes: 107 additions & 0 deletions
107
...ac/src/main/java/io/helidon/microprofile/example/helloworld/implicit/AnotherResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
/* | ||
* Copyright (c) 2018,2020 Oracle and/or its affiliates. | ||
* | ||
* 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 io.helidon.microprofile.example.helloworld.implicit; | ||
|
||
import java.net.URI; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
|
||
import jakarta.enterprise.context.RequestScoped; | ||
import jakarta.inject.Inject; | ||
import jakarta.inject.Provider; | ||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
import org.eclipse.microprofile.config.Config; | ||
import org.eclipse.microprofile.config.inject.ConfigProperty; | ||
|
||
/** | ||
* Resource showing all possible configuration injections. | ||
*/ | ||
@Path("another") | ||
@RequestScoped | ||
public class AnotherResource { | ||
@Inject | ||
@ConfigProperty(name = "app.nonExistent", defaultValue = "145") | ||
private int defaultValue; | ||
|
||
@Inject | ||
@ConfigProperty(name = "app.nonExistent") | ||
private Optional<String> empty; | ||
|
||
@Inject | ||
@ConfigProperty(name = "app.uri") | ||
private Optional<URI> full; | ||
|
||
@Inject | ||
@ConfigProperty(name = "app.someInt") | ||
private Provider<Integer> provider; | ||
|
||
@Inject | ||
@ConfigProperty(name = "app.ints") | ||
private List<Integer> ints; | ||
|
||
@Inject | ||
@ConfigProperty(name = "app.ints") | ||
private Optional<List<Integer>> optionalInts; | ||
|
||
@Inject | ||
@ConfigProperty(name = "app.ints") | ||
private Provider<List<Integer>> providedInts; | ||
|
||
@Inject | ||
@ConfigProperty(name = "app.ints") | ||
private int[] intsArray; | ||
|
||
@Inject | ||
@ConfigProperty(name = "app") | ||
private Map<String, String> detached; | ||
|
||
@Inject | ||
private Config mpConfig; | ||
|
||
@Inject | ||
private io.helidon.config.Config helidonConfig; | ||
|
||
/** | ||
* Get method to validate that all injections worked. | ||
* | ||
* @return data from all fields of this class | ||
*/ | ||
@GET | ||
public String get() { | ||
return toString(); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "AnotherResource{" | ||
+ "defaultValue=" + defaultValue | ||
+ ", empty=" + empty | ||
+ ", full=" + full | ||
+ ", provider=" + provider + "(" + provider.get() + ")" | ||
+ ", ints=" + ints | ||
+ ", optionalInts=" + optionalInts | ||
+ ", providedInts=" + providedInts + "(" + providedInts.get() + ")" | ||
+ ", detached=" + detached | ||
+ ", microprofileConfig=" + mpConfig | ||
+ ", helidonConfig=" + helidonConfig | ||
+ ", intsArray=" + Arrays.toString(intsArray) | ||
+ '}'; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Lurking. I wonder if, since you're doing this
java
run already, you might also combine it with class data sharing. Or maybe you want to keep things pure for this PoC.)