Skip to content

Commit 807bf52

Browse files
committed
workflow: build eBPF optimizer in container
Signed-off-by: Bin Tang <[email protected]>
1 parent f816ef0 commit 807bf52

File tree

3 files changed

+55
-41
lines changed

3 files changed

+55
-41
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ env:
1212
jobs:
1313
build:
1414
name: Build and Lint
15-
timeout-minutes: 10
15+
timeout-minutes: 20
1616
runs-on: ubuntu-latest
1717
steps:
1818
- name: Set up Go
@@ -33,17 +33,13 @@ jobs:
3333
go install github.com/golangci/golangci-lint/cmd/[email protected]
3434
export PATH=$PATH:$(go env GOPATH)/bin
3535
make
36-
make test
37-
make check
36+
make container-test
37+
make container-check
3838
build-optimizer:
3939
name: Build optimizer
40-
timeout-minutes: 10
40+
timeout-minutes: 20
4141
runs-on: ubuntu-latest
4242
steps:
43-
- name: Set up Go
44-
uses: actions/setup-go@v3
45-
with:
46-
go-version: "1.20.1"
4743
- name: Check out code
4844
uses: actions/checkout@v3
4945
- name: cache go mod
@@ -55,19 +51,12 @@ jobs:
5551
${{ runner.os }}-go
5652
- name: Build
5753
run: |
58-
go install github.com/golangci/golangci-lint/cmd/[email protected]
59-
export PATH=$PATH:$(go env GOPATH)/bin
60-
rustup component add rustfmt clippy
61-
make build-optimizer
54+
make container-build-optimizer
6255
smoke:
6356
name: Smoke
64-
timeout-minutes: 10
57+
timeout-minutes: 20
6558
runs-on: ubuntu-latest
6659
steps:
67-
- name: Set up Go
68-
uses: actions/setup-go@v3
69-
with:
70-
go-version: "1.19.6"
7160
- name: Check out code
7261
uses: actions/checkout@v3
7362
- name: cache go mod
@@ -118,14 +107,10 @@ jobs:
118107
119108
coverage:
120109
name: Code coverage
121-
timeout-minutes: 10
110+
timeout-minutes: 20
122111
runs-on: ubuntu-latest
123112
needs: [build]
124113
steps:
125-
- name: Install Go
126-
uses: actions/setup-go@v3
127-
with:
128-
go-version: "1.19.6"
129114
- name: Checkout code
130115
uses: actions/checkout@v3
131116
- name: cache go mod
@@ -136,7 +121,7 @@ jobs:
136121
restore-keys: |
137122
${{ runner.os }}-go
138123
- name: Run unit tests.
139-
run: make cover
124+
run: make container-cover
140125
- name: Upload coverage to Codecov
141126
uses: codecov/codecov-action@v3
142127
with:

.github/workflows/optimizer.yml

Lines changed: 46 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,11 @@ env:
1919

