diff --git a/cmd/containerd/builtins_zfs_linux.go b/cmd/containerd/builtins_zfs_linux.go index b1d161117..8bc26e5fa 100644 --- a/cmd/containerd/builtins_zfs_linux.go +++ b/cmd/containerd/builtins_zfs_linux.go @@ -18,4 +18,4 @@ package main -import _ "github.com/containerd/zfs" +import _ "github.com/containerd/zfs/plugin" diff --git a/vendor.conf b/vendor.conf index 7304f44be..dbc240084 100644 --- a/vendor.conf +++ b/vendor.conf @@ -99,7 +99,7 @@ github.com/fullsailor/pkcs7 8306686428a5fe132eac8cb7c484 gopkg.in/square/go-jose.v2 v2.3.1 # zfs dependencies -github.com/containerd/zfs 9abf673ca6ff9ab8d9bd776a4ceff8f6dc699c3d +github.com/containerd/zfs 0a33824f23a2ab8ec84166f47b571ecb793b0354 github.com/mistifyio/go-zfs f784269be439d704d3dfa1906f45dd848fed2beb # aufs dependencies diff --git a/vendor/github.com/containerd/zfs/README.md b/vendor/github.com/containerd/zfs/README.md index 5f8e5bad3..badd83fd4 100644 --- a/vendor/github.com/containerd/zfs/README.md +++ b/vendor/github.com/containerd/zfs/README.md @@ -7,26 +7,11 @@ ZFS snapshotter plugin for containerd. This plugin is tested on Linux with Ubuntu. It should be compatible with FreeBSD. - -## Compile - -To compile containerd with ZFS support, add the import into the `$GOPATH/src/github.com/containerd/containerd/cmd/containerd/builtins_zfs.go` file. - -```go -// +build linux freebsd - -package main - -import ( - _ "github.com/containerd/zfs" -) -``` - -Please refer to [`.travis.yml`](.travis.yml) for the latest containerd version known to work with. - - ## Usage +The plugin is built-in by default since containerd 1.1. +No need to recompile containerd or execute a proxy snapshotter process. + 1. Set up a ZFS filesystem. The ZFS filesystem name is arbitrary but the mount point needs to be `/var/lib/containerd/io.containerd.snapshotter.v1.zfs`, when the containerd root is set to `/var/lib/containerd`. ```console diff --git a/vendor/github.com/containerd/zfs/go.mod b/vendor/github.com/containerd/zfs/go.mod new file mode 100644 index 000000000..f05aa4acb --- /dev/null +++ b/vendor/github.com/containerd/zfs/go.mod @@ -0,0 +1,23 @@ +module github.com/containerd/zfs + +go 1.13 + +require ( + github.com/Microsoft/hcsshim v0.8.7 // indirect + github.com/containerd/containerd v1.3.1-0.20191213020239-082f7e3aed57 + github.com/containerd/continuity v0.0.0-20191127005431-f65d91d395eb + github.com/containerd/ttrpc v0.0.0-20191028202541-4f1b8fe65a5c // indirect + github.com/containerd/typeurl v0.0.0-20190911142611-5eb25027c9fd // indirect + github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c // indirect + github.com/gogo/protobuf v1.3.1 // indirect + github.com/google/go-cmp v0.3.1 // indirect + github.com/google/uuid v1.1.1 // indirect + github.com/mistifyio/go-zfs v2.1.2-0.20190413222219-f784269be439+incompatible + github.com/opencontainers/go-digest v1.0.0-rc1 // indirect + github.com/opencontainers/image-spec v1.0.1 // indirect + github.com/opencontainers/runc v1.0.0-rc9 // indirect + github.com/pkg/errors v0.8.1 + go.etcd.io/bbolt v1.3.3 // indirect + golang.org/x/sys v0.0.0-20191210023423-ac6580df4449 // indirect + google.golang.org/grpc v1.25.1 // indirect +) diff --git a/vendor/github.com/containerd/zfs/plugin/plugin.go b/vendor/github.com/containerd/zfs/plugin/plugin.go new file mode 100644 index 000000000..40dd864c8 --- /dev/null +++ b/vendor/github.com/containerd/zfs/plugin/plugin.go @@ -0,0 +1,58 @@ +/* + Copyright The containerd Authors. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package plugin + +import ( + "github.com/containerd/containerd/platforms" + "github.com/containerd/containerd/plugin" + "github.com/containerd/zfs" + "github.com/pkg/errors" +) + + +// Config represents configuration for the zfs plugin +type Config struct { + // Root directory for the plugin + RootPath string `toml:"root_path"` +} + +func init() { + plugin.Register(&plugin.Registration{ + Type: plugin.SnapshotPlugin, + ID: "zfs", + InitFn: func(ic *plugin.InitContext) (interface{}, error) { + ic.Meta.Platforms = append(ic.Meta.Platforms, platforms.DefaultSpec()) + + // get config + config, ok := ic.Config.(*Config) + if !ok { + return nil, errors.New("invalid zfs configuration") + } + // use default ic.Root as root path if config doesn't have a valid root path + root := ic.Root + if len(config.RootPath) != 0 { + root = config.RootPath + } + ic.Meta.Exports["root"] = root + snapshotter, err := zfs.NewSnapshotter(root) + if err != nil { + return nil, errors.Wrap(plugin.ErrSkipPlugin, err.Error()) + } + return snapshotter, nil + }, + }) +} diff --git a/vendor/github.com/containerd/zfs/zfs.go b/vendor/github.com/containerd/zfs/zfs.go index 43c9dcd2e..f22d16afa 100644 --- a/vendor/github.com/containerd/zfs/zfs.go +++ b/vendor/github.com/containerd/zfs/zfs.go @@ -20,16 +20,13 @@ package zfs import ( "context" - "path/filepath" - "github.com/containerd/containerd/log" "github.com/containerd/containerd/mount" - "github.com/containerd/containerd/platforms" - "github.com/containerd/containerd/plugin" "github.com/containerd/containerd/snapshots" "github.com/containerd/containerd/snapshots/storage" zfs "github.com/mistifyio/go-zfs" "github.com/pkg/errors" + "path/filepath" ) const ( @@ -39,17 +36,6 @@ const ( snapshotSuffix = "snapshot" ) -func init() { - plugin.Register(&plugin.Registration{ - Type: plugin.SnapshotPlugin, - ID: "zfs", - InitFn: func(ic *plugin.InitContext) (interface{}, error) { - ic.Meta.Platforms = append(ic.Meta.Platforms, platforms.DefaultSpec()) - ic.Meta.Exports["root"] = ic.Root - return NewSnapshotter(ic.Root) - }, - }) -} type snapshotter struct { dataset *zfs.Dataset @@ -66,7 +52,7 @@ func NewSnapshotter(root string) (snapshots.Snapshotter, error) { return nil, err } if m.FSType != "zfs" { - return nil, errors.Wrapf(plugin.ErrSkipPlugin, "path %s must be a zfs filesystem to be used with the zfs snapshotter", root) + return nil, errors.Errorf("path %s must be a zfs filesystem to be used with the zfs snapshotter", root) } dataset, err := zfs.GetDataset(m.Source) if err != nil {