Skip to content

Commit e110f40

Browse files
committed
Support converting and pulling zstd:chunked
Signed-off-by: Kohei Tokunaga <[email protected]>
1 parent 526091c commit e110f40

File tree

42 files changed

+2085
-311
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+2085
-311
lines changed

.github/workflows/benchmark.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,16 @@ jobs:
1212
BENCHMARK_LOG_DIR: ${{ github.workspace }}/log/
1313
BENCHMARK_RESULT_DIR: ${{ github.workspace }}/benchmark/
1414
BENCHMARK_REGISTRY: ghcr.io
15-
BENCHMARK_USER: stargz-containers
15+
BENCHMARK_USER: ktock
1616
BENCHMARK_TARGETS: python:3.9 gcc:10.2.0 postgres:13.1 tomcat:10.0.0-jdk15-openjdk-buster
1717
BENCHMARK_SAMPLES_NUM: 5
1818
BENCHMARK_PERCENTILE: 95
1919
BENCHMARK_PERCENTILES_GRANULARITY: 25
20+
strategy:
21+
fail-fast: false
22+
max-parallel: 1
23+
matrix:
24+
runtime: ["podman", "containerd"]
2025
steps:
2126
- name: Install tools
2227
run: |
@@ -31,9 +36,9 @@ jobs:
3136
jq '{ location : .compute.location, vmSize : .compute.vmSize }' | \
3237
tee ${{ env.BENCHMARK_RESULT_DIR }}/instance.json
3338
- name: Run benchmark
34-
run: make benchmark
39+
run: make benchmark-${{ matrix.runtime }}
3540
- uses: actions/upload-artifact@v1
3641
if: ${{ always() }}
3742
with:
38-
name: benchmarking-result
43+
name: benchmarking-result-${{ matrix.runtime }}
3944
path: ${{ env.BENCHMARK_RESULT_DIR }}

.github/workflows/tests.yml

Lines changed: 0 additions & 128 deletions
This file was deleted.

Dockerfile

Lines changed: 79 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,16 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
ARG CONTAINERD_VERSION=v1.4.3
16-
ARG RUNC_VERSION=v1.0.0-rc92
15+
ARG CONTAINERD_VERSION=v1.5.0-beta.2
16+
ARG RUNC_VERSION=v1.0.0-rc93
1717
ARG CNI_PLUGINS_VERSION=v0.9.0
1818
ARG NERDCTL_VERSION=0.6.0
19+
ARG PODMAN_VERSION=2314af70bdacf75135a11b48b87dba8e461a43ea
20+
ARG CONTAINERS_IMAGE_VERSION=1d45144111969eb7160be0fd32a82ada5f3bca7a
21+
ARG CONTAINERS_STORAGE_VERSION=4d4212f14a5cc5256b330e08e9f4c770a14c0a04
22+
ARG CRUN_VERSION=0.17
23+
ARG CONMON_VERSION=v2.0.26
24+
ARG SKOPEO_VERSION=v1.2.2
1925

2026
# Legacy builder that doesn't support TARGETARCH should set this explicitly using --build-arg.
2127
# If TARGETARCH isn't supported by the builder, the default value is "amd64".
@@ -65,6 +71,55 @@ RUN cd $GOPATH/src/github.com/containerd/stargz-snapshotter && \
6571
PREFIX=/out/ GOARCH=${TARGETARCH:-amd64} GO_BUILD_FLAGS=${SNAPSHOTTER_BUILD_FLAGS} make containerd-stargz-grpc && \
6672
PREFIX=/out/ GOARCH=${TARGETARCH:-amd64} GO_BUILD_FLAGS=${CTR_REMOTE_BUILD_FLAGS} make ctr-remote
6773

