Commit 124e46bc authored by Brad Davidson's avatar Brad Davidson Committed by Brad Davidson

Upgrade containerd to v2.0.2

parent 04ed6c09
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -9,7 +9,7 @@ import ( ...@@ -9,7 +9,7 @@ import (
"path/filepath" "path/filepath"
"strings" "strings"
"github.com/containerd/containerd/remotes/docker" "github.com/containerd/containerd/v2/core/remotes/docker"
"github.com/k3s-io/k3s/pkg/agent/templates" "github.com/k3s-io/k3s/pkg/agent/templates"
util2 "github.com/k3s-io/k3s/pkg/agent/util" util2 "github.com/k3s-io/k3s/pkg/agent/util"
"github.com/k3s-io/k3s/pkg/daemons/config" "github.com/k3s-io/k3s/pkg/daemons/config"
......
...@@ -6,16 +6,16 @@ package containerd ...@@ -6,16 +6,16 @@ package containerd
import ( import (
"os" "os"
"github.com/containerd/containerd" containerd "github.com/containerd/containerd/v2/client"
overlayutils "github.com/containerd/containerd/snapshots/overlay/overlayutils" "github.com/containerd/containerd/v2/plugins/snapshots/overlay/overlayutils"
fuseoverlayfs "github.com/containerd/fuse-overlayfs-snapshotter" fuseoverlayfs "github.com/containerd/fuse-overlayfs-snapshotter/v2"
stargz "github.com/containerd/stargz-snapshotter/service" stargz "github.com/containerd/stargz-snapshotter/service"
"github.com/docker/docker/pkg/parsers/kernel" "github.com/docker/docker/pkg/parsers/kernel"
"github.com/k3s-io/k3s/pkg/agent/templates" "github.com/k3s-io/k3s/pkg/agent/templates"
"github.com/k3s-io/k3s/pkg/cgroups" "github.com/k3s-io/k3s/pkg/cgroups"
"github.com/k3s-io/k3s/pkg/daemons/config" "github.com/k3s-io/k3s/pkg/daemons/config"
"github.com/k3s-io/k3s/pkg/version" "github.com/k3s-io/k3s/pkg/version"
"github.com/opencontainers/runc/libcontainer/userns" "github.com/moby/sys/userns"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"golang.org/x/sys/unix" "golang.org/x/sys/unix"
......
...@@ -6,7 +6,7 @@ package containerd ...@@ -6,7 +6,7 @@ package containerd
import ( import (
"net" "net"
"github.com/containerd/containerd" containerd "github.com/containerd/containerd/v2/client"
"github.com/k3s-io/k3s/pkg/agent/templates" "github.com/k3s-io/k3s/pkg/agent/templates"
"github.com/k3s-io/k3s/pkg/daemons/config" "github.com/k3s-io/k3s/pkg/daemons/config"
util3 "github.com/k3s-io/k3s/pkg/util" util3 "github.com/k3s-io/k3s/pkg/util"
......
...@@ -11,13 +11,11 @@ import ( ...@@ -11,13 +11,11 @@ import (
"strings" "strings"
"time" "time"
"github.com/containerd/containerd" containerd "github.com/containerd/containerd/v2/client"
"github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/v2/core/images"
"github.com/containerd/containerd/images" "github.com/containerd/containerd/v2/pkg/namespaces"
"github.com/containerd/containerd/namespaces" "github.com/containerd/errdefs"
"github.com/containerd/containerd/pkg/cri/constants" docker "github.com/distribution/reference"
"github.com/containerd/containerd/pkg/cri/labels"
"github.com/containerd/containerd/reference/docker"
reference "github.com/google/go-containerregistry/pkg/name" reference "github.com/google/go-containerregistry/pkg/name"
"github.com/k3s-io/k3s/pkg/agent/cri" "github.com/k3s-io/k3s/pkg/agent/cri"
util2 "github.com/k3s-io/k3s/pkg/agent/util" util2 "github.com/k3s-io/k3s/pkg/agent/util"
...@@ -39,6 +37,16 @@ var ( ...@@ -39,6 +37,16 @@ var (
k3sPinnedImageLabelValue = "pinned" k3sPinnedImageLabelValue = "pinned"
) )
const (
// these were previously exported via containerd/containerd/pkg/cri/constants
// and containerd/containerd/pkg/cri/labels but have been made internal as of
// containerd v2.
criContainerdPrefix = "io.cri-containerd"
criPinnedImageLabelKey = criContainerdPrefix + ".pinned"
criPinnedImageLabelValue = "pinned"
criK8sContainerdNamespace = "k8s.io"
)
// Run configures and starts containerd as a child process. Once it is up, images are preloaded // Run configures and starts containerd as a child process. Once it is up, images are preloaded
// or pulled from files found in the agent images directory. // or pulled from files found in the agent images directory.
func Run(ctx context.Context, cfg *config.Node) error { func Run(ctx context.Context, cfg *config.Node) error {
...@@ -133,7 +141,7 @@ func PreloadImages(ctx context.Context, cfg *config.Node) error { ...@@ -133,7 +141,7 @@ func PreloadImages(ctx context.Context, cfg *config.Node) error {
imageClient := runtimeapi.NewImageServiceClient(criConn) imageClient := runtimeapi.NewImageServiceClient(criConn)
// Ensure that our images are imported into the correct namespace // Ensure that our images are imported into the correct namespace
ctx = namespaces.WithNamespace(ctx, constants.K8sContainerdNamespace) ctx = namespaces.WithNamespace(ctx, criK8sContainerdNamespace)
// At startup all leases from k3s are cleared; we no longer use leases to lock content // At startup all leases from k3s are cleared; we no longer use leases to lock content
if err := clearLeases(ctx, client); err != nil { if err := clearLeases(ctx, client); err != nil {
...@@ -261,7 +269,7 @@ func clearLabels(ctx context.Context, client *containerd.Client) error { ...@@ -261,7 +269,7 @@ func clearLabels(ctx context.Context, client *containerd.Client) error {
} }
for _, image := range images { for _, image := range images {
delete(image.Labels, k3sPinnedImageLabelKey) delete(image.Labels, k3sPinnedImageLabelKey)
delete(image.Labels, labels.PinnedImageLabelKey) delete(image.Labels, criPinnedImageLabelKey)
if _, err := imageService.Update(ctx, image, "labels"); err != nil { if _, err := imageService.Update(ctx, image, "labels"); err != nil {
errs = append(errs, errors.Wrap(err, "failed to delete labels from image "+image.Name)) errs = append(errs, errors.Wrap(err, "failed to delete labels from image "+image.Name))
} }
...@@ -276,7 +284,7 @@ func labelImages(ctx context.Context, client *containerd.Client, images []images ...@@ -276,7 +284,7 @@ func labelImages(ctx context.Context, client *containerd.Client, images []images
imageService := client.ImageService() imageService := client.ImageService()
for i, image := range images { for i, image := range images {
if image.Labels[k3sPinnedImageLabelKey] == k3sPinnedImageLabelValue && if image.Labels[k3sPinnedImageLabelKey] == k3sPinnedImageLabelValue &&
image.Labels[labels.PinnedImageLabelKey] == labels.PinnedImageLabelValue { image.Labels[criPinnedImageLabelKey] == criPinnedImageLabelValue {
continue continue
} }
...@@ -285,7 +293,7 @@ func labelImages(ctx context.Context, client *containerd.Client, images []images ...@@ -285,7 +293,7 @@ func labelImages(ctx context.Context, client *containerd.Client, images []images
} }
image.Labels[k3sPinnedImageLabelKey] = k3sPinnedImageLabelValue image.Labels[k3sPinnedImageLabelKey] = k3sPinnedImageLabelValue
image.Labels[labels.PinnedImageLabelKey] = labels.PinnedImageLabelValue image.Labels[criPinnedImageLabelKey] = criPinnedImageLabelValue
updatedImage, err := imageService.Update(ctx, image, "labels") updatedImage, err := imageService.Update(ctx, image, "labels")
if err != nil { if err != nil {
errs = append(errs, errors.Wrap(err, "failed to add labels to image "+image.Name)) errs = append(errs, errors.Wrap(err, "failed to add labels to image "+image.Name))
......
...@@ -9,7 +9,7 @@ import ( ...@@ -9,7 +9,7 @@ import (
"strings" "strings"
"time" "time"
"github.com/containerd/containerd" containerd "github.com/containerd/containerd/v2/client"
"github.com/fsnotify/fsnotify" "github.com/fsnotify/fsnotify"
"github.com/k3s-io/k3s/pkg/agent/cri" "github.com/k3s-io/k3s/pkg/agent/cri"
"github.com/k3s-io/k3s/pkg/daemons/config" "github.com/k3s-io/k3s/pkg/daemons/config"
......
...@@ -5,7 +5,7 @@ package cmds ...@@ -5,7 +5,7 @@ package cmds
import ( import (
"os" "os"
"github.com/containerd/containerd/pkg/userns" "github.com/moby/sys/userns"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/rootless-containers/rootlesskit/pkg/parent/cgrouputil" "github.com/rootless-containers/rootlesskit/pkg/parent/cgrouputil"
) )
......
...@@ -21,31 +21,33 @@ package containerd ...@@ -21,31 +21,33 @@ package containerd
// register containerd builtins here // register containerd builtins here
import ( import (
_ "github.com/containerd/containerd/diff/walking/plugin" _ "github.com/containerd/containerd/v2/core/runtime/v2"
_ "github.com/containerd/containerd/events/plugin" _ "github.com/containerd/containerd/v2/plugins/content/local/plugin"
_ "github.com/containerd/containerd/gc/scheduler" _ "github.com/containerd/containerd/v2/plugins/events"
_ "github.com/containerd/containerd/leases/plugin" _ "github.com/containerd/containerd/v2/plugins/gc"
_ "github.com/containerd/containerd/metadata/plugin" _ "github.com/containerd/containerd/v2/plugins/imageverifier"
_ "github.com/containerd/containerd/pkg/nri/plugin" _ "github.com/containerd/containerd/v2/plugins/leases"
_ "github.com/containerd/containerd/plugins/sandbox" _ "github.com/containerd/containerd/v2/plugins/metadata"
_ "github.com/containerd/containerd/plugins/streaming" _ "github.com/containerd/containerd/v2/plugins/nri"
_ "github.com/containerd/containerd/plugins/transfer" _ "github.com/containerd/containerd/v2/plugins/restart"
_ "github.com/containerd/containerd/runtime/restart/monitor" _ "github.com/containerd/containerd/v2/plugins/sandbox"
_ "github.com/containerd/containerd/runtime/v2" _ "github.com/containerd/containerd/v2/plugins/services/containers"
_ "github.com/containerd/containerd/services/containers" _ "github.com/containerd/containerd/v2/plugins/services/content"
_ "github.com/containerd/containerd/services/content" _ "github.com/containerd/containerd/v2/plugins/services/diff"
_ "github.com/containerd/containerd/services/diff" _ "github.com/containerd/containerd/v2/plugins/services/events"
_ "github.com/containerd/containerd/services/events" _ "github.com/containerd/containerd/v2/plugins/services/healthcheck"
_ "github.com/containerd/containerd/services/healthcheck" _ "github.com/containerd/containerd/v2/plugins/services/images"
_ "github.com/containerd/containerd/services/images" _ "github.com/containerd/containerd/v2/plugins/services/introspection"
_ "github.com/containerd/containerd/services/introspection" _ "github.com/containerd/containerd/v2/plugins/services/leases"
_ "github.com/containerd/containerd/services/leases" _ "github.com/containerd/containerd/v2/plugins/services/namespaces"
_ "github.com/containerd/containerd/services/namespaces" _ "github.com/containerd/containerd/v2/plugins/services/opt"
_ "github.com/containerd/containerd/services/opt" _ "github.com/containerd/containerd/v2/plugins/services/sandbox"
_ "github.com/containerd/containerd/services/sandbox" _ "github.com/containerd/containerd/v2/plugins/services/snapshots"
_ "github.com/containerd/containerd/services/snapshots" _ "github.com/containerd/containerd/v2/plugins/services/streaming"
_ "github.com/containerd/containerd/services/streaming" _ "github.com/containerd/containerd/v2/plugins/services/tasks"
_ "github.com/containerd/containerd/services/tasks" _ "github.com/containerd/containerd/v2/plugins/services/transfer"
_ "github.com/containerd/containerd/services/transfer" _ "github.com/containerd/containerd/v2/plugins/services/version"
_ "github.com/containerd/containerd/services/version" _ "github.com/containerd/containerd/v2/plugins/services/warning"
_ "github.com/containerd/containerd/v2/plugins/streaming"
_ "github.com/containerd/containerd/v2/plugins/transfer"
) )
...@@ -19,4 +19,8 @@ ...@@ -19,4 +19,8 @@
package containerd package containerd
import _ "github.com/containerd/containerd/pkg/cri" import (
_ "github.com/containerd/containerd/v2/plugins/cri"
_ "github.com/containerd/containerd/v2/plugins/cri/images"
_ "github.com/containerd/containerd/v2/plugins/cri/runtime"
)
...@@ -20,16 +20,16 @@ ...@@ -20,16 +20,16 @@
package containerd package containerd
import ( import (
_ "github.com/containerd/aufs/plugin" _ "github.com/containerd/containerd/api/types/runc/options"
_ "github.com/containerd/containerd/metrics" _ "github.com/containerd/containerd/v2/core/metrics/cgroups"
_ "github.com/containerd/containerd/metrics/cgroups" _ "github.com/containerd/containerd/v2/core/metrics/cgroups/v2"
_ "github.com/containerd/containerd/metrics/cgroups/v2" _ "github.com/containerd/containerd/v2/plugins/diff/walking/plugin"
_ "github.com/containerd/containerd/runtime/v2/runc/options" _ "github.com/containerd/containerd/v2/plugins/snapshots/blockfile/plugin"
_ "github.com/containerd/containerd/snapshots/btrfs/plugin" _ "github.com/containerd/containerd/v2/plugins/snapshots/btrfs/plugin"
_ "github.com/containerd/containerd/snapshots/devmapper/plugin" _ "github.com/containerd/containerd/v2/plugins/snapshots/devmapper/plugin"
_ "github.com/containerd/containerd/snapshots/native/plugin" _ "github.com/containerd/containerd/v2/plugins/snapshots/native/plugin"
_ "github.com/containerd/containerd/snapshots/overlay/plugin" _ "github.com/containerd/containerd/v2/plugins/snapshots/overlay/plugin"
_ "github.com/containerd/fuse-overlayfs-snapshotter/plugin" _ "github.com/containerd/fuse-overlayfs-snapshotter/v2/plugin"
_ "github.com/containerd/stargz-snapshotter/service/plugin" _ "github.com/containerd/stargz-snapshotter/service/plugin"
_ "github.com/containerd/zfs/plugin" _ "github.com/containerd/zfs/v2/plugin"
) )
...@@ -20,8 +20,8 @@ ...@@ -20,8 +20,8 @@
package containerd package containerd
import ( import (
_ "github.com/containerd/containerd/diff/lcow" _ "github.com/containerd/containerd/v2/plugins/diff/lcow"
_ "github.com/containerd/containerd/diff/windows" _ "github.com/containerd/containerd/v2/plugins/diff/windows"
_ "github.com/containerd/containerd/snapshots/lcow" _ "github.com/containerd/containerd/v2/plugins/snapshots/lcow"
_ "github.com/containerd/containerd/snapshots/windows" _ "github.com/containerd/containerd/v2/plugins/snapshots/windows"
) )
...@@ -7,13 +7,10 @@ import ( ...@@ -7,13 +7,10 @@ import (
"fmt" "fmt"
"os" "os"
"github.com/containerd/containerd/cmd/containerd/command" "github.com/containerd/containerd/v2/cmd/containerd/command"
"github.com/containerd/containerd/pkg/seed"
) )
func Main() { func Main() {
//klog.InitFlags(nil)
seed.WithTimeAndRand()
app := command.App() app := command.App()
if err := app.Run(os.Args); err != nil { if err := app.Run(os.Args); err != nil {
fmt.Fprintf(os.Stderr, "containerd: %s\n", err) fmt.Fprintf(os.Stderr, "containerd: %s\n", err)
......
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
package containerd package containerd
import ( import (
"github.com/containerd/containerd/snapshots/overlay/overlayutils" "github.com/containerd/containerd/v2/plugins/snapshots/overlay/overlayutils"
fuseoverlayfs "github.com/containerd/fuse-overlayfs-snapshotter" fuseoverlayfs "github.com/containerd/fuse-overlayfs-snapshotter/v2"
stargz "github.com/containerd/stargz-snapshotter/service" stargz "github.com/containerd/stargz-snapshotter/service"
) )
......
...@@ -20,9 +20,8 @@ import ( ...@@ -20,9 +20,8 @@ import (
"fmt" "fmt"
"os" "os"
"github.com/containerd/containerd/cmd/ctr/app" "github.com/containerd/containerd/v2/cmd/ctr/app"
"github.com/containerd/containerd/pkg/seed" "github.com/urfave/cli/v2"
"github.com/urfave/cli"
) )
func Main() { func Main() {
...@@ -30,14 +29,13 @@ func Main() { ...@@ -30,14 +29,13 @@ func Main() {
} }
func main() { func main() {
seed.WithTimeAndRand()
app := app.New() app := app.New()
for i, flag := range app.Flags { for i, flag := range app.Flags {
if sFlag, ok := flag.(cli.StringFlag); ok { if sFlag, ok := flag.(*cli.StringFlag); ok {
if sFlag.Name == "address, a" { if sFlag.Name == "address" {
sFlag.Value = "/run/k3s/containerd/containerd.sock" sFlag.Value = "/run/k3s/containerd/containerd.sock"
app.Flags[i] = sFlag app.Flags[i] = sFlag
} else if sFlag.Name == "namespace, n" { } else if sFlag.Name == "namespace" {
sFlag.Value = "k8s.io" sFlag.Value = "k8s.io"
app.Flags[i] = sFlag app.Flags[i] = sFlag
} }
......
...@@ -3,7 +3,7 @@ package spegel ...@@ -3,7 +3,7 @@ package spegel
import ( import (
"net" "net"
"github.com/containerd/containerd/remotes/docker" "github.com/containerd/containerd/v2/core/remotes/docker"
"github.com/k3s-io/k3s/pkg/daemons/config" "github.com/k3s-io/k3s/pkg/daemons/config"
"github.com/rancher/wharfie/pkg/registries" "github.com/rancher/wharfie/pkg/registries"
) )
......
...@@ -13,7 +13,7 @@ import ( ...@@ -13,7 +13,7 @@ import (
"strconv" "strconv"
"time" "time"
"github.com/containerd/containerd/remotes/docker" "github.com/containerd/containerd/v2/core/remotes/docker"
"github.com/k3s-io/k3s/pkg/agent/https" "github.com/k3s-io/k3s/pkg/agent/https"
"github.com/k3s-io/k3s/pkg/clientaccess" "github.com/k3s-io/k3s/pkg/clientaccess"
"github.com/k3s-io/k3s/pkg/daemons/config" "github.com/k3s-io/k3s/pkg/daemons/config"
......
...@@ -8,7 +8,7 @@ cd $(dirname $0)/.. ...@@ -8,7 +8,7 @@ cd $(dirname $0)/..
GO=${GO-go} GO=${GO-go}
PKG="github.com/k3s-io/k3s" PKG="github.com/k3s-io/k3s"
PKG_CONTAINERD="github.com/containerd/containerd" PKG_CONTAINERD="github.com/containerd/containerd/v2"
PKG_CRICTL="sigs.k8s.io/cri-tools/pkg" PKG_CRICTL="sigs.k8s.io/cri-tools/pkg"
PKG_K8S_BASE="k8s.io/component-base" PKG_K8S_BASE="k8s.io/component-base"
PKG_K8S_CLIENT="k8s.io/client-go/pkg" PKG_K8S_CLIENT="k8s.io/client-go/pkg"
......
...@@ -36,7 +36,7 @@ case ${OS} in ...@@ -36,7 +36,7 @@ case ${OS} in
;; ;;
esac esac
git clone --single-branch --branch=${VERSION_CONTAINERD} --depth=1 https://${PKG_CONTAINERD_K3S} ${CONTAINERD_DIR} git clone --single-branch --branch=${VERSION_CONTAINERD} --depth=1 https://${PKG_CONTAINERD_K3S/\/v*/} ${CONTAINERD_DIR}
for CHART_FILE in $(grep -rlF HelmChart manifests/ | xargs yq eval --no-doc .spec.chart | xargs -n1 basename); do for CHART_FILE in $(grep -rlF HelmChart manifests/ | xargs yq eval --no-doc .spec.chart | xargs -n1 basename); do
CHART_NAME=$(echo $CHART_FILE | grep -oE '^(-*[a-z])+') CHART_NAME=$(echo $CHART_FILE | grep -oE '^(-*[a-z])+')
......
...@@ -31,8 +31,8 @@ get-module-path(){ ...@@ -31,8 +31,8 @@ get-module-path(){
go list -m -f '{{if .Replace}}{{.Replace.Path}}{{else}}{{.Path}}{{end}}' $1 go list -m -f '{{if .Replace}}{{.Replace.Path}}{{else}}{{.Path}}{{end}}' $1
} }
PKG_CONTAINERD_K3S=$(get-module-path github.com/containerd/containerd) PKG_CONTAINERD_K3S=$(get-module-path github.com/containerd/containerd/v2)
VERSION_CONTAINERD=$(get-module-version github.com/containerd/containerd) VERSION_CONTAINERD=$(get-module-version github.com/containerd/containerd/v2)
if [ -z "$VERSION_CONTAINERD" ]; then if [ -z "$VERSION_CONTAINERD" ]; then
VERSION_CONTAINERD="v0.0.0" VERSION_CONTAINERD="v0.0.0"
fi fi
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment