Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,18 @@ func (c *Client) NewContainer(ctx context.Context, id string, opts ...NewContain
return containerFromRecord(c, r), nil
}

func (c *Client) UpdateDevboxSnapshot(ctx context.Context, snapshotter string, id string, label string, value string) error {
fmt.Println("Check snapshotter:", snapshotter)
_, err := c.SnapshotService(snapshotter).Update(ctx, snapshots.Info{
Name: id,
Labels: map[string]string{label: value},
}, "labels."+label)
if err != nil {
return err
}
return nil
}

// LoadContainer loads an existing container from metadata
func (c *Client) LoadContainer(ctx context.Context, id string) (Container, error) {
r, err := c.ContainerService().Get(ctx, id)
Expand Down Expand Up @@ -621,15 +633,20 @@ func (c *Client) ContentStore() content.Store {

// SnapshotService returns the underlying snapshotter for the provided snapshotter name
func (c *Client) SnapshotService(snapshotterName string) snapshots.Snapshotter {
fmt.Println("Snapshotter name:", snapshotterName)
snapshotterName, err := c.resolveSnapshotterName(context.Background(), snapshotterName)
fmt.Println("Resolved snapshotter name:", snapshotterName)
if err != nil {
snapshotterName = DefaultSnapshotter
fmt.Println("Using default snapshotter:", snapshotterName)
}
if c.snapshotters != nil {
fmt.Println("Using cached snapshotter:", snapshotterName)
return c.snapshotters[snapshotterName]
}
c.connMu.Lock()
defer c.connMu.Unlock()
fmt.Println("Creating new remote snapshotter:", snapshotterName)
return snproxy.NewSnapshotter(snapshotsapi.NewSnapshotsClient(c.conn), snapshotterName)
}

Expand Down
1 change: 1 addition & 0 deletions cmd/containerd/builtins/builtins_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
_ "github.com/containerd/containerd/metrics/cgroups/v2"
_ "github.com/containerd/containerd/runtime/v1/linux"
_ "github.com/containerd/containerd/snapshots/blockfile/plugin"
_ "github.com/containerd/containerd/snapshots/devbox/plugin"
_ "github.com/containerd/containerd/snapshots/native/plugin"
_ "github.com/containerd/containerd/snapshots/overlay/plugin"
)
19 changes: 18 additions & 1 deletion container_opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"encoding/json"
"errors"
"fmt"
"strings"

"github.com/containerd/containerd/containers"
"github.com/containerd/containerd/content"
Expand Down Expand Up @@ -229,7 +230,23 @@ func WithNewSnapshot(id string, i Image, opts ...snapshots.Opt) NewContainerOpts
if err != nil {
return err
}
if _, err := s.Prepare(ctx, id, parent, opts...); err != nil {
base := snapshots.Info{}
for _, opt := range opts {
if err := opt(&base); err != nil {
return fmt.Errorf("error applying snapshot option: %w", err)
}
}
start_opts := []snapshots.Opt{}
for label, value := range base.Labels {
// if label start with "devbox.sealos.io/", transform it to "containerd.io/snapshot/"
if strings.HasPrefix(label, "devbox.sealos.io/") {
start_opts = append(start_opts, snapshots.WithLabels(map[string]string{
"containerd.io/snapshot/devbox-" + label[len("devbox.sealos.io/"):]: value,
}))
}
}
start_opts = append(start_opts, opts...)
if _, err := s.Prepare(ctx, id, parent, start_opts...); err != nil {
return err
}
c.SnapshotKey = id
Expand Down
43 changes: 27 additions & 16 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module github.com/containerd/containerd

go 1.21
go 1.23.0

toolchain go1.24.4

require (
dario.cat/mergo v1.0.0
Expand Down Expand Up @@ -33,7 +35,7 @@ require (
github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c
github.com/docker/go-metrics v0.0.1
github.com/docker/go-units v0.5.0
github.com/emicklei/go-restful/v3 v3.10.1
github.com/emicklei/go-restful/v3 v3.10.2
github.com/fsnotify/fsnotify v1.6.0
github.com/google/go-cmp v0.6.0
github.com/google/uuid v1.4.0
Expand All @@ -54,7 +56,10 @@ require (
github.com/opencontainers/runtime-spec v1.1.0
github.com/opencontainers/runtime-tools v0.9.1-0.20221107090550-2e043c6bd626
github.com/opencontainers/selinux v1.11.0
github.com/openebs/lvm-localpv v1.7.0
github.com/otiai10/copy v1.14.1
github.com/pelletier/go-toml v1.9.5
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.16.0
github.com/sirupsen/logrus v1.9.3
github.com/stretchr/testify v1.8.4
Expand All @@ -70,21 +75,21 @@ require (
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.19.0
go.opentelemetry.io/otel/sdk v1.21.0
go.opentelemetry.io/otel/trace v1.21.0
golang.org/x/net v0.33.0
golang.org/x/sync v0.10.0
golang.org/x/sys v0.28.0
golang.org/x/net v0.38.0
golang.org/x/sync v0.12.0
golang.org/x/sys v0.31.0
google.golang.org/genproto v0.0.0-20231211222908-989df2bf70f3
google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda
google.golang.org/grpc v1.59.0
google.golang.org/protobuf v1.35.2
k8s.io/api v0.26.2
k8s.io/api v0.27.2
k8s.io/apimachinery v0.27.4
k8s.io/apiserver v0.26.2
k8s.io/client-go v0.26.2
k8s.io/client-go v11.0.1-0.20190409021438-1a26190bd76a+incompatible
k8s.io/component-base v0.26.2
k8s.io/cri-api v0.27.1
k8s.io/klog/v2 v2.90.1
k8s.io/utils v0.0.0-20230220204549-a5ecb0141aa5
k8s.io/klog/v2 v2.100.1
k8s.io/utils v0.0.0-20230505201702-9f6742963106
tags.cncf.io/container-device-interface v0.8.1
)

Expand Down Expand Up @@ -117,10 +122,10 @@ require (
github.com/moby/spdystream v0.2.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/otiai10/mint v1.6.3 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.42.0 // indirect
github.com/prometheus/client_model v0.4.0 // indirect
github.com/prometheus/common v0.44.0 // indirect
github.com/prometheus/procfs v0.10.1 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
Expand All @@ -131,12 +136,12 @@ require (
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/otel/metric v1.21.0 // indirect
go.opentelemetry.io/proto/otlp v1.0.0 // indirect
golang.org/x/crypto v0.31.0 // indirect
golang.org/x/crypto v0.36.0 // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/oauth2 v0.11.0 // indirect
golang.org/x/term v0.27.0 // indirect
golang.org/x/text v0.21.0 // indirect
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 // indirect
golang.org/x/term v0.30.0 // indirect
golang.org/x/text v0.23.0 // indirect
golang.org/x/time v0.3.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20231120223509-83a465c0220f // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
Expand All @@ -151,3 +156,9 @@ require (
// Workaround for indirect dependency no longer being available.
// https://github.com/containerd/containerd/issues/9969
exclude github.com/mitchellh/osext v0.0.0-20151018003038-5e2d6d41470f

replace k8s.io/apimachinery v0.27.2 => k8s.io/apimachinery v0.24.17

replace k8s.io/client-go => k8s.io/client-go v0.26.2

replace k8s.io/api => k8s.io/api v0.26.2
Loading