74+
# Build registry storage
75+
FROM golang-base AS registry-storage-dev
76+
ARG TARGETARCH
77+
ARG GOARM
78+
ARG SNAPSHOTTER_BUILD_FLAGS
79+
ARG CTR_REMOTE_BUILD_FLAGS
80+
COPY . $GOPATH/src/github.com/containerd/stargz-snapshotter
81+
RUN cd $GOPATH/src/github.com/containerd/stargz-snapshotter && \
82+
PREFIX=/out/ GOARCH=${TARGETARCH:-amd64} GO_BUILD_FLAGS=${SNAPSHOTTER_BUILD_FLAGS} make registry-storage
83+
84+
# Build podman
85+
FROM golang-base AS podman-dev
86+
ARG PODMAN_VERSION
87+
ARG CONTAINERS_IMAGE_VERSION
88+
ARG CONTAINERS_STORAGE_VERSION
89+
RUN apt-get update -y && apt-get install -y libseccomp-dev libgpgme-dev && \
90+
git clone https://github.com/ktock/storage $GOPATH/src/github.com/containers/storage && \
91+
cd $GOPATH/src/github.com/containers/storage && \
92+
git checkout ${CONTAINERS_STORAGE_VERSION} && \
93+
git clone https://github.com/ktock/image $GOPATH/src/github.com/containers/image && \
94+
cd $GOPATH/src/github.com/containers/image && \
95+
git checkout ${CONTAINERS_IMAGE_VERSION} && \
96+
git clone https://github.com/containers/podman $GOPATH/src/github.com/containers/podman && \
97+
cd $GOPATH/src/github.com/containers/podman && \
98+
git checkout ${PODMAN_VERSION} && \
99+
sed -i "s/-mod=vendor//g" $GOPATH/src/github.com/containers/podman/Makefile && \
100+
echo "replace github.com/containers/image/v5 => /go/src/github.com/containers/image\nreplace github.com/containers/storage => /go/src/github.com/containers/storage" >> $GOPATH/src/github.com/containers/podman/go.mod && \
101+
make && make install PREFIX=/out/
102+
103+
# Build crun
104+
FROM golang-base AS crun-dev
105+
ARG CRUN_VERSION
106+
RUN apt-get update -y && apt-get install -y make git gcc build-essential pkgconf libtool \
107+
libsystemd-dev libcap-dev libseccomp-dev libyajl-dev \
108+
go-md2man libtool autoconf python3 automake && \
109+
git clone -b ${CRUN_VERSION} --depth 1 \
110+
https://github.com/containers/crun $GOPATH/src/github.com/containers/crun && \
111+
cd $GOPATH/src/github.com/containers/crun && \
112+
./autogen.sh && ./configure --prefix=/out/ && make && make install
113+
114+
# Build conmon
115+
FROM golang-base AS conmon-dev
116+
ARG CONMON_VERSION
117+
RUN apt-get update -y && apt-get install -y gcc git libc6-dev libglib2.0-dev pkg-config make && \
118+
git clone -b ${CONMON_VERSION} --depth 1 \
119+
https://github.com/containers/conmon $GOPATH/src/github.com/containers/conmon && \
120+
cd $GOPATH/src/github.com/containers/conmon && \
121+
mkdir /out/ && make && make install PREFIX=/out/
122+
68123
# Binaries for release
69124
FROM scratch AS release-binaries
70125
COPY --from=snapshotter-dev /out/* /
@@ -98,6 +153,28 @@ COPY --from=runc-dev /out/sbin/* /usr/local/sbin/
98153
COPY --from=snapshotter-dev /out/ctr-remote /usr/local/bin/
99154
RUN ln -s /usr/local/bin/ctr-remote /usr/local/bin/ctr
100155

156+
# Base image which contains podman with registry-storage
157+
FROM golang-base AS podman-base
158+
ARG TARGETARCH
159+
ARG CNI_PLUGINS_VERSION
160+
ARG PODMAN_VERSION
161+
ARG SKOPEO_VERSION
162+
RUN apt-get update -y && apt-get --no-install-recommends install -y fuse libgpgme-dev \
163+
iptables libyajl-dev && \
164+
# Make CNI plugins manipulate iptables instead of nftables
165+
# as this test runs in a Docker container that network is configured with iptables.
166+
# c.f. https://github.com/moby/moby/issues/26824
167+
update-alternatives --set iptables /usr/sbin/iptables-legacy && \
168+
mkdir -p /etc/containers /etc/cni/net.d /opt/cni/bin && \
169+
curl -L -o /etc/containers/policy.json https://raw.githubusercontent.com/containers/skopeo/${SKOPEO_VERSION}/default-policy.json && \
170+
curl -qsSL https://raw.githubusercontent.com/containers/podman/${PODMAN_VERSION}/cni/87-podman-bridge.conflist | tee /etc/cni/net.d/87-podman-bridge.conflist && \
171+
curl -Ls https://github.com/containernetworking/plugins/releases/download/${CNI_PLUGINS_VERSION}/cni-plugins-linux-${TARGETARCH:-amd64}-${CNI_PLUGINS_VERSION}.tgz | tar xzv -C /opt/cni/bin
172+
173+
COPY --from=podman-dev /out/bin/* /usr/local/bin/
174+
COPY --from=crun-dev /out/bin/* /usr/local/bin/
175+
COPY --from=conmon-dev /out/bin/* /usr/local/bin/
176+
COPY --from=registry-storage-dev /out/* /usr/local/bin/
177+
101178
# Image which can be used as all-in-one single node demo environment
102179
FROM snapshotter-base AS cind
103180
COPY ./script/config/ /

Makefile

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ build: $(CMD)
3636
FORCE:
3737

3838
containerd-stargz-grpc: FORCE
39-
GO111MODULE=$(GO111MODULE_VALUE) go build -o $(PREFIX)$@ $(GO_BUILD_FLAGS) $(GO_LD_FLAGS) -v ./cmd/containerd-stargz-grpc
39+
CGO_ENABLED=0 GO111MODULE=$(GO111MODULE_VALUE) go build -o $(PREFIX)$@ $(GO_BUILD_FLAGS) $(GO_LD_FLAGS) -v ./cmd/containerd-stargz-grpc
4040

4141
ctr-remote: FORCE
42-
GO111MODULE=$(GO111MODULE_VALUE) go build -o $(PREFIX)$@ $(GO_BUILD_FLAGS) $(GO_LD_FLAGS) -v ./cmd/ctr-remote
42+
CGO_ENABLED=0 GO111MODULE=$(GO111MODULE_VALUE) go build -o $(PREFIX)$@ $(GO_BUILD_FLAGS) $(GO_LD_FLAGS) -v ./cmd/ctr-remote
4343

4444
registry-storage: FORCE
45-
GO111MODULE=$(GO111MODULE_VALUE) go build -o $(PREFIX)$@ $(GO_BUILD_FLAGS) $(GO_LD_FLAGS) -v ./cmd/registry-storage
45+
CGO_ENABLED=0 GO111MODULE=$(GO111MODULE_VALUE) go build -o $(PREFIX)$@ $(GO_BUILD_FLAGS) $(GO_LD_FLAGS) -v ./cmd/registry-storage
4646

4747
check:
4848
@echo "$@"
@@ -82,9 +82,12 @@ integration:
8282
test-optimize:
8383
@./script/optimize/test.sh
8484

85-
benchmark:
85+
benchmark-containerd:
8686
@./script/benchmark/test.sh
8787

88+
benchmark-podman:
89+
@./script/benchmark2/test.sh
90+
8891
test-pullsecrets:
8992
@./script/pullsecrets/test.sh
9093

cmd/ctr-remote/commands/convert.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
"github.com/containerd/containerd/platforms"
2929
"github.com/containerd/stargz-snapshotter/estargz"
3030
estargzconvert "github.com/containerd/stargz-snapshotter/nativeconverter/estargz"
31+
zstdchunkedconvert "github.com/containerd/stargz-snapshotter/nativeconverter/zstdchunked"
3132
"github.com/containerd/stargz-snapshotter/recorder"
3233
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
3334
"github.com/pkg/errors"
@@ -66,6 +67,11 @@ When '--all-platforms' is given all images in a manifest list must be available.
6667
Usage: "eStargz chunk size",
6768
Value: 0,
6869
},
70+
// zstd:chunked flags
71+
cli.BoolFlag{
72+
Name: "zstdchunked",
73+
Usage: "convert legacy tar(.gz) layers to zstd:chunked for lazy pulling. Must be used in conjunction with '--oci'",
74+
},
6975
// generic flags
7076
cli.BoolFlag{
7177
Name: "uncompress",
@@ -124,6 +130,19 @@ When '--all-platforms' is given all images in a manifest list must be available.
124130
if context.Bool("uncompress") {
125131
return errors.New("option --estargz conflicts with --uncompress")
126132
}
133+
if context.Bool("zstdchunked") {
134+
return errors.New("option --estargz conflicts with --zstdchunked")
135+
}
136+
}
137+
138+
if context.Bool("zstdchunked") {
139+
convertOpts = append(convertOpts, converter.WithLayerConvertFunc(zstdchunkedconvert.LayerConvertFunc()))
140+
if !context.Bool("oci") {
141+
return errors.New("option --zstdchunked must be used in conjunction with --oci")
142+
}
143+
if context.Bool("uncompress") {
144+
return errors.New("option --zstdchunked conflicts with --uncompress")
145+
}
127146
}
128147

129148
if context.Bool("uncompress") {

cmd/registry-storage/fs.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ const (
3636
defaultLinkMode = syscall.S_IFLNK | 0400 // -r--------
3737
defaultDirMode = syscall.S_IFDIR | 0500 // dr-x------
3838

39+
poolLink = "pool"
3940
chainLink = "chain"
4041
layerLink = "diff"
4142
debugManifestLink = "manifest"
@@ -57,6 +58,11 @@ var _ = (fusefs.NodeLookuper)((*rootnode)(nil))
5758
// Lookup loads manifest and config of specified name (imgae reference)
5859
// and returns refnode of the specified name
5960
func (n *rootnode) Lookup(ctx context.Context, name string, out *fuse.EntryOut) (*fusefs.Inode, syscall.Errno) {
61+
switch name {
62+
case poolLink:
63+
return n.NewInode(ctx,
64+
&linknode{linkname: n.pool.root()}, defaultLinkAttr(&out.Attr)), 0
65+
}
6066
refBytes, err := base64.StdEncoding.DecodeString(name)
6167
if err != nil {
6268
log.G(ctx).WithError(err).Debugf("failed to decode ref base64 %q", name)
@@ -132,6 +138,7 @@ func (n *refnode) Lookup(ctx context.Context, name string, out *fuse.EntryOut) (
132138
pool: n.pool,
133139
layer: chain[len(chain)-1],
134140
chain: chain,
141+
layers: n.manifest.Layers,
135142
refnode: n,
136143
}, defaultDirAttr(&out.Attr)), 0
137144
}
@@ -165,8 +172,9 @@ type layernode struct {
165172
fusefs.Inode
166173
pool *pool
167174

168-
layer ocispec.Descriptor
169-
chain []ocispec.Descriptor
175+
layer ocispec.Descriptor
176+
chain []ocispec.Descriptor
177+
layers []ocispec.Descriptor
170178

171179
refnode *refnode
172180
}
@@ -204,7 +212,7 @@ func (n *layernode) Lookup(ctx context.Context, name string, out *fuse.EntryOut)
204212
}
205213
case layerLink:
206214
var layers []string
207-
for _, l := range n.chain {
215+
for _, l := range n.layers {
208216
if images.IsLayerType(l.MediaType) {
209217
layers = append(layers, l.Digest.String())
210218
}

0 commit comments

Comments
 (0)