Skip to content

Commit c044f6b

Browse files
committed
modify optimizer test
Signed-off-by: Guangyu Xu <[email protected]>
1 parent f674b97 commit c044f6b

File tree

6 files changed

+211
-7
lines changed

6 files changed

+211
-7
lines changed

.github/workflows/optimizer.yml

+60-4
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/snapshotter/config_optimizer.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:
@@ -58,6 +64,34 @@ jobs:
5864
sudo mkdir -p /opt/cni/bin
5965
sudo tar xzf cni-plugins-linux-amd64-v1.2.0.tgz -C /opt/cni/bin/
6066
sudo install -D -m 755 misc/example/10-containerd-net.conflist /etc/cni/net.d/10-containerd-net.conflist
67+
- name: Setup nydus-snapshotter and nydus service
68+
run: |
69+
GOOS=linux GOARCH=amd64 go build -o bin/containerd-nydus-grpc ./cmd/containerd-nydus-grpc
70+
sudo install -D -m 755 bin/containerd-nydus-grpc /usr/local/bin/containerd-nydus-grpc
71+
if [ ! -e "${{ env.NYDUSD_CONFIG }}" ]; then
72+
echo "Installing ${{ env.SOURCE_NYDUSD_CONFIG }} to ${{ env.NYDUSD_CONFIG }}"
73+
sudo install -D -m 664 "${{ env.SOURCE_NYDUSD_CONFIG }}" "${{ env.NYDUSD_CONFIG }}"
74+
fi
75+
if [ ! -e "${{ env.SNAPSHOTTER_CONFIG }}" ]; then
76+
echo "Installing ${{ env.SOURCE_SNAPSHOTTER_CONFIG }} to ${{ env.SNAPSHOTTER_CONFIG }}"
77+
sudo install -D -m 664 "${{ env.SOURCE_SNAPSHOTTER_CONFIG }}" "${{ env.SNAPSHOTTER_CONFIG }}"
78+
fi
79+
sudo ln -f -s /etc/nydus/nydusd-config.fusedev.json /etc/nydus/nydusd-config.json
80+
echo "Installing ${{ env.SNAPSHOTTER_SYSTEMD_UNIT_SERVICE }} to /etc/systemd/system/nydus-snapshotter.service"
81+
sudo install -D -m 644 "${{ env.SNAPSHOTTER_SYSTEMD_UNIT_SERVICE }}" /etc/systemd/system/nydus-snapshotter.service
82+
if command -v systemctl >/dev/null; then
83+
sudo systemctl enable /etc/systemd/system/nydus-snapshotter.service
84+
sudo systemctl restart nydus-snapshotter
85+
fi
86+
sleep 5
87+
NYDUS_VER=v$(curl -s "https://api.github.com/repos/dragonflyoss/nydus/releases/latest" | jq -r .tag_name | sed 's/^v//')
88+
wget https://github.com/dragonflyoss/nydus/releases/download/$NYDUS_VER/nydus-static-$NYDUS_VER-linux-amd64.tgz
89+
tar xzvf nydus-static-$NYDUS_VER-linux-amd64.tgz
90+
# sudo systemctl restart nydus-snapshotter.service
91+
sudo install -D -m 755 nydus-static/nydusd /usr/local/bin/nydusd
92+
sudo install -D -m 755 nydus-static/nydus-image /usr/local/bin/nydus-image
93+
sudo install -D -m 755 nydus-static/nydusctl /usr/local/bin/nydusctl
94+
6195
- name: Build and install optimizer
6296
run: |
6397
rustup component add rustfmt clippy
@@ -84,26 +118,48 @@ jobs:
84118
echo "containerd is not ready"
85119
exit 1
86120
fi
121+
- name: Setup prefetch-distribution http server
122+
run: |
123+
go build -o prefetch-distribution tools/prefetch-distribution/main.go
124+
nohup ./prefetch-distribution &
125+
sleep 5
126+
- name: Log in to container registry
127+
uses: docker/login-action@v2
128+
with:
129+
registry: ${{ env.REGISTRY }}
130+
username: ${{ github.actor }}
131+
password: ${{ secrets.GITHUB_TOKEN }}
132+
87133
- name: Generate accessed files list
88134
run: |
89135
sed -i "s|host_path: script|host_path: $(pwd)/misc/optimizer/script|g" misc/optimizer/nginx.yaml
90136
sudo crictl run misc/optimizer/nginx.yaml misc/optimizer/sandbox.yaml
91137
sleep 20
92138
sudo crictl rmp -f --all
139+
sudo crictl rmi --all
93140
tree /opt/nri/optimizer/results/
94-
count=$(cat /opt/nri/optimizer/results/library/nginx:1.23.3 | wc -l)
141+
count=$(cat /opt/nri/optimizer/results/dragonflyoss/image-service/nginx:nydus-latest | wc -l)
95142
expected=$(cat misc/optimizer/script/file_list.txt | wc -l)
96143
echo "count: $count expected minimum value: $expected"
97144
if [ $count -lt $expected ]; then
98-
echo "failed to generate accessed files list for nginx:1.23.3"
145+
echo "failed to generate accessed files list for nginx:nydus-latest"
99146
cat misc/optimizer/script/file_list.txt
100147
exit 1
101148
fi
102-
cat /opt/nri/optimizer/results/library/nginx:1.23.3.csv
149+
cat /opt/nri/optimizer/results/dragonflyoss/image-service/nginx:nydus-latest.csv
150+
- name: Transmit the prefetch list to nydusd
151+
run: |
152+
sed -i "s|host_path: script|host_path: $(pwd)/misc/optimizer/script|g" misc/optimizer/nginx.yaml
153+
sudo crictl run misc/optimizer/nginx.yaml misc/optimizer/sandbox.yaml
154+
if sudo ps aux | grep "[/]usr/local/bin/nydusd" | grep "prefetch-files"; then
155+
echo "Found --prefetch-files in running processes"
156+
else
157+
echo "Error: --prefetch-files not found in running processes"
158+
exit 1
159+
fi
103160
- name: Dump logs
104161
if: failure()
105162
continue-on-error: true
106163
run: |
107164
systemctl status containerd --no-pager -l
108165
journalctl -xeu containerd --no-pager
109-

config/config_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ func TestLoadSnapshotterTOMLConfig(t *testing.T) {
3131
EnableStargz: false,
3232
EnableReferrerDetect: false,
3333
},
34+
PrefetchControllerConfig: PrefetchControllerConfig{
35+
Enable: false,
36+
PrefetchConfig: "http://localhost:1323/api/v1/prefetch",
37+
},
3438
CleanupOnClose: false,
3539
SystemControllerConfig: SystemControllerConfig{
3640
Enable: true,

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

misc/snapshotter/config.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ cleanup_on_close = false
1111

1212
[prefetch]
1313
enable = false
14-
get_prefetch_endpoint = "http://localhost:1323/api/v1/prefetch/download"
14+
distribution_pull_endpoint = "http://localhost:1323/api/v1/prefetch"
1515

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

0 commit comments

Comments
 (0)