Skip to content

Commit bf97c9a

Browse files
committed
modify optimizer test
1 parent 634c106 commit bf97c9a

File tree

6 files changed

+206
-5
lines changed

6 files changed

+206
-5
lines changed

.github/workflows/optimizer.yml

+58-3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ on:
1616

1717
env:
1818
CARGO_TERM_COLOR: always
19+
REGISTRY: ghcr.io
20+
SNAPSHOTTER_CONFIG: /etc/nydus/config.toml
21+
SOURCE_SNAPSHOTTER_CONFIG: misc/optimizer/snapshotter-config.toml
22+
NYDUSD_CONFIG: /etc/nydus/nydusd-config.fusedev.json
23+
SOURCE_NYDUSD_CONFIG: misc/snapshotter/nydusd-config.fusedev.json
24+
SNAPSHOTTER_SYSTEMD_UNIT_SERVICE: misc/snapshotter/nydus-snapshotter.fusedev.service
1925

2026
jobs:
2127
run_optimizer:
@@ -55,6 +61,7 @@ jobs:
5561
sudo systemctl stop containerd
5662
sudo tar -zxf ./containerd-static-1.7.0-linux-amd64.tar.gz -C /usr/
5763
sudo install -D -m 755 misc/optimizer/containerd-config.toml /etc/containerd/config.toml
64+
# sudo install -D -m 755 misc/example/containerd-config.toml /etc/containerd/config.toml
5865
sudo systemctl restart containerd
5966
sudo wget https://github.com/opencontainers/runc/releases/download/v1.1.5/runc.amd64 -O /usr/bin/runc
6067
sudo chmod +x /usr/bin/runc
@@ -64,6 +71,36 @@ jobs:
6471
sudo mkdir -p /opt/cni/bin
6572
sudo tar xzf cni-plugins-linux-amd64-v1.2.0.tgz -C /opt/cni/bin/
6673
sudo install -D -m 755 misc/example/10-containerd-net.conflist /etc/cni/net.d/10-containerd-net.conflist
74+
- name: Setup nydus-snapshotter and nydus service
75+
run: |
76+
GOOS=linux GOARCH=amd64 go build -o bin/containerd-nydus-grpc ./cmd/containerd-nydus-grpc
77+
sudo install -D -m 755 bin/containerd-nydus-grpc /usr/local/bin/containerd-nydus-grpc
78+
if [ ! -e "${{ env.NYDUSD_CONFIG }}" ]; then
79+
echo "Installing ${{ env.SOURCE_NYDUSD_CONFIG }} to ${{ env.NYDUSD_CONFIG }}"
80+
sudo install -D -m 664 "${{ env.SOURCE_NYDUSD_CONFIG }}" "${{ env.NYDUSD_CONFIG }}"
81+
fi
82+
if [ ! -e "${{ env.SNAPSHOTTER_CONFIG }}" ]; then
83+
echo "Installing ${{ env.SOURCE_SNAPSHOTTER_CONFIG }} to ${{ env.SNAPSHOTTER_CONFIG }}"
84+
sudo install -D -m 664 "${{ env.SOURCE_SNAPSHOTTER_CONFIG }}" "${{ env.SNAPSHOTTER_CONFIG }}"
85+
fi
86+
sudo ln -f -s /etc/nydus/nydusd-config.fusedev.json /etc/nydus/nydusd-config.json
87+
echo "Installing ${{ env.SNAPSHOTTER_SYSTEMD_UNIT_SERVICE }} to /etc/systemd/system/nydus-snapshotter.service"
88+
sudo install -D -m 644 "${{ env.SNAPSHOTTER_SYSTEMD_UNIT_SERVICE }}" /etc/systemd/system/nydus-snapshotter.service
89+
90+
if command -v systemctl >/dev/null; then
91+
sudo systemctl enable /etc/systemd/system/nydus-snapshotter.service
92+
sudo systemctl restart nydus-snapshotter
93+
fi
94+
95+
sleep 5
96+
NYDUS_VER=v$(curl --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' -s "https://api.github.com/repos/dragonflyoss/nydus/releases/latest" | jq -r .tag_name | sed 's/^v//')
97+
wget https://github.com/dragonflyoss/nydus/releases/download/$NYDUS_VER/nydus-static-$NYDUS_VER-linux-amd64.tgz
98+
tar xzvf nydus-static-$NYDUS_VER-linux-amd64.tgz
99+
# sudo systemctl restart nydus-snapshotter.service
100+
sudo install -D -m 755 nydus-static/nydusd /usr/local/bin/nydusd
101+
sudo install -D -m 755 nydus-static/nydus-image /usr/local/bin/nydus-image
102+
sudo install -D -m 755 nydus-static/nydusctl /usr/local/bin/nydusctl
103+
67104
- name: Build and install optimizer
68105
run: |
69106
rustup component add rustfmt clippy
@@ -90,22 +127,40 @@ jobs:
90127
echo "containerd is not ready"
91128
exit 1
92129
fi
130+
- name: Setup prefetch-distribution http server
131+
run: |
132+
go build -o prefetch-distribution tools/prefetch-distribution/main.go
133+
nohup ./prefetch-distribution &
134+
sleep 5
135+
- name: Log in to container registry
136+
uses: docker/login-action@v2
137+
with:
138+
registry: ${{ env.REGISTRY }}
139+
username: ${{ github.actor }}
140+
password: ${{ secrets.GITHUB_TOKEN }}
141+
93142
- name: Generate accessed files list
94143
run: |
95144
sed -i "s|host_path: script|host_path: $(pwd)/misc/optimizer/script|g" misc/optimizer/nginx.yaml
96145
sudo crictl run misc/optimizer/nginx.yaml misc/optimizer/sandbox.yaml
97146
sleep 20
98147
sudo crictl rmp -f --all
148+
sudo crictl rmi --all
99149
tree /opt/nri/optimizer/results/
100-
count=$(cat /opt/nri/optimizer/results/library/nginx:1.23.3 | wc -l)
150+
count=$(cat /opt/nri/optimizer/results/dragonflyoss/image-service/nginx:nydus-latest | wc -l)
101151
expected=$(cat misc/optimizer/script/file_list.txt | wc -l)
102152
echo "count: $count expected minimum value: $expected"
103153
if [ $count -lt $expected ]; then
104-
echo "failed to generate accessed files list for nginx:1.23.3"
154+
echo "failed to generate accessed files list for nginx:nydus-latest"
105155
cat misc/optimizer/script/file_list.txt
106156
exit 1
107157
fi
108-
cat /opt/nri/optimizer/results/library/nginx:1.23.3.csv
158+
cat /opt/nri/optimizer/results/dragonflyoss/image-service/nginx:nydus-latest.csv
159+
- name: Transmit the prefetch list to nydusd
160+
run: |
161+
sed -i "s|host_path: script|host_path: $(pwd)/misc/optimizer/script|g" misc/optimizer/nginx.yaml
162+
sudo crictl run misc/optimizer/nginx.yaml misc/optimizer/sandbox.yaml
163+
sudo cat /etc/nydus/logs/nydus-snapshotter.log | grep "nydusd command"
109164
- name: Dump logs
110165
if: failure()
111166
continue-on-error: true

misc/example/containerd-config.toml

+6
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ oom_score = 0
1818
[plugins."io.containerd.grpc.v1.cri".cni]
1919
bin_dir = "/opt/cni/bin"
2020
conf_dir = "/etc/cni/net.d"
21+
22+
[plugins."io.containerd.nri.v1.nri"]
23+
config_file = "/etc/nri/nri.conf"
24+
disable = false
25+
plugin_path = "/opt/nri/plugins"
26+
socket_path = "/var/run/nri.sock"
2127

2228
[proxy_plugins]
2329
[proxy_plugins.nydus]

misc/example/optimizer-nri-plugin.conf

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ overwrite = false
1212
# Do not change this element.
1313
events = [ "StartContainer", "StopContainer" ]
1414
# The service url of prefetch distribution.
15-
prefetch_distribution_url = "http://localhost:1323"
15+
prefetch_distribution_url = "http://localhost:1323"

misc/optimizer/containerd-config.toml

+5
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414

1515
version = 2
1616

17+
[plugins."io.containerd.grpc.v1.cri"]
18+
[plugins."io.containerd.grpc.v1.cri".containerd]
19+
snapshotter = "nydus"
20+
disable_snapshot_annotations = false
21+
1722
[proxy_plugins]
1823
[proxy_plugins.nydus]
1924
type = "snapshot"

misc/optimizer/nginx.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ metadata:
22
name: nginx
33

44
image:
5-
image: nginx:1.23.3
5+
image: ghcr.io/dragonflyoss/image-service/nginx:nydus-latest
66

77
mounts:
88
- host_path: script
+135
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
version = 1
2+
# Snapshotter's own home directory where it stores and creates necessary resources
3+
root = "/var/lib/containerd-nydus"
4+
# The snapshotter's GRPC server socket, containerd will connect to plugin on this socket
5+
address = "/run/containerd-nydus/containerd-nydus-grpc.sock"
6+
# The nydus daemon mode can be one of the following options: multiple, dedicated, shared, or none.
7+
# If `daemon_mode` option is not specified, the default value is multiple.
8+
daemon_mode = "dedicated"
9+
# Whether snapshotter should try to clean up resources when it is closed
10+
cleanup_on_close = false
11+
12+
[system]
13+
# Snapshotter's debug and trace HTTP server interface
14+
enable = true
15+
# Unix domain socket path where system controller is listening on
16+
address = "/run/containerd-nydus/system.sock"
17+
18+
[system.debug]
19+
# Snapshotter can profile the CPU utilization of each nydusd daemon when it is being started.
20+
# This option specifies the profile duration when nydusd is downloading and uncomproessing data.
21+
daemon_cpu_profile_duration_secs = 5
22+
# Enable by assigning an address, empty indicates pprof server is disabled
23+
pprof_address = ""
24+
25+
[daemon]
26+
# Specify a configuration file for nydusd
27+
nydusd_config = "/etc/nydus/nydusd-config.fusedev.json"
28+
nydusd_path = "/usr/local/bin/nydusd"
29+
nydusimage_path = "/usr/local/bin/nydus-image"
30+
# fusedev or fscache
31+
fs_driver = "fusedev"
32+
# How to process when daemon dies: "none", "restart" or "failover"
33+
recover_policy = "restart"
34+
# Nydusd worker thread number to handle FUSE or fscache requests, [0-1024].
35+
# Setting to 0 will use the default configuration of nydusd.
36+
threads_number = 4
37+
# Log rotation size for nydusd, in unit MB(megabytes). (default 100MB)
38+
log_rotation_size = 100
39+
40+
[cgroup]
41+
# Whether to use separate cgroup for nydusd.
42+
enable = true
43+
# The memory limit for nydusd cgroup, which contains all nydusd processes.
44+
# Percentage is supported as well, please ensure it is end with "%".
45+
# The default unit is bytes. Acceptable values include "209715200", "200MiB", "200Mi" and "10%".
46+
memory_limit = ""
47+
48+
[log]
49+
# Print logs to stdout rather than logging files
50+
log_to_stdout = false
51+
dir = "/etc/nydus/logs"
52+
# Snapshotter's log level
53+
level = "info"
54+
log_rotation_compress = true
55+
log_rotation_local_time = true
56+
# Max number of days to retain logs
57+
log_rotation_max_age = 7
58+
log_rotation_max_backups = 5
59+
# In unit MB(megabytes)
60+
log_rotation_max_size = 100
61+
62+
[metrics]
63+
# Enable by assigning an address, empty indicates metrics server is disabled
64+
address = ":9110"
65+
66+
[remote]
67+
convert_vpc_registry = false
68+
69+
[remote.mirrors_config]
70+
# Snapshotter will overwrite daemon's mirrors configuration
71+
# if the values loaded from this driectory are not null before starting a daemon.
72+
# Set to "" or an empty directory to disable it.
73+
#dir = "/etc/nydus/certs.d"
74+
75+
[remote.auth]
76+
# Fetch the private registry auth by listening to K8s API server
77+
enable_kubeconfig_keychain = false
78+
# synchronize `kubernetes.io/dockerconfigjson` secret from kubernetes API server with specified kubeconfig (default `$KUBECONFIG` or `~/.kube/config`)
79+
kubeconfig_path = ""
80+
# Fetch the private registry auth as CRI image service proxy
81+
enable_cri_keychain = false
82+
# the target image service when using image proxy
83+
#image_service_address = "/run/containerd/containerd.sock"
84+
85+
[snapshot]
86+
# Let containerd use nydus-overlayfs mount helper
87+
enable_nydus_overlayfs = false
88+
# Insert Kata Virtual Volume option to `Mount.Options`
89+
enable_kata_volume = false
90+
# Whether to remove resources when a snapshot is removed
91+
sync_remove = false
92+
93+
[cache_manager]
94+
# Disable or enable recyclebin
95+
disable = false
96+
# How long to keep deleted files in recyclebin
97+
gc_period = "24h"
98+
# Directory to host cached files
99+
cache_dir = ""
100+
101+
[image]
102+
public_key_file = ""
103+
validate_signature = false
104+
105+
# The configuraions for features that are not production ready
106+
[experimental]
107+
# Whether to enable stargz support
108+
enable_stargz = false
109+
# Whether to enable referrers support
110+
# The option enables trying to fetch the Nydus image associated with the OCI image and run it.
111+
# Also see https://github.com/opencontainers/distribution-spec/blob/main/spec.md#listing-referrers
112+
enable_referrer_detect = false
113+
# Whether to enable authentication support
114+
# The option enables nydus snapshot to provide backend information to nydusd.
115+
enable_backend_source = false
116+
[experimental.tarfs]
117+
# Whether to enable nydus tarfs mode. Tarfs is supported by:
118+
# - The EROFS filesystem driver since Linux 6.4
119+
# - Nydus Image Service release v2.3
120+
enable_tarfs = false
121+
# Mount rafs on host by loopdev and EROFS
122+
mount_tarfs_on_host = false
123+
# Only enable nydus tarfs mode for images with `tarfs hint` label when true
124+
tarfs_hint = false
125+
# Maximum of concurrence to converting OCIv1 images to tarfs, 0 means default
126+
max_concurrent_proc = 0
127+
# Mode to export tarfs images:
128+
# - "none" or "": do not export tarfs
129+
# - "layer_verity_only": only generate disk verity information for a layer blob
130+
# - "image_verity_only": only generate disk verity information for all blobs of an image
131+
# - "layer_block": generate a raw block disk image with tarfs for a layer
132+
# - "image_block": generate a raw block disk image with tarfs for an image
133+
# - "layer_block_with_verity": generate a raw block disk image with tarfs for a layer with dm-verity info
134+
# - "image_block_with_verity": generate a raw block disk image with tarfs for an image with dm-verity info
135+
export_mode = ""

0 commit comments

Comments
 (0)