Skip to content

Commit f528b02

Browse files
authoredJan 17, 2025··
Merge pull request #3828 from AkihiroSuda/containerd-v2
update containerd to v2.0.2
2 parents 82a216b + 586b038 commit f528b02

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed
 

‎images/base/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ RUN eval "$(gimme "${GO_VERSION}")" \
122122
# stage for building containerd
123123
FROM go-build AS build-containerd
124124
ARG TARGETARCH GO_VERSION
125-
ARG CONTAINERD_VERSION="v1.7.24"
125+
ARG CONTAINERD_VERSION="v2.0.2"
126126
ARG CONTAINERD_CLONE_URL="https://github.com/containerd/containerd"
127127
# we don't build with optional snapshotters, we never select any of these
128128
# they're not ideal inside kind anyhow, and we save some disk space

‎pkg/cluster/nodeutils/util.go

+18-2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package nodeutils
1919
import (
2020
"bytes"
2121
"encoding/json"
22+
"fmt"
2223
"io"
2324
"path"
2425
"strings"
@@ -102,9 +103,24 @@ func parseSnapshotter(config string) (string, error) {
102103
if err != nil {
103104
return "", errors.Wrap(err, "failed to detect containerd snapshotter")
104105
}
105-
snapshotter, ok := parsed.GetPath([]string{"plugins", "io.containerd.grpc.v1.cri", "containerd", "snapshotter"}).(string)
106+
configVersion, ok := parsed.Get("version").(int64)
106107
if !ok {
107-
return "", errors.New("failed to detect containerd snapshotter")
108+
return "", errors.New("failed to detect containerd config version")
109+
}
110+
var snapshotter string
111+
switch configVersion {
112+
case 2: // Introduced in containerd v1.3. Still supported in containerd v2.
113+
snapshotter, ok = parsed.GetPath([]string{"plugins", "io.containerd.grpc.v1.cri", "containerd", "snapshotter"}).(string)
114+
if !ok {
115+
return "", errors.New("failed to detect containerd snapshotter (config version 2)")
116+
}
117+
case 3: // Introduced in containerd v2.0.
118+
snapshotter, ok = parsed.GetPath([]string{"plugins", "io.containerd.cri.v1.images", "snapshotter"}).(string)
119+
if !ok {
120+
return "", errors.New("failed to detect containerd snapshotter (config version 3)")
121+
}
122+
default:
123+
return "", fmt.Errorf("unknown containerd config version: %d (supported versions: 2 and 3)", configVersion)
108124
}
109125
return snapshotter, nil
110126
}

0 commit comments

Comments
 (0)
Please sign in to comment.