-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
[Feature] GraalVM Native Image support (Experimental). #11365
Changes from 3 commits
e2ad8fb
7982230
9211ae3
0ab6b79
fb4cd26
46443b5
b5fad86
617d4cb
094e4ab
44e47ce
1f8df26
3338207
da3d1c3
ec6dc79
bfaf1dc
94bb2a5
d27fc18
1ad623f
20447ef
b99f565
6517a67
615b3a6
799f9bd
a7036b5
2501791
4df1860
2ab226f
6e11010
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -17,6 +17,16 @@ | |||||
name: GraalVM Community Edition build | ||||||
on: | ||||||
pull_request: | ||||||
push: | ||||||
|
||||||
concurrency: | ||||||
group: skywalking-${{ github.event.pull_request.number || github.ref }} | ||||||
cancel-in-progress: true | ||||||
|
||||||
env: | ||||||
SW_AGENT_JDK_VERSION: 8 | ||||||
MAVEN_OPTS: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.httpconnectionManager.ttlSeconds=120 | ||||||
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 5 # Cache restore timeout | ||||||
jobs: | ||||||
build: | ||||||
runs-on: ubuntu-latest | ||||||
|
@@ -31,10 +41,72 @@ jobs: | |||||
components: 'native-image' | ||||||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||||||
- name: Native Compile | ||||||
env: | ||||||
SW_OAL_ENGINE_DEBUG: true | ||||||
run: | | ||||||
./mvnw -Pbackend,native clean package -Dmaven.test.skip | ||||||
- uses: actions/upload-artifact@v3 | ||||||
name: Upload distribution tar | ||||||
with: | ||||||
name: native-pre-dist | ||||||
path: distribution/graal/dist | ||||||
path: graal/dist | ||||||
- name: Build and save docker images | ||||||
run: | | ||||||
make -f graal/Makefile docker.oap || make -f graal/Makefile docker.oap | ||||||
docker save -o docker-images-skywalking-oap.tar skywalking/oap:latest | ||||||
- name: Upload docker images | ||||||
uses: actions/upload-artifact@v3 | ||||||
with: | ||||||
name: docker-images-native | ||||||
path: docker-images-skywalking-*.tar | ||||||
e2e-test: | ||||||
if: | | ||||||
always() && ! cancelled() | ||||||
name: E2E test | ||||||
needs: [build] | ||||||
runs-on: ${{ 'ubuntu-latest' }} | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
timeout-minutes: 60 | ||||||
strategy: | ||||||
fail-fast: false | ||||||
matrix: | ||||||
test: | ||||||
- name: Storage H2 | ||||||
config: test/e2e-v2/cases/storage/h2/e2e.yaml | ||||||
- name: Agent Python | ||||||
config: test/e2e-v2/cases/python/e2e.yaml | ||||||
|
||||||
steps: | ||||||
- uses: actions/checkout@v3 | ||||||
with: | ||||||
submodules: true | ||||||
- uses: actions/download-artifact@v3 | ||||||
name: Download docker images | ||||||
with: | ||||||
name: docker-images-native | ||||||
path: docker-images | ||||||
- name: Load docker images | ||||||
run: | | ||||||
find docker-images -name "*.tar" -exec docker load -i {} \; | ||||||
find docker-images -name "*.tar" -exec rm {} \; | ||||||
- name: Cache maven repository | ||||||
uses: actions/cache@v3 | ||||||
with: | ||||||
path: ~/.m2/repository | ||||||
key: ${{ runner.os }}-maven-${{ hashFiles('test/e2e-v2/java-test-service/**/pom.xml') }} | ||||||
restore-keys: ${{ runner.os }}-maven- | ||||||
- name: Prepare test services | ||||||
shell: bash | ||||||
run: ./mvnw -B -q -f test/e2e-v2/java-test-service/pom.xml clean package | ||||||
- name: Set env var | ||||||
run: | | ||||||
echo "${{ matrix.test.env }}" >> $GITHUB_ENV | ||||||
- name: ${{ matrix.test.name }} | ||||||
uses: apache/skywalking-infra-e2e@0a5b398fc9668ccb848b16e6da4f09180955dc3e | ||||||
with: | ||||||
e2e-file: $GITHUB_WORKSPACE/${{ matrix.test.config }} | ||||||
- uses: actions/upload-artifact@v2 | ||||||
if: ${{ failure() }} | ||||||
name: Upload Logs | ||||||
with: | ||||||
name: logs | ||||||
path: "${{ env.SW_INFRA_E2E_LOG_DIR }}" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
|
||
SHELL := /bin/bash -o pipefail | ||
|
||
SW_GRAAL_ROOT := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) | ||
CONTEXT = ${SW_GRAAL_ROOT}/dist | ||
DIST ?= apache-skywalking-apm-native-bin.tar.gz | ||
CLI_VERSION ?= 0.12.0 # CLI version inside OAP image should always use an Apache released artifact. | ||
|
||
HUB ?= skywalking | ||
|
||
TAG ?= latest | ||
|
||
DOCKER_BUILD_TOP:=${CONTEXT}/docker_build | ||
|
||
NAME := oap | ||
|
||
LOAD_OR_PUSH = --load | ||
|
||
#PLATFORMS = --platform linux/amd64,linux/arm64 | ||
|
||
BUILD_ARGS := $(BUILD_ARGS) --build-arg DIST=$(DIST) --build-arg SKYWALKING_CLI_VERSION=$(CLI_VERSION) | ||
|
||
|
||
|
||
docker.% push.docker.%: $(CONTEXT)/$(DIST) $(SW_GRAAL_ROOT)/docker/%/* | ||
$(DOCKER_RULE) | ||
|
||
define DOCKER_RULE | ||
mkdir -p $(DOCKER_BUILD_TOP)/$(NAME) | ||
cp -r $^ $(DOCKER_BUILD_TOP)/$(NAME) | ||
docker buildx create --use --driver docker-container --name skywalking_main > /dev/null 2>&1 || true | ||
docker buildx build $(PLATFORMS) $(LOAD_OR_PUSH) \ | ||
--no-cache $(BUILD_ARGS) \ | ||
-t $(HUB)/$(NAME):$(TAG) \ | ||
-t $(HUB)/$(NAME):latest \ | ||
$(DOCKER_BUILD_TOP)/$(NAME) | ||
docker buildx rm skywalking_main || true | ||
endef |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you 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. | ||
|
||
ARG BASE_IMAGE='eclipse-temurin:11-jre' | ||
|
||
ARG SKYWALKING_CLI_VERSION | ||
|
||
FROM apache/skywalking-cli:$SKYWALKING_CLI_VERSION as cli | ||
|
||
FROM --platform=linux/amd64 ubuntu:latest | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So we only support amd64 architecture in our Docker images? We don't have to add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ARM architecture should can be supported, but for the sake of passing tests stably, I specified AMD (some Docker images do not support ARM architecture operating systems). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's open another PR to verify this. |
||
|
||
ENV SKYWALKING_HOME=/skywalking | ||
|
||
WORKDIR $SKYWALKING_HOME | ||
|
||
ARG DIST | ||
|
||
COPY "$DIST" . | ||
|
||
RUN set -ex; \ | ||
tar -xzf "$DIST" --strip 1; \ | ||
rm -rf "$DIST"; | ||
|
||
COPY --from=cli /swctl ./bin | ||
|
||
EXPOSE 12800 11800 1234 | ||
|
||
ENTRYPOINT ["bash", "bin/oapService-native.sh"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,13 +98,21 @@ | |
<artifactId>oal-rt-graal-native</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.graalvm.sdk</groupId> | ||
<artifactId>graal-sdk</artifactId> | ||
<version>23.0.1</version> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please manage the version from the bom. |
||
<scope>provided</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<profiles> | ||
<profile> | ||
<id>native</id> | ||
<build> | ||
<plugins> | ||
|
||
<plugin> | ||
<groupId>org.apache.skywalking</groupId> | ||
<artifactId>skywalking-on-graal-compiling-plugin</artifactId> | ||
|
@@ -134,7 +142,6 @@ | |
</executions> | ||
<configuration> | ||
<verbose>true</verbose> | ||
<agent>f</agent> | ||
<imageName>${image.name}</imageName> | ||
<mainClass>org.apache.skywalking.oap.server.starter.OAPServerStartUp</mainClass> | ||
<metadataRepository> | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,75 @@ | ||||||
package org.apache.skywalking.graal; | ||||||
|
||||||
import org.apache.kafka.clients.consumer.RangeAssignor; | ||||||
import org.apache.skywalking.library.elasticsearch.response.Document; | ||||||
import org.apache.skywalking.library.elasticsearch.response.Documents; | ||||||
import org.apache.skywalking.library.elasticsearch.response.Index; | ||||||
import org.apache.skywalking.library.elasticsearch.response.IndexTemplate; | ||||||
import org.apache.skywalking.library.elasticsearch.response.IndexTemplates; | ||||||
import org.apache.skywalking.library.elasticsearch.response.Mappings; | ||||||
import org.apache.skywalking.library.elasticsearch.response.NodeInfo; | ||||||
import org.apache.skywalking.library.elasticsearch.response.search.SearchHit; | ||||||
import org.apache.skywalking.library.elasticsearch.response.search.SearchHits; | ||||||
import org.apache.skywalking.library.elasticsearch.response.search.SearchResponse; | ||||||
import org.apache.skywalking.oap.server.analyzer.agent.kafka.module.KafkaFetcherConfig; | ||||||
import org.apache.skywalking.oap.server.core.query.input.Duration; | ||||||
import org.apache.skywalking.oap.server.storage.plugin.banyandb.BanyanDBStorageConfig; | ||||||
import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.StorageModuleElasticsearchConfig; | ||||||
import org.graalvm.nativeimage.hosted.Feature; | ||||||
import org.graalvm.nativeimage.hosted.RuntimeReflection; | ||||||
|
||||||
import java.util.Arrays; | ||||||
import java.util.List; | ||||||
|
||||||
public class SkywalkingFeature implements Feature { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add comments to explain what this is about.
Suggested change
|
||||||
@Override | ||||||
public void beforeAnalysis(BeforeAnalysisAccess access) { | ||||||
registerAllOfClazz(BanyanDBStorageConfig.class); | ||||||
registerAllOfClazz(StorageModuleElasticsearchConfig.class); | ||||||
|
||||||
//kafka | ||||||
registerAllOfClazz(KafkaFetcherConfig.class); | ||||||
registerAllOfClazz(RangeAssignor.class); | ||||||
|
||||||
//e2e | ||||||
registerAllOfClazz(Duration.class); | ||||||
|
||||||
//es | ||||||
registerES(); | ||||||
} | ||||||
|
||||||
private void registerES() { | ||||||
registerClasses(Arrays.asList( | ||||||
SearchHit.class, | ||||||
SearchHits.class, | ||||||
SearchHits.TotalDeserializer.class, | ||||||
Mappings.Source.class, | ||||||
NodeInfo.Version.class, | ||||||
SearchResponse.class, | ||||||
Document.class, | ||||||
Documents.class, | ||||||
Index.class, | ||||||
IndexTemplate.class, | ||||||
IndexTemplates.class, | ||||||
Mappings.class, | ||||||
NodeInfo.class | ||||||
)); | ||||||
} | ||||||
|
||||||
private void registerClasses(List<Class> classes) { | ||||||
classes.forEach(this::registerAllOfClazz); | ||||||
} | ||||||
|
||||||
private void registerAllOfClazz(Class targetClass) { | ||||||
|
||||||
RuntimeReflection.register(targetClass); | ||||||
|
||||||
RuntimeReflection.register(targetClass.getDeclaredMethods()); | ||||||
|
||||||
RuntimeReflection.register(targetClass.getDeclaredFields()); | ||||||
for (Class declaredClass : targetClass.getDeclaredClasses()) { | ||||||
RuntimeReflection.register(declaredClass); | ||||||
} | ||||||
RuntimeReflection.register(targetClass.getDeclaredConstructors()); | ||||||
} | ||||||
} |
This file was deleted.
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.