Skip to content

Commit

Permalink
Support compatibility checks and add documentation (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrproliu authored Dec 8, 2022
1 parent 2462d62 commit 1bb40c9
Show file tree
Hide file tree
Showing 26 changed files with 712 additions and 48 deletions.
206 changes: 206 additions & 0 deletions .github/workflows/compatibility.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# 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.

name: Compatibility Checks

on: workflow_dispatch

jobs:
upload-checkers:
name: Upload checkers
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Set up Go 1.18
uses: actions/setup-go@v2
with:
go-version: 1.18
- id: 'auth'
uses: 'google-github-actions/auth@v1'
with:
credentials_json: '${{ secrets.GCP_SERVICE_ACCOUNT_CREDENTIALS }}'
- name: 'Set up Cloud SDK'
uses: 'google-github-actions/setup-gcloud@v1'
- name: Build and Upload
run: |
# build skywalking rover binary
make container-btfgen build
cp bin/skywalking-rover-latest-linux-amd64 scripts/check/profiling
# build demo program
cd scripts/check/profiling
go build demo.go
mv demo demo-program

# upload to the gcloud
gcloud storage cp ./* gs://skywalking-rover-compatibility/runner

checks:
name: Compatibility Checks
needs: [upload-checkers]
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
# following `gcloud compute images list`
system:
# ubuntu
- name: Ubuntu
project: ubuntu-os-cloud
family: ubuntu-1804-lts
image: ubuntu-1804-bionic-v20221201
- name: Ubuntu
project: ubuntu-os-cloud
family: ubuntu-2004-lts
image: ubuntu-2004-focal-v20221202
- name: Ubuntu
project: ubuntu-os-cloud
family: ubuntu-2204-lts
image: ubuntu-2204-jammy-v20221201
- name: Ubuntu
project: ubuntu-os-cloud
family: ubuntu-2210-amd64
image: ubuntu-2210-kinetic-amd64-v20221201

# ubuntu pro
- name: Ubuntu_Pro
project: ubuntu-os-pro-cloud
family: ubuntu-pro-1604-lts
image: ubuntu-pro-1604-xenial-v20221201
- name: Ubuntu_Pro
project: ubuntu-os-pro-cloud
family: ubuntu-pro-1804-lts
image: ubuntu-pro-1804-bionic-v20221201
- name: Ubuntu_Pro
project: ubuntu-os-pro-cloud
family: ubuntu-pro-2004-lts
image: ubuntu-pro-2004-focal-v20221202
- name: Ubuntu_Pro
project: ubuntu-os-pro-cloud
family: ubuntu-pro-2204-lts
image: ubuntu-pro-2204-jammy-v20221201

# centos
- name: Centos
project: centos-cloud
family: centos-7
image: centos-7-v20221102
- name: Centos
project: centos-cloud
family: centos-stream-8
image: centos-stream-8-v20221102
- name: Centos
project: centos-cloud
family: centos-stream-9
image: centos-stream-9-v20221102

# debian
- name: Debian
project: debian-cloud
family: debian-10
image: debian-10-buster-v20221102
- name: Debian
project: debian-cloud
family: debian-11
image: debian-11-bullseye-v20221102

# RHEL
- name: RHEL
project: rhel-cloud
family: rhel-7
image: rhel-7-v20221102
- name: RHEL
project: rhel-cloud
family: rhel-8
image: rhel-8-v20221102
- name: RHEL
project: rhel-cloud
family: rhel-9
image: rhel-9-v20221102

# rocky
- name: Rocky
project: rocky-linux-cloud
family: rocky-linux-8
image: rocky-linux-8-v20221102
- name: Rocky
project: rocky-linux-cloud
family: rocky-linux-9
image: rocky-linux-9-v20221102

# Fedora
- name: Fedora
project: fedora-cloud
family: fedora-cloud-34
image: fedora-cloud-base-gcp-34-1-2-x86-64
- name: Fedora
project: fedora-cloud
family: fedora-cloud-35
image: fedora-cloud-base-gcp-35-1-2-x86-64
- name: Fedora
project: fedora-cloud
family: fedora-cloud-36
image: fedora-cloud-base-gcp-36-20220506-n-0-x86-64
- name: Fedora
project: fedora-cloud
family: fedora-cloud-37
image: fedora-cloud-base-gcp-37-beta-1-5-x86-64
steps:
- uses: actions/checkout@v3
with:
submodules: true
- id: 'auth'
uses: 'google-github-actions/auth@v1'
with:
credentials_json: '${{ secrets.GCP_SERVICE_ACCOUNT_CREDENTIALS }}'
- name: 'Set up Cloud SDK'
uses: 'google-github-actions/setup-gcloud@v1'
- name: Check
env:
INSTANCE_PROJECT: "${{ matrix.system.project }}"
INSTANCE_IMAGE: "${{ matrix.system.image }}"
INSTANCE_FAMILY: "${{ matrix.system.family }}"
INSTANCE_SYSTEM: "${{ matrix.system.name }}"
run: |
# download the runner
mkdir -p /tmp/runner
gcloud storage cp gs://skywalking-rover-compatibility/runner/* /tmp/runner
# create instance
gcloud compute instances create "skywalking-rover-test-$INSTANCE_IMAGE" --image "$INSTANCE_IMAGE" \
--image-project "$INSTANCE_PROJECT" --machine-type e2-medium --zone us-west1-b
# generate the public ssh key
ssh-keygen -b 2048 -t rsa -f /tmp/sshkey -f ~/.ssh/google_compute_engine -q -N ""
# scp runner
gcloud compute scp --recurse /tmp/runner hanliu@"skywalking-rover-test-$INSTANCE_IMAGE":/tmp/ --zone us-west1-b
# run checker
gcloud compute ssh --zone "us-west1-b" "hanliu@skywalking-rover-test-$INSTANCE_IMAGE" \
--project "skywalking-live-demo" \
--command "cd /tmp/runner; chmod +x /tmp/runner/demo-program /tmp/runner/skywalking-rover-latest-linux-amd64; sudo bash check.sh /tmp/runner/config.yaml /tmp/runner/demo-program /tmp/runner/skywalking-rover-latest-linux-amd64 /tmp/runner/result/$INSTANCE_SYSTEM/$INSTANCE_FAMILY json"
# scp from instance and upload to the storage
gcloud compute scp --recurse hanliu@"skywalking-rover-test-$INSTANCE_IMAGE":/tmp/runner/result /tmp/runner --zone us-west1-b
gcloud storage cp -r /tmp/runner/result gs://skywalking-rover-compatibility/
# delete test instance
gcloud compute instances delete "skywalking-rover-test-$INSTANCE_IMAGE" --zone us-west1-b -q
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ Release Notes.

#### Bug Fixes

#### Documentation
* Adding support version of Linux documentation.

#### Issues and PR
- All issues are [here](https://github.com/apache/skywalking/milestone/154?closed=1)
- All and pull requests are [here](https://github.com/apache/skywalking-rover/milestone/4?closed=1)
Expand Down
12 changes: 6 additions & 6 deletions bpf/profiling/network/args.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
#pragma once

// for protocol analyze need to read
#define MAX_PROTOCOL_SOCKET_READ_LENGTH 21
#define MAX_PROTOCOL_SOCKET_READ_LENGTH 31
// for transmit to the user space
#define MAX_TRANSMIT_SOCKET_READ_LENGTH 2048
#define MAX_TRANSMIT_SOCKET_READ_LENGTH 2047

// unknown the connection type, not trigger the syscall connect,accept
#define AF_UNKNOWN 0xff
Expand Down Expand Up @@ -205,7 +205,7 @@ struct {

struct socket_buffer_reader_t {
__u32 data_len;
char buffer[MAX_PROTOCOL_SOCKET_READ_LENGTH];
char buffer[MAX_PROTOCOL_SOCKET_READ_LENGTH + 1];
};
struct {
__uint(type, BPF_MAP_TYPE_PERCPU_ARRAY);
Expand Down Expand Up @@ -240,9 +240,9 @@ static __inline struct socket_buffer_reader_t* read_socket_data(struct sock_data
if (size > MAX_PROTOCOL_SOCKET_READ_LENGTH) {
size = MAX_PROTOCOL_SOCKET_READ_LENGTH;
}
asm volatile("%[size] &= 0xfff;\n" ::[size] "+r"(size) :);
bpf_probe_read(&reader->buffer, size, buf);
reader->data_len = size;
asm volatile("%[size] &= 0x1f;\n" ::[size] "+r"(size) :);
bpf_probe_read(&reader->buffer, size & MAX_PROTOCOL_SOCKET_READ_LENGTH, buf);
reader->data_len = size & MAX_PROTOCOL_SOCKET_READ_LENGTH;
return reader;
}

Expand Down
8 changes: 4 additions & 4 deletions bpf/profiling/network/go_tls.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ struct {
__type(key, __u32);
__type(value, struct go_tls_args_symaddr_t);
} go_tls_args_symaddr_map SEC(".maps");
static __inline struct go_tls_args_symaddr_t* get_go_tls_args_symaddr(__u32 tgid) {
static __always_inline struct go_tls_args_symaddr_t* get_go_tls_args_symaddr(__u32 tgid) {
struct go_tls_args_symaddr_t *addr = bpf_map_lookup_elem(&go_tls_args_symaddr_map, &tgid);
return addr;
}
Expand Down Expand Up @@ -82,7 +82,7 @@ struct {
} go_regabi_regs_map SEC(".maps");
// Copies the registers of the golang ABI, so that they can be
// easily accessed using an offset.
static __inline uint64_t* go_regabi_regs(const struct pt_regs* ctx) {
static __always_inline uint64_t* go_regabi_regs(const struct pt_regs* ctx) {
__u32 zero = 0;
struct go_regabi_regs_t* regs_heap_var = bpf_map_lookup_elem(&go_regabi_regs_map, &zero);
if (regs_heap_var == NULL) {
Expand All @@ -107,7 +107,7 @@ struct go_interface {
void* ptr;
};

static __inline void assign_go_tls_arg(void* arg, size_t arg_size, struct go_tls_arg_location_t loc, const void* sp,
static __always_inline void assign_go_tls_arg(void* arg, size_t arg_size, struct go_tls_arg_location_t loc, const void* sp,
uint64_t* regs) {
// stack type
if (loc.type == 1) {
Expand All @@ -120,7 +120,7 @@ static __inline void assign_go_tls_arg(void* arg, size_t arg_size, struct go_tls
}
}

static __inline int get_fd_from_go_tls_conn(struct go_interface conn, struct go_tls_args_symaddr_t* symaddr) {
static __always_inline int get_fd_from_go_tls_conn(struct go_interface conn, struct go_tls_args_symaddr_t* symaddr) {
// read connection
bpf_probe_read(&conn, sizeof(conn), conn.ptr + symaddr->tls_conn_offset);

Expand Down
12 changes: 4 additions & 8 deletions bpf/profiling/network/netmonitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ static __inline struct active_connection_t* get_or_create_active_conn(struct pt_
return bpf_map_lookup_elem(&active_connection_map, &conid);
}

static __inline void set_conn_as_ssl(struct pt_regs* ctx, __u32 tgid, __u32 fd, __u32 func_name) {
static __always_inline void set_conn_as_ssl(struct pt_regs* ctx, __u32 tgid, __u32 fd, __u32 func_name) {
struct active_connection_t* conn = get_or_create_active_conn(ctx, tgid, fd, func_name);
if (conn == NULL) {
return;
Expand Down Expand Up @@ -276,17 +276,13 @@ static __always_inline void __upload_socket_data_with_buffer(void *ctx, __u8 ind
event->sequence = index;
event->data_len = size;
event->finished = is_finished;
if (size == 0) {
if (size <= 0) {
return;
}
if (size > MAX_TRANSMIT_SOCKET_READ_LENGTH) {
size = MAX_TRANSMIT_SOCKET_READ_LENGTH;
}
asm volatile("%[size] &= 0x7fffffff;\n" ::[size] "+r"(size) :);
bpf_probe_read(&event->buffer, size, buf);
asm volatile("%[size] &= 0x7ff;\n" ::[size] "+r"(size) :);
bpf_probe_read(&event->buffer, size & 0x7ff, buf);

bpf_perf_event_output(ctx, &socket_data_upload_event_queue, BPF_F_CURRENT_CPU, event, sizeof(*event));

}

static __always_inline void upload_socket_data_buf(void *ctx, char* buf, ssize_t size, struct socket_data_upload_event *event, __u8 force_unfinished) {
Expand Down
2 changes: 1 addition & 1 deletion bpf/profiling/network/sock_stats.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ struct socket_data_upload_event {
__u64 randomid;
__u64 data_id;
__u64 total_size;
char buffer[MAX_TRANSMIT_SOCKET_READ_LENGTH];
char buffer[MAX_TRANSMIT_SOCKET_READ_LENGTH + 1];
};
struct {
__uint(type, BPF_MAP_TYPE_PERCPU_ARRAY);
Expand Down
34 changes: 27 additions & 7 deletions docs/en/concepts-and-designs/project_structue.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,48 @@
- cmd: The starter of Rover.
- configs: Rover configs.
- bpf: All the BPF programs with C code.
- docker: Docker files for build Rover image.
- docs: The documentation of Rover.
- pkg: Contains all modules and basic framework.
- boot: Manage all enabled module life cycle.
- config: Read config for start.
- logger: Manage the log.
- config: Read config for start.
- module: The interface of each module.
- boot: Manage all enabled module life cycle.
- core: Manage the connection with OAP.
- process: Manage the process detect and upload them to the OAP.
- profiling: Manage the profiling tasks and upload data to the OAP.
- tools: Sharing tools for each module.
- script/build: For `make` command use.
- internal/cmd: Command lines for execute the Rover.
- script: The rover related shell scripts.
- build: For `make` command use.
- check: Check the rover features is supported for the system.
- debug: Generate the debug information for the programs.
- release: Fot release the rover.
- test/e2e: E2E test to verify the Rover future.
```
.
├── CHANGES.md
├── cmd
├── configs
├── bpf
├── docker
├── docs
├── go.sum
├── script
│   ├── build
│   ├── check
│   ├── debug
│   ├── release
├── pkg
│   ├── boot
│   ├── config
│   ├── logger
│   ├── config
│   ├── module
│   ├── boot
│   ├── core
│   ├── process
│   ├── profiling
│   ├── tools
│   ├── modules
├── test
│   ├── e2e
├── internal
│   ├── cmd
```
Loading

0 comments on commit 1bb40c9

Please sign in to comment.