vendor: github.com/containerd/zfs v1.1.0

- update github.com/mistifyio/go-zfs dependency to github.com/mistifyio/go-zfs/v3,
  which contains various bugfixes, and adds go module support (which required a major
  version update): https://github.com/mistifyio/go-zfs/compare/f784269be439...v3.0.1
- remove github.com/pkg/errors dependency
- various minor cleanups/fixes

Full diff: https://github.com/containerd/zfs/compare/v1.0.0...v1.1.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2023-05-26 13:46:44 +02:00
parent d5ec7286ae
commit 05fef52b68
31 changed files with 945 additions and 329 deletions

View File

@@ -1,7 +1,9 @@
# [containerd](https://github.com/containerd/containerd) ZFS snapshotter plugin
[![Build Status](https://travis-ci.org/containerd/zfs.svg)](https://travis-ci.org/containerd/zfs)
[![codecov](https://codecov.io/gh/containerd/zfs/branch/master/graph/badge.svg)](https://codecov.io/gh/containerd/zfs)
[![PkgGoDev](https://pkg.go.dev/badge/github.com/containerd/zfs)](https://pkg.go.dev/github.com/containerd/zfs)
[![Build Status](https://github.com/containerd/zfs/actions/workflows/ci.yml/badge.svg)](https://github.com/containerd/zfs/actions/workflows/ci.yml)
[![Go Report Card](https://goreportcard.com/badge/github.com/containerd/zfs)](https://goreportcard.com/report/github.com/containerd/zfs)
[![codecov](https://codecov.io/gh/containerd/zfs/branch/main/graph/badge.svg)](https://codecov.io/gh/containerd/zfs)
ZFS snapshotter plugin for containerd.
@@ -26,8 +28,8 @@ $ zfs create -o mountpoint=/var/lib/containerd/io.containerd.snapshotter.v1.zfs
The zfs plugin is a containerd sub-project, licensed under the [Apache 2.0 license](./LICENSE).
As a containerd sub-project, you will find the:
* [Project governance](https://github.com/containerd/project/blob/master/GOVERNANCE.md),
* [Maintainers](https://github.com/containerd/project/blob/master/MAINTAINERS),
* and [Contributing guidelines](https://github.com/containerd/project/blob/master/CONTRIBUTING.md)
* [Project governance](https://github.com/containerd/project/blob/main/GOVERNANCE.md),
* [Maintainers](https://github.com/containerd/project/blob/main/MAINTAINERS),
* and [Contributing guidelines](https://github.com/containerd/project/blob/main/CONTRIBUTING.md)
information in our [`containerd/project`](https://github.com/containerd/project) repository.

View File

@@ -1,3 +1,5 @@
//go:build linux || freebsd
/*
Copyright The containerd Authors.
@@ -17,10 +19,12 @@
package plugin
import (
"errors"
"fmt"
"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
@@ -50,7 +54,7 @@ func init() {
ic.Meta.Exports["root"] = root
snapshotter, err := zfs.NewSnapshotter(root)
if err != nil {
return nil, errors.Wrap(plugin.ErrSkipPlugin, err.Error())
return nil, fmt.Errorf("%s: %w", err.Error(), plugin.ErrSkipPlugin)
}
return snapshotter, nil
},

View File

@@ -1,4 +1,4 @@
// +build linux freebsd
//go:build linux || freebsd
/*
Copyright The containerd Authors.
@@ -20,6 +20,7 @@ package zfs
import (
"context"
"fmt"
"math"
"path/filepath"
@@ -27,8 +28,7 @@ import (
"github.com/containerd/containerd/mount"
"github.com/containerd/containerd/snapshots"
"github.com/containerd/containerd/snapshots/storage"
zfs "github.com/mistifyio/go-zfs"
"github.com/pkg/errors"
"github.com/mistifyio/go-zfs/v3"
)
const (
@@ -56,7 +56,7 @@ func NewSnapshotter(root string) (snapshots.Snapshotter, error) {
return nil, err
}
if m.FSType != "zfs" {
return nil, errors.Errorf("path %s must be a zfs filesystem to be used with the zfs snapshotter", root)
return nil, fmt.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 {
@@ -75,11 +75,9 @@ func NewSnapshotter(root string) (snapshots.Snapshotter, error) {
return b, nil
}
var (
zfsCreateProperties = map[string]string{
"mountpoint": "legacy",
}
)
var zfsCreateProperties = map[string]string{
"mountpoint": "legacy",
}
// createFilesystem creates but not mount.
func createFilesystem(datasetName string) (*zfs.Dataset, error) {
@@ -138,13 +136,12 @@ func (z *snapshotter) usage(ctx context.Context, key string) (snapshots.Usage, e
if info.Kind == snapshots.KindActive {
activeName := filepath.Join(z.dataset.Name, id)
sDataset, err := zfs.GetDataset(activeName)
if err != nil {
return snapshots.Usage{}, err
}
if int64(sDataset.Used) > maxSnapshotSize {
return snapshots.Usage{}, errors.Errorf("Dataset size exceeds maximum snapshot size of %d bytes", maxSnapshotSize)
return snapshots.Usage{}, fmt.Errorf("Dataset size exceeds maximum snapshot size of %d bytes", maxSnapshotSize)
}
usage = snapshots.Usage{
@@ -240,7 +237,7 @@ func (z *snapshotter) mounts(dataset *zfs.Dataset, readonly bool) ([]mount.Mount
func (z *snapshotter) Commit(ctx context.Context, name, key string, opts ...snapshots.Opt) (err error) {
usage, err := z.usage(ctx, key)
if err != nil {
return errors.Wrap(err, "failed to compute usage")
return fmt.Errorf("failed to compute usage: %w", err)
}
ctx, t, err := z.ms.TransactionContext(ctx, true)
@@ -257,7 +254,7 @@ func (z *snapshotter) Commit(ctx context.Context, name, key string, opts ...snap
id, err := storage.CommitActive(ctx, key, name, usage, opts...)
if err != nil {
return errors.Wrap(err, "failed to commit")
return fmt.Errorf("failed to commit: %w", err)
}
activeName := filepath.Join(z.dataset.Name, id)
@@ -293,7 +290,7 @@ func (z *snapshotter) Mounts(ctx context.Context, key string) ([]mount.Mount, er
s, err := storage.GetSnapshot(ctx, key)
t.Rollback() //nolint:errcheck
if err != nil {
return nil, errors.Wrap(err, "failed to get active snapshot")
return nil, fmt.Errorf("failed to get active snapshot: %w", err)
}
sName := filepath.Join(z.dataset.Name, s.ID)
sDataset, err := zfs.GetDataset(sName)
@@ -321,7 +318,7 @@ func (z *snapshotter) Remove(ctx context.Context, key string) (err error) {
id, k, err := storage.Remove(ctx, key)
if err != nil {
return errors.Wrap(err, "failed to remove snapshot")
return fmt.Errorf("failed to remove snapshot: %w", err)
}
datasetName := filepath.Join(z.dataset.Name, id)