Skip to content
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

Merged
merged 28 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
e2ad8fb
[Feature] Preliminary support native-image
yswdqz Sep 28, 2023
7982230
[optimize] optimize config file size.
yswdqz Sep 29, 2023
9211ae3
[change] update changes
yswdqz Sep 29, 2023
0ab6b79
test e2e
yswdqz Oct 14, 2023
fb4cd26
[config] add e2e config
yswdqz Oct 19, 2023
46443b5
[config] add e2e config file
yswdqz Oct 19, 2023
b5fad86
[e2e/doc] reduce e2e casees, add docs for native-image configs
yswdqz Oct 19, 2023
617d4cb
[CI] fix native-image args file
yswdqz Oct 19, 2023
094e4ab
[e2e] fix e2e
yswdqz Oct 19, 2023
44e47ce
Merge branch 'master' into native-image-support
yswdqz Oct 19, 2023
1f8df26
[license] add license
yswdqz Oct 20, 2023
3338207
Merge branch 'master' into native-image-support
wu-sheng Oct 20, 2023
da3d1c3
[license] add license
yswdqz Oct 20, 2023
ec6dc79
Merge branch 'native-image-support' of https://github.com/yswdqz/skyw…
yswdqz Oct 20, 2023
bfaf1dc
[Native config] run ut/it by native-tracing-agent to generate configs
yswdqz Oct 28, 2023
94bb2a5
Merge branch 'master' into native-image-support
wu-sheng Oct 29, 2023
d27fc18
[e2e] test python agent e2e
yswdqz Oct 29, 2023
1ad623f
Merge branch 'native-image-support' of https://github.com/yswdqz/skyw…
yswdqz Oct 29, 2023
20447ef
Update NativeConfigFilter.java
yswdqz Oct 29, 2023
b99f565
[Fix] fix error when generate oal classes
yswdqz Oct 29, 2023
6517a67
[Ready] update e2e, optimize IT
yswdqz Oct 29, 2023
615b3a6
[fix] fix docs
yswdqz Oct 29, 2023
799f9bd
[Fix] fix e2e/license
yswdqz Oct 30, 2023
a7036b5
[doc] change doc link to relative path
yswdqz Oct 30, 2023
2501791
[license/doc] add license, fix typo
yswdqz Oct 30, 2023
4df1860
[typo] fix typo
yswdqz Oct 30, 2023
2ab226f
[doc] add graal jdk install docs
yswdqz Oct 30, 2023
6e11010
[typo] fix typo in ci config files
yswdqz Oct 30, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 73 additions & 1 deletion .github/workflows/native-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@
name: GraalVM Community Edition build
on:
pull_request:
push:

concurrency:
group: skywalking-${{ github.event.pull_request.number || github.ref }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
group: skywalking-${{ github.event.pull_request.number || github.ref }}
group: skywalking-graalvm-${{ 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
Expand All @@ -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' }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
runs-on: ${{ 'ubuntu-latest' }}
runs-on: ubuntu-latest

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 }}"
38 changes: 38 additions & 0 deletions graal/Makefile
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
39 changes: 39 additions & 0 deletions graal/docker/oap/Dockerfile
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
Copy link
Member

Choose a reason for hiding this comment

The 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 arm support in this PR, just wondering whether there is any blocker to support arm64 arch

Copy link
Member Author

Choose a reason for hiding this comment

The 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).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's open another PR to verify this.
Considering timing of OSPP, I could skip 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"]
9 changes: 8 additions & 1 deletion graal/graal-server-starter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Copy link
Member

Choose a reason for hiding this comment

The 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>
Expand Down Expand Up @@ -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>
Expand Down
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 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add comments to explain what this is about.

Suggested change
public class SkywalkingFeature implements Feature {
public class SkyWalkingFeature implements Feature {

skywalking should always be SkyWalking.

@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.

Loading