2020
jobs:
2121
run_optimizer:
22-
runs-on: ubuntu-latest
22+
runs-on: ubuntu-20.04
23+
env:
24+
GOBCC_BUILDER_IMAGE: 'ghcr.io/sctb512/gobcc-builder:20.04'
25+
GOBCC_BUILDER_IMAGE_FILE: '~/.image/gobcc-builder:20.04.tar'
2326
steps:
24-
- name: Set up Go
25-
uses: actions/setup-go@v3
26-
with:
27-
go-version: "1.19.6"
2827
- name: Checkout repository
2928
uses: actions/checkout@v3
3029
- name: cache go mod
@@ -46,6 +45,44 @@ jobs:
4645
key: ${{ runner.os }}-cargo-${{ hashFiles('tools/optimizer-server/Cargo.lock') }}
4746
restore-keys: |
4847
${{ runner.os }}-cargo
48+
- name: cache go bcc image
49+
uses: actions/cache@v3
50+
with:
51+
path: |
52+
${GOBCC_BUILDER_IMAGE_FILE}
53+
key: ${{ runner.os }}-bogcc-builder-${{ hashFiles('${GOBCC_BUILDER_IMAGE_FILE}') }}
54+
restore-keys: |
55+
${{ runner.os }}-bogcc-builder
56+
- name: load go bcc image
57+
run: |
58+
if [ -f ${GOBCC_BUILDER_IMAGE_FILE} ];then
59+
sudo docker load < ${GOBCC_BUILDER_IMAGE_FILE}
60+
else
61+
sudo docker pull ${GOBCC_BUILDER_IMAGE}
62+
fi
63+
- name: Build optimizer
64+
run: |
65+
make container-optimizer
66+
pwd
67+
ldd bin/*optimizer*
68+
ls -lh bin/*optimizer*
69+
- name: Setup bcc for eBPF
70+
run: |
71+
sudo apt-get update
72+
sudo apt install -y zip bison build-essential cmake flex git libedit-dev \
73+
libllvm12 llvm-12-dev libclang-12-dev python zlib1g-dev libelf-dev libfl-dev python3-setuptools \
74+
liblzma-dev arping netperf iperf
75+
git clone https://github.com/iovisor/bcc.git; cd bcc
76+
git checkout v0.24.0
77+
mkdir build; cd build
78+
cmake ..
79+
make
80+
sudo make install
81+
cmake -DPYTHON_CMD=python3 ..
82+
pushd src/python/
83+
make
84+
sudo make install
85+
popd
4986
- name: containerd runc and crictl
5087
run: |
5188
sudo wget https://github.com/kubernetes-sigs/cri-tools/releases/download/v1.26.0/crictl-v1.26.0-linux-amd64.tar.gz
@@ -56,6 +93,7 @@ jobs:
5693
sudo tar -zxf ./containerd-static-1.7.0-linux-amd64.tar.gz -C /usr/
5794
sudo install -D -m 755 misc/optimizer/containerd-config.toml /etc/containerd/config.toml
5895
sudo systemctl restart containerd
96+
systemctl status containerd --no-pager -l
5997
sudo wget https://github.com/opencontainers/runc/releases/download/v1.1.5/runc.amd64 -O /usr/bin/runc
6098
sudo chmod +x /usr/bin/runc
6199
- name: Setup CNI
@@ -66,11 +104,6 @@ jobs:
66104
sudo install -D -m 755 misc/example/10-containerd-net.conflist /etc/cni/net.d/10-containerd-net.conflist
67105
- name: Build and install optimizer
68106
run: |
69-
rustup component add rustfmt clippy
70-
make optimizer
71-
sudo chown -R $(id -un):$(id -gn) . ~/.cargo/
72-
pwd
73-
ls -lh bin/*optimizer*
74107
sudo make install-optimizer
75108
sudo install -D -m 755 misc/example/optimizer-nri-plugin.conf /etc/nri/conf.d/02-optimizer-nri-plugin.conf
76109
sudo systemctl restart containerd
@@ -87,14 +120,15 @@ jobs:
87120
echo "count: $count expected minimum value: $expected"
88121
if [ $count -lt $expected ]; then
89122
echo "failed to generate accessed files list for nginx:1.23.3"
90-
cat misc/optimizer/script/file_list.txt
123+
cat /opt/nri/optimizer/results/library/nginx:1.23.3
91124
exit 1
92125
fi
93126
cat /opt/nri/optimizer/results/library/nginx:1.23.3.csv
94127
- name: Dump logs
95128
if: failure()
96129
continue-on-error: true
97130
run: |
98-
systemctl status containerd --no-pager -l
99131
journalctl -xeu containerd --no-pager
132+
journalctl -xeu docker --no-pager
133+
journalctl -t "optimizer-nri-plugin" --no-pager
100134

.github/workflows/release.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ jobs:
1515
runs-on: ubuntu-latest
1616
steps:
1717
- uses: actions/checkout@v3
18-
- uses: actions/setup-go@v3
19-
with:
20-
go-version: "1.19.6"
2118
- name: cache go mod
2219
uses: actions/cache@v3
2320
with:
@@ -39,9 +36,7 @@ jobs:
3936
${{ runner.os }}-cargo
4037
- name: build nydus-snapshotter and optimizer
4138
run: |
42-
go install github.com/golangci/golangci-lint/cmd/[email protected]
43-
export PATH=$PATH:$(go env GOPATH)/bin
44-
make static-release
39+
make container-static-release
4540
- name: upload artifacts
4641
uses: actions/upload-artifact@v3
4742
with:

0 commit comments

Comments
 (0)