Skip to content

Commit 9f0a458

Browse files
committed
feat: adding support for lazy-pulling with soci in pull and run command
Signed-off-by: Channing Gaddy <[email protected]>
1 parent a797372 commit 9f0a458

10 files changed

+240
-20
lines changed

Dockerfile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ ARG UBUNTU_VERSION=22.04
4949
ARG CONTAINERIZED_SYSTEMD_VERSION=v0.1.1
5050
ARG GOTESTSUM_VERSION=v1.10.0
5151
ARG NYDUS_VERSION=v2.2.1
52+
ARG SOCI_SNAPSHOTTER_VERSION=0.3.0
5253

5354
FROM --platform=$BUILDPLATFORM tonistiigi/xx:1.2.1 AS xx
5455

@@ -282,13 +283,21 @@ VOLUME /tmp
282283
ENV CGO_ENABLED=0
283284
# copy cosign binary for integration test
284285
COPY --from=gcr.io/projectsigstore/cosign:v2.0.0@sha256:728944a9542a7235b4358c4ab2bcea855840e9d4b9594febca5c2207f5da7f38 /ko-app/cosign /usr/local/bin/cosign
286+
# installing soci for integration test
287+
ARG SOCI_SNAPSHOTTER_VERSION
288+
RUN fname="soci-snapshotter-${SOCI_SNAPSHOTTER_VERSION}-${TARGETOS:-linux}-${TARGETARCH:-amd64}.tar.gz" && \
289+
curl -o "${fname}" -fSL "https://github.com/awslabs/soci-snapshotter/releases/download/v${SOCI_SNAPSHOTTER_VERSION}/${fname}" && \
290+
tar -C /usr/local/bin -xvf "${fname}" soci soci-snapshotter-grpc
285291
# enable offline ipfs for integration test
286292
COPY ./Dockerfile.d/test-integration-etc_containerd-stargz-grpc_config.toml /etc/containerd-stargz-grpc/config.toml
287293
COPY ./Dockerfile.d/test-integration-ipfs-offline.service /usr/local/lib/systemd/system/
288294
COPY ./Dockerfile.d/test-integration-buildkit-nerdctl-test.service /usr/local/lib/systemd/system/
295+
COPY ./Dockerfile.d/test-integration-soci-snapshotter.service /usr/local/lib/systemd/system/
289296
RUN cp /usr/local/bin/tini /usr/local/bin/tini-custom
297+
# using test integration containerd config
298+
COPY ./Dockerfile.d/test-integration-etc_containerd_config.toml /etc/containerd/config.toml
290299
# install ipfs service. avoid using 5001(api)/8080(gateway) which are reserved by tests.
291-
RUN systemctl enable test-integration-ipfs-offline test-integration-buildkit-nerdctl-test && \
300+
RUN systemctl enable test-integration-ipfs-offline test-integration-buildkit-nerdctl-test test-integration-soci-snapshotter && \
292301
ipfs init && \
293302
ipfs config Addresses.API "/ip4/127.0.0.1/tcp/5888" && \
294303
ipfs config Addresses.Gateway "/ip4/127.0.0.1/tcp/5889"
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
version = 2
2+
3+
# Enable stargz snapshotter
4+
[proxy_plugins]
5+
[proxy_plugins.stargz]
6+
type = "snapshot"
7+
address = "/run/containerd-stargz-grpc/containerd-stargz-grpc.sock"
8+
9+
# Enable soci snapshotter
10+
[proxy_plugins.soci]
11+
type = "snapshot"
12+
address = "/run/soci-snapshotter-grpc/soci-snapshotter-grpc.sock"
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[Unit]
2+
Description=soci snapshotter containerd plugin for integration test
3+
Documentation=https://github.com/awslabs/soci-snapshotter
4+
After=network.target
5+
Before=containerd.service
6+
7+
[Service]
8+
Type=notify
9+
ExecStartPre=/bin/bash -c 'mkdir -p /var/lib/soci-snapshotter-grpc && mount -t tmpfs none /var/lib/soci-snapshotter-grpc'
10+
ExecStart=/usr/local/bin/soci-snapshotter-grpc
11+
Restart=always
12+
RestartSec=5
13+
14+
[Install]
15+
WantedBy=docker-entrypoint.target
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
/*
2+
Copyright The containerd Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package main
18+
19+
import (
20+
"os"
21+
"os/exec"
22+
"strings"
23+
"testing"
24+
25+
"github.com/containerd/nerdctl/pkg/testutil"
26+
)
27+
28+
func TestRunSoci(t *testing.T) {
29+
testutil.DockerIncompatible(t)
30+
base := testutil.NewBase(t)
31+
requiresSoci(base)
32+
33+
//counting initial snapshot mounts
34+
initialMounts, err := exec.Command("mount").Output()
35+
if err != nil {
36+
t.Fatal(err)
37+
}
38+
39+
remoteSnapshotsInitialCount := strings.Count(string(initialMounts), "fuse.rawBridge")
40+
41+
if remoteSnapshotsInitialCount != 0 {
42+
t.Fatalf("initial mounts count isn't zero")
43+
}
44+
45+
//validating `nerdctl --snapshotter=soci run` and `soci rpull` behave the same using mounts
46+
runOutput := base.Cmd("--snapshotter=soci", "run", "--rm", testutil.FfmpegSociImage).Out()
47+
base.T.Logf("run output: %s", runOutput)
48+
49+
actualMounts, err := exec.Command("mount").Output()
50+
if err != nil {
51+
t.Fatal(err)
52+
}
53+
remoteSnapshotsActualCount := strings.Count(string(actualMounts), "fuse.rawBridge")
54+
base.T.Logf("number of actual mounts: %v", remoteSnapshotsActualCount)
55+
56+
rmiOutput := base.Cmd("rmi", testutil.FfmpegSociImage).Out()
57+
base.T.Logf("rmi output: %s", rmiOutput)
58+
59+
sociExecutable, err := exec.LookPath("soci")
60+
if err != nil {
61+
t.Fatalf("SOCI is not installed.")
62+
}
63+
64+
rpullCmd := exec.Command(sociExecutable, []string{"image", "rpull", testutil.FfmpegSociImage}...)
65+
66+
rpullCmd.Env = os.Environ()
67+
68+
err = rpullCmd.Run()
69+
if err != nil {
70+
t.Fatal(err)
71+
}
72+
73+
expectedMounts, err := exec.Command("mount").Output()
74+
if err != nil {
75+
t.Fatal(err)
76+
}
77+
78+
remoteSnapshotsExpectedCount := strings.Count(string(expectedMounts), "fuse.rawBridge")
79+
base.T.Logf("number of expected mounts: %v", remoteSnapshotsExpectedCount)
80+
81+
if remoteSnapshotsExpectedCount != remoteSnapshotsActualCount {
82+
t.Fatalf("incorrect number of remote snapshots; expected=%d, actual=%d",
83+
remoteSnapshotsExpectedCount, remoteSnapshotsActualCount)
84+
}
85+
}
86+
87+
func requiresSoci(base *testutil.Base) {
88+
info := base.Info()
89+
for _, p := range info.Plugins.Storage {
90+
if p == "soci" {
91+
return
92+
}
93+
}
94+
base.T.Skip("test requires soci")
95+
}

cmd/nerdctl/image_pull_linux_test.go

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,3 +145,58 @@ CMD ["echo", "nerdctl-build-test-string"]
145145
newKeyPair := newCosignKeyPair(t, "cosign-key-pair-test")
146146
base.Cmd("pull", testImageRef, "--verify=cosign", "--cosign-key="+newKeyPair.publicKey).AssertFail()
147147
}
148+
149+
func TestPullSoci(t *testing.T) {
150+
testutil.DockerIncompatible(t)
151+
base := testutil.NewBase(t)
152+
requiresSoci(base)
153+
154+
//counting initial snapshot mounts
155+
initialMounts, err := exec.Command("mount").Output()
156+
if err != nil {
157+
t.Fatal(err)
158+
}
159+
160+
remoteSnapshotsInitialCount := strings.Count(string(initialMounts), "fuse.rawBridge")
161+
162+
//validating `nerdctl --snapshotter=soci pull` and `soci rpull` behave the same using mounts
163+
pullOutput := base.Cmd("--snapshotter=soci", "pull", testutil.FfmpegSociImage).Out()
164+
base.T.Logf("pull output: %s", pullOutput)
165+
166+
actualMounts, err := exec.Command("mount").Output()
167+
if err != nil {
168+
t.Fatal(err)
169+
}
170+
remoteSnapshotsActualCount := strings.Count(string(actualMounts), "fuse.rawBridge")
171+
base.T.Logf("number of actual mounts: %v", remoteSnapshotsActualCount)
172+
173+
rmiOutput := base.Cmd("rmi", testutil.FfmpegSociImage).Out()
174+
base.T.Logf("rmi output: %s", rmiOutput)
175+
176+
sociExecutable, err := exec.LookPath("soci")
177+
if err != nil {
178+
t.Fatalf("SOCI is not installed.")
179+
}
180+
181+
rpullCmd := exec.Command(sociExecutable, []string{"image", "rpull", testutil.FfmpegSociImage}...)
182+
183+
rpullCmd.Env = os.Environ()
184+
185+
err = rpullCmd.Run()
186+
if err != nil {
187+
t.Fatal(err)
188+
}
189+
190+
expectedMounts, err := exec.Command("mount").Output()
191+
if err != nil {
192+
t.Fatal(err)
193+
}
194+
195+
remoteSnapshotsExpectedCount := strings.Count(string(expectedMounts), "fuse.rawBridge")
196+
base.T.Logf("number of expected mounts: %v", remoteSnapshotsExpectedCount)
197+
198+
if remoteSnapshotsExpectedCount != (remoteSnapshotsActualCount - remoteSnapshotsInitialCount) {
199+
t.Fatalf("incorrect number of remote snapshots; expected=%d, actual=%d",
200+
remoteSnapshotsExpectedCount, remoteSnapshotsActualCount)
201+
}
202+
}

go.mod

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ require (
66
github.com/Masterminds/semver/v3 v3.2.1
77
github.com/Microsoft/go-winio v0.6.1
88
github.com/Microsoft/hcsshim v0.10.0-rc.9
9+
github.com/awslabs/soci-snapshotter v0.3.0
910
github.com/compose-spec/compose-go v1.17.0
1011
github.com/containerd/accelerated-container-image v0.6.7
1112
github.com/containerd/cgroups/v3 v3.0.2
@@ -68,7 +69,7 @@ require (
6869

6970
require (
7071
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230106234847-43070de90fa1 // indirect
71-
github.com/AdamKorcz/go-118-fuzz-build v0.0.0-20221215162035-5330a85ea652 // indirect
72+
github.com/AdamKorcz/go-118-fuzz-build v0.0.0-20230306123547-8075edf89bb0 // indirect
7273
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
7374
github.com/cilium/ebpf v0.9.1 // indirect
7475
github.com/containerd/cgroups v1.1.0 // indirect
@@ -125,12 +126,12 @@ require (
125126
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
126127
go.mozilla.org/pkcs7 v0.0.0-20200128120323-432b2356ecb1 // indirect
127128
go.opencensus.io v0.24.0 // indirect
128-
go.opentelemetry.io/otel v1.14.0 // indirect
129-
go.opentelemetry.io/otel/trace v1.14.0 // indirect
129+
go.opentelemetry.io/otel v1.15.1 // indirect
130+
go.opentelemetry.io/otel/trace v1.15.1 // indirect
130131
golang.org/x/mod v0.11.0 // indirect
131-
golang.org/x/tools v0.8.0 // indirect
132-
google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4 // indirect
133-
google.golang.org/grpc v1.54.0 // indirect
132+
golang.org/x/tools v0.9.1 // indirect
133+
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
134+
google.golang.org/grpc v1.55.0 // indirect
134135
google.golang.org/protobuf v1.30.0 // indirect
135136
gopkg.in/square/go-jose.v2 v2.5.1 // indirect
136137
lukechampine.com/blake3 v1.1.7 // indirect

go.sum

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7
4242
github.com/AdaLogics/go-fuzz-headers v0.0.0-20210715213245-6c3934b029d8/go.mod h1:CzsSbkDixRphAF5hS6wbMKq0eI6ccJRb7/A0M6JBnwg=
4343
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230106234847-43070de90fa1 h1:EKPd1INOIyr5hWOWhvpmQpY6tKjeG0hT1s3AMC/9fic=
4444
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230106234847-43070de90fa1/go.mod h1:VzwV+t+dZ9j/H867F1M2ziD+yLHtB46oM35FxxMJ4d0=
45-
github.com/AdamKorcz/go-118-fuzz-build v0.0.0-20221215162035-5330a85ea652 h1:+vTEFqeoeur6XSq06bs+roX3YiT49gUniJK7Zky7Xjg=
46-
github.com/AdamKorcz/go-118-fuzz-build v0.0.0-20221215162035-5330a85ea652/go.mod h1:OahwfttHWG6eJ0clwcfBAHoDI6X/LV/15hx/wlMZSrU=
45+
github.com/AdamKorcz/go-118-fuzz-build v0.0.0-20230306123547-8075edf89bb0 h1:59MxjQVfjXsBpLy+dbd2/ELV5ofnUkUZBvWSC85sheA=
46+
github.com/AdamKorcz/go-118-fuzz-build v0.0.0-20230306123547-8075edf89bb0/go.mod h1:OahwfttHWG6eJ0clwcfBAHoDI6X/LV/15hx/wlMZSrU=
4747
github.com/Azure/azure-sdk-for-go v16.2.1+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc=
4848
github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8=
4949
github.com/Azure/go-ansiterm v0.0.0-20210608223527-2377c96fe795/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8=
@@ -117,6 +117,8 @@ github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmV
117117
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
118118
github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY=
119119
github.com/aws/aws-sdk-go v1.15.11/go.mod h1:mFuSZ37Z9YOHbQEwBWztmVzqXrEkub65tZoCYDt7FT0=
120+
github.com/awslabs/soci-snapshotter v0.3.0 h1:DcVedf88R8GO77WhJn/dusQqzCrjrh1RWBataW6pVV8=
121+
github.com/awslabs/soci-snapshotter v0.3.0/go.mod h1:s3cGc7hKDMefFbTf4YGzxRC9Q9nm2E/IU+65ExdRbvA=
120122
github.com/benbjohnson/clock v1.0.3/go.mod h1:bGMdMPoPVvcYyt1gHDf4J2KE153Yf9BuiUKYMaxlTDM=
121123
github.com/beorn7/perks v0.0.0-20160804104726-4c0e84591b9a/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
122124
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
@@ -1049,8 +1051,8 @@ go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.2
10491051
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.20.0/go.mod h1:2AboqHi0CiIZU0qwhtUfCYD1GeUzvvIXWNkhDt7ZMG4=
10501052
go.opentelemetry.io/otel v0.20.0/go.mod h1:Y3ugLH2oa81t5QO+Lty+zXf8zC9L26ax4Nzoxm/dooo=
10511053
go.opentelemetry.io/otel v1.3.0/go.mod h1:PWIKzi6JCp7sM0k9yZ43VX+T345uNbAkDKwHVjb2PTs=
1052-
go.opentelemetry.io/otel v1.14.0 h1:/79Huy8wbf5DnIPhemGB+zEPVwnN6fuQybr/SRXa6hM=
1053-
go.opentelemetry.io/otel v1.14.0/go.mod h1:o4buv+dJzx8rohcUeRmWUZhqupFvzWis188WlggnNeU=
1054+
go.opentelemetry.io/otel v1.15.1 h1:3Iwq3lfRByPaws0f6bU3naAqOR1n5IeDWd9390kWHa8=
1055+
go.opentelemetry.io/otel v1.15.1/go.mod h1:mHHGEHVDLal6YrKMmk9LqC4a3sF5g+fHfrttQIB1NTc=
10541056
go.opentelemetry.io/otel/exporters/otlp v0.20.0/go.mod h1:YIieizyaN77rtLJra0buKiNBOm9XQfkPEKBeuhoMwAM=
10551057
go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.3.0/go.mod h1:VpP4/RMn8bv8gNo9uK7/IMY4mtWLELsS+JIP0inH0h4=
10561058
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.3.0/go.mod h1:hO1KLR7jcKaDDKDkvI9dP/FIhpmna5lkqPUQdEjFAM8=
@@ -1064,8 +1066,8 @@ go.opentelemetry.io/otel/sdk/export/metric v0.20.0/go.mod h1:h7RBNMsDJ5pmI1zExLi
10641066
go.opentelemetry.io/otel/sdk/metric v0.20.0/go.mod h1:knxiS8Xd4E/N+ZqKmUPf3gTTZ4/0TjTXukfxjzSTpHE=
10651067
go.opentelemetry.io/otel/trace v0.20.0/go.mod h1:6GjCW8zgDjwGHGa6GkyeB8+/5vjT16gUEi0Nf1iBdgw=
10661068
go.opentelemetry.io/otel/trace v1.3.0/go.mod h1:c/VDhno8888bvQYmbYLqe41/Ldmr/KKunbvWM4/fEjk=
1067-
go.opentelemetry.io/otel/trace v1.14.0 h1:wp2Mmvj41tDsyAJXiWDWpfNsOiIyd38fy85pyKcFq/M=
1068-
go.opentelemetry.io/otel/trace v1.14.0/go.mod h1:8avnQLK+CG77yNLUae4ea2JDQ6iT+gozhnZjy/rw9G8=
1069+
go.opentelemetry.io/otel/trace v1.15.1 h1:uXLo6iHJEzDfrNC0L0mNjItIp06SyaBQxu5t3xMlngY=
1070+
go.opentelemetry.io/otel/trace v1.15.1/go.mod h1:IWdQG/5N1x7f6YUlmdLeJvH9yxtuJAfc4VW5Agv9r/8=
10691071
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
10701072
go.opentelemetry.io/proto/otlp v0.11.0/go.mod h1:QpEjXPrNQzrFDZgoTo49dgHR9RYRSrg3NAKnUGl9YpQ=
10711073
go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
@@ -1416,8 +1418,8 @@ golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
14161418
golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
14171419
golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
14181420
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
1419-
golang.org/x/tools v0.8.0 h1:vSDcovVPld282ceKgDimkRSC8kpaH1dgyc9UMzlt84Y=
1420-
golang.org/x/tools v0.8.0/go.mod h1:JxBZ99ISMI5ViVkT1tr6tdNmXeTrcpVSD3vZ1RsRdN4=
1421+
golang.org/x/tools v0.9.1 h1:8WMNJAz3zrtPmnYC7ISf5dEn3MT0gY7jBJfw27yrrLo=
1422+
golang.org/x/tools v0.9.1/go.mod h1:owI94Op576fPu3cIGQeHs3joujW/2Oc6MtlxbF5dfNc=
14211423
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
14221424
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
14231425
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
@@ -1501,8 +1503,8 @@ google.golang.org/genproto v0.0.0-20210402141018-6c239bbf2bb1/go.mod h1:9lPAdzaE
15011503
google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0=
15021504
google.golang.org/genproto v0.0.0-20210831024726-fe130286e0e2/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY=
15031505
google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc=
1504-
google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4 h1:DdoeryqhaXp1LtT/emMP1BRJPHHKFi5akj/nbx/zNTA=
1505-
google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4/go.mod h1:NWraEVixdDnqcqQ30jipen1STv2r/n24Wb7twVTGR4s=
1506+
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 h1:KpwkzHKEF7B9Zxg18WzOa7djJ+Ha5DzthMyZYQfEn2A=
1507+
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1/go.mod h1:nKE/iIaLqn2bQwXBg8f1g2Ylh6r5MN5CmZvuzZCgsCU=
15061508
google.golang.org/grpc v0.0.0-20160317175043-d3ddb4469d5a/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw=
15071509
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
15081510
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
@@ -1531,8 +1533,8 @@ google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQ
15311533
google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34=
15321534
google.golang.org/grpc v1.42.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU=
15331535
google.golang.org/grpc v1.43.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU=
1534-
google.golang.org/grpc v1.54.0 h1:EhTqbhiYeixwWQtAEZAxmV9MGqcjEU2mFx52xCzNyag=
1535-
google.golang.org/grpc v1.54.0/go.mod h1:PUSEXI6iWghWaB6lXM4knEgpJNu2qUcKfDtNci3EC2g=
1536+
google.golang.org/grpc v1.55.0 h1:3Oj82/tFSCeUrRTg/5E/7d/W5A1tj6Ky1ABAuZuv5ag=
1537+
google.golang.org/grpc v1.55.0/go.mod h1:iYEXKGkEBhg1PjZQvoYEVPTDkHo1/bjTnfwTeGONTY8=
15361538
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
15371539
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
15381540
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=

pkg/imgutil/snapshotter.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package imgutil
1919
import (
2020
"strings"
2121

22+
socisource "github.com/awslabs/soci-snapshotter/fs/source"
2223
"github.com/containerd/containerd"
2324
"github.com/containerd/containerd/images"
2425
ctdsnapshotters "github.com/containerd/containerd/pkg/snapshotters"
@@ -31,6 +32,7 @@ const (
3132
snapshotterNameOverlaybd = "overlaybd"
3233
snapshotterNameStargz = "stargz"
3334
snapshotterNameNydus = "nydus"
35+
snapshotterNameSoci = "soci"
3436

3537
// prefetch size for stargz
3638
prefetchSize = 10 * 1024 * 1024
@@ -41,6 +43,7 @@ var builtinRemoteSnapshotterOpts = map[string]snapshotterOpts{
4143
snapshotterNameOverlaybd: &remoteSnapshotterOpts{snapshotter: "overlaybd"},
4244
snapshotterNameStargz: &remoteSnapshotterOpts{snapshotter: "stargz", extraLabels: stargzExtraLabels},
4345
snapshotterNameNydus: &remoteSnapshotterOpts{snapshotter: "nydus"},
46+
snapshotterNameSoci: &remoteSnapshotterOpts{snapshotter: "soci", extraLabels: sociExtraLabels},
4447
}
4548

4649
// snapshotterOpts is used to update pull config
@@ -107,3 +110,7 @@ func (dsn *defaultSnapshotterOpts) isRemote() bool {
107110
func stargzExtraLabels(f func(images.Handler) images.Handler) func(images.Handler) images.Handler {
108111
return source.AppendExtraLabelsHandler(prefetchSize, f)
109112
}
113+
114+
func sociExtraLabels(f func(images.Handler) images.Handler) func(images.Handler) images.Handler {
115+
return socisource.AppendDefaultLabelsHandlerWrapper("", f)
116+
}

pkg/imgutil/snapshotter_test.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ func TestGetSnapshotterOpts(t *testing.T) {
5252
sns: []string{"stargz", "stargz-v1"},
5353
check: remoteSnOpts("stargz", true),
5454
},
55+
{
56+
sns: []string{"soci"},
57+
check: remoteSnOpts("soci", true),
58+
},
5559
{
5660
sns: []string{"overlaybd", "overlaybd-v2"},
5761
check: sameOpts(&remoteSnapshotterOpts{snapshotter: "overlaybd"}),
@@ -132,6 +136,12 @@ func TestRemoteSnapshotterOpts(t *testing.T) {
132136
checkRemoteSnapshotterAnnotataions, checkStargzSnapshotterAnnotataions,
133137
},
134138
},
139+
{
140+
name: "soci",
141+
check: []func(t *testing.T, a map[string]string){
142+
checkRemoteSnapshotterAnnotataions, checkSociSnapshotterAnnotataions,
143+
},
144+
},
135145
{
136146
name: "nydus",
137147
check: []func(t *testing.T, a map[string]string){checkRemoteSnapshotterAnnotataions},
@@ -175,3 +185,16 @@ func checkStargzSnapshotterAnnotataions(t *testing.T, a map[string]string) {
175185
_, ok := a["containerd.io/snapshot/remote/urls"]
176186
assert.Equal(t, ok, true)
177187
}
188+
189+
// using values from soci source to check for annotations (
190+
// see https://github.com/awslabs/soci-snapshotter/blob/b05ba712d246ecc5146469f87e5e9305702fd72b/fs/source/source.go#L80C1-L80C6
191+
func checkSociSnapshotterAnnotataions(t *testing.T, a map[string]string) {
192+
assert.Check(t, a != nil)
193+
_, ok := a["containerd.io/snapshot/remote/soci.size"]
194+
assert.Equal(t, ok, true)
195+
_, ok = a["containerd.io/snapshot/remote/image.layers.size"]
196+
assert.Equal(t, ok, true)
197+
_, ok = a["containerd.io/snapshot/remote/soci.index.digest"]
198+
assert.Equal(t, ok, true)
199+
200+
}

0 commit comments

Comments
 (0)