diff --git a/.gometalinter.json b/.gometalinter.json index ef5d6f0d5..177be92a1 100644 --- a/.gometalinter.json +++ b/.gometalinter.json @@ -10,6 +10,10 @@ "WarnUnmatchedDirective": true, "Enable": [ + "structcheck", + "unused", + "varcheck", + "gofmt", "goimports", "golint", diff --git a/archive/path.go b/archive/path.go deleted file mode 100644 index 0f6cfa32e..000000000 --- a/archive/path.go +++ /dev/null @@ -1 +0,0 @@ -package archive diff --git a/cmd/containerd-shim/main_unix.go b/cmd/containerd-shim/main_unix.go index 232c4bbfc..f1163d0d2 100644 --- a/cmd/containerd-shim/main_unix.go +++ b/cmd/containerd-shim/main_unix.go @@ -29,16 +29,6 @@ import ( "google.golang.org/grpc" ) -const usage = ` - __ _ __ __ _ - _________ ____ / /_____ _(_)___ ___ _________/ / _____/ /_ (_)___ ___ - / ___/ __ \/ __ \/ __/ __ ` + "`" + `/ / __ \/ _ \/ ___/ __ /_____/ ___/ __ \/ / __ ` + "`" + `__ \ -/ /__/ /_/ / / / / /_/ /_/ / / / / / __/ / / /_/ /_____(__ ) / / / / / / / / / -\___/\____/_/ /_/\__/\__,_/_/_/ /_/\___/_/ \__,_/ /____/_/ /_/_/_/ /_/ /_/ - -shim for container lifecycle and reconnection -` - var ( debugFlag bool namespaceFlag string diff --git a/cmd/containerd-stress/main.go b/cmd/containerd-stress/main.go index 17eb70674..284c7e305 100644 --- a/cmd/containerd-stress/main.go +++ b/cmd/containerd-stress/main.go @@ -236,16 +236,6 @@ func (w *worker) getID() string { return fmt.Sprintf("%d-%d", w.id, w.count) } -func (w *worker) cleanup(ctx context.Context, c containerd.Container) { - if err := c.Delete(ctx, containerd.WithSnapshotCleanup); err != nil { - if err == context.DeadlineExceeded { - return - } - w.failures++ - logrus.WithError(err).Errorf("delete container %s", c.ID()) - } -} - // cleanup cleans up any containers in the "stress" namespace before the test run func cleanup(ctx context.Context, client *containerd.Client) error { containers, err := client.Containers(ctx) diff --git a/cmd/containerd/main.go b/cmd/containerd/main.go index 04a178af8..6a923d519 100644 --- a/cmd/containerd/main.go +++ b/cmd/containerd/main.go @@ -8,7 +8,6 @@ import ( "net" "os" "os/signal" - "runtime" "time" "google.golang.org/grpc/grpclog" @@ -196,18 +195,3 @@ func setLevel(context *cli.Context, config *server.Config) error { } return nil } - -func dumpStacks() { - var ( - buf []byte - stackSize int - ) - bufferLen := 16384 - for stackSize == len(buf) { - buf = make([]byte, bufferLen) - stackSize = runtime.Stack(buf, true) - bufferLen *= 2 - } - buf = buf[:stackSize] - logrus.Infof("=== BEGIN goroutine stack dump ===\n%s\n=== END goroutine stack dump ===", buf) -} diff --git a/cmd/containerd/main_unix.go b/cmd/containerd/main_unix.go index ba39a381d..f400fad2f 100644 --- a/cmd/containerd/main_unix.go +++ b/cmd/containerd/main_unix.go @@ -5,7 +5,9 @@ package main import ( "context" "os" + "runtime" + "github.com/sirupsen/logrus" "golang.org/x/sys/unix" "github.com/containerd/containerd/log" @@ -55,3 +57,18 @@ func handleSignals(ctx context.Context, signals chan os.Signal, serverC chan *se }() return done } + +func dumpStacks() { + var ( + buf []byte + stackSize int + ) + bufferLen := 16384 + for stackSize == len(buf) { + buf = make([]byte, bufferLen) + stackSize = runtime.Stack(buf, true) + bufferLen *= 2 + } + buf = buf[:stackSize] + logrus.Infof("=== BEGIN goroutine stack dump ===\n%s\n=== END goroutine stack dump ===", buf) +} diff --git a/cmd/ctr/commands/images/push.go b/cmd/ctr/commands/images/push.go index d37653918..b8b2ee878 100644 --- a/cmd/ctr/commands/images/push.go +++ b/cmd/ctr/commands/images/push.go @@ -133,13 +133,6 @@ var pushCommand = cli.Command{ }, } -type pushStatus struct { - name string - started bool - written int64 - total int64 -} - type pushjobs struct { jobs map[string]struct{} ordered []string diff --git a/cmd/ctr/commands/run/run_windows.go b/cmd/ctr/commands/run/run_windows.go index 5a004b65f..be7e3f6ad 100644 --- a/cmd/ctr/commands/run/run_windows.go +++ b/cmd/ctr/commands/run/run_windows.go @@ -14,8 +14,6 @@ import ( "github.com/urfave/cli" ) -const pipeRoot = `\\.\pipe` - func init() { Command.Flags = append(Command.Flags, cli.StringSliceFlag{ Name: "layer", @@ -50,10 +48,6 @@ func withTTY(terminal bool) containerd.SpecOpts { return containerd.WithTTY(int(size.Width), int(size.Height)) } -func setHostNetworking() containerd.SpecOpts { - return nil -} - func newContainer(ctx gocontext.Context, client *containerd.Client, context *cli.Context) (containerd.Container, error) { var ( // ref = context.Args().First() diff --git a/cmd/ctr/commands/shim/io_windows.go b/cmd/ctr/commands/shim/io_windows.go deleted file mode 100644 index 4125b3fdd..000000000 --- a/cmd/ctr/commands/shim/io_windows.go +++ /dev/null @@ -1,91 +0,0 @@ -package shim - -import ( - "io" - "net" - "os" - "sync" - - "github.com/Microsoft/go-winio" - clog "github.com/containerd/containerd/log" - "github.com/pkg/errors" -) - -func prepareStdio(stdin, stdout, stderr string, console bool) (*sync.WaitGroup, error) { - var wg sync.WaitGroup - - if stdin != "" { - l, err := winio.ListenPipe(stdin, nil) - if err != nil { - return nil, errors.Wrapf(err, "failed to create stdin pipe %s", stdin) - } - defer func(l net.Listener) { - if err != nil { - l.Close() - } - }(l) - - go func() { - c, err := l.Accept() - if err != nil { - clog.L.WithError(err).Errorf("failed to accept stdin connection on %s", stdin) - return - } - io.Copy(c, os.Stdin) - c.Close() - l.Close() - }() - } - - if stdout != "" { - l, err := winio.ListenPipe(stdout, nil) - if err != nil { - return nil, errors.Wrapf(err, "failed to create stdin pipe %s", stdout) - } - defer func(l net.Listener) { - if err != nil { - l.Close() - } - }(l) - - wg.Add(1) - go func() { - defer wg.Done() - c, err := l.Accept() - if err != nil { - clog.L.WithError(err).Errorf("failed to accept stdout connection on %s", stdout) - return - } - io.Copy(os.Stdout, c) - c.Close() - l.Close() - }() - } - - if !console && stderr != "" { - l, err := winio.ListenPipe(stderr, nil) - if err != nil { - return nil, errors.Wrapf(err, "failed to create stderr pipe %s", stderr) - } - defer func(l net.Listener) { - if err != nil { - l.Close() - } - }(l) - - wg.Add(1) - go func() { - defer wg.Done() - c, err := l.Accept() - if err != nil { - clog.L.WithError(err).Errorf("failed to accept stderr connection on %s", stderr) - return - } - io.Copy(os.Stderr, c) - c.Close() - l.Close() - }() - } - - return &wg, nil -} diff --git a/container_linux_test.go b/container_linux_test.go index 06a35ae07..cbdebab99 100644 --- a/container_linux_test.go +++ b/container_linux_test.go @@ -1028,9 +1028,9 @@ func testUserNamespaces(t *testing.T, readonlyRootFS bool) { WithUserNamespace(0, 1000, 10000), )} if readonlyRootFS { - opts = append(opts, withRemappedSnapshotView(id, image, 1000, 1000)) + opts = append(opts, WithRemappedSnapshotView(id, image, 1000, 1000)) } else { - opts = append(opts, withRemappedSnapshot(id, image, 1000, 1000)) + opts = append(opts, WithRemappedSnapshot(id, image, 1000, 1000)) } container, err := client.NewContainer(ctx, id, opts...) diff --git a/container_test.go b/container_test.go index db6e63910..b4ad7315d 100644 --- a/container_test.go +++ b/container_test.go @@ -437,7 +437,6 @@ func TestContainerCloseIO(t *testing.T) { } defer container.Delete(ctx, WithSnapshotCleanup) - const expected = "hello" + newLine stdout := bytes.NewBuffer(nil) r, w, err := os.Pipe() diff --git a/content/local/store_unix.go b/content/local/store_unix.go index 0d500b84d..c0587e1b2 100644 --- a/content/local/store_unix.go +++ b/content/local/store_unix.go @@ -10,15 +10,6 @@ import ( "github.com/containerd/containerd/sys" ) -func getStartTime(fi os.FileInfo) time.Time { - if st, ok := fi.Sys().(*syscall.Stat_t); ok { - return time.Unix(int64(sys.StatCtime(st).Sec), - int64(sys.StatCtime(st).Nsec)) - } - - return fi.ModTime() -} - func getATime(fi os.FileInfo) time.Time { if st, ok := fi.Sys().(*syscall.Stat_t); ok { return time.Unix(int64(sys.StatAtime(st).Sec), diff --git a/content/local/store_windows.go b/content/local/store_windows.go index 5f12ea5c4..f745aafdb 100644 --- a/content/local/store_windows.go +++ b/content/local/store_windows.go @@ -5,10 +5,6 @@ import ( "time" ) -func getStartTime(fi os.FileInfo) time.Time { - return fi.ModTime() -} - func getATime(fi os.FileInfo) time.Time { return fi.ModTime() } diff --git a/debug/debug.go b/debug/debug.go index 6359f1008..8d127034a 100644 --- a/debug/debug.go +++ b/debug/debug.go @@ -4,7 +4,6 @@ import ( "bufio" "fmt" "os" - "sort" "strconv" "strings" ) @@ -55,12 +54,3 @@ func getMaps(pid int) (map[string]int, error) { } return smaps, nil } - -func keys(smaps map[string]int) []string { - var o []string - for k := range smaps { - o = append(o, k) - } - sort.Strings(o) - return o -} diff --git a/fs/diff_unix.go b/fs/diff_unix.go index 36a0f3fde..375181444 100644 --- a/fs/diff_unix.go +++ b/fs/diff_unix.go @@ -5,36 +5,12 @@ package fs import ( "bytes" "os" - "path/filepath" - "strings" "syscall" "github.com/containerd/continuity/sysx" "github.com/pkg/errors" ) -// whiteouts are files with a special meaning for the layered filesystem. -// Docker uses AUFS whiteout files inside exported archives. In other -// filesystems these files are generated/handled on tar creation/extraction. - -// whiteoutPrefix prefix means file is a whiteout. If this is followed by a -// filename this means that file has been removed from the base layer. -const whiteoutPrefix = ".wh." - -// whiteoutMetaPrefix prefix means whiteout has a special meaning and is not -// for removing an actual file. Normally these files are excluded from exported -// archives. -const whiteoutMetaPrefix = whiteoutPrefix + whiteoutPrefix - -// whiteoutLinkDir is a directory AUFS uses for storing hardlink links to other -// layers. Normally these should not go into exported archives and all changed -// hardlinks should be copied to the top layer. -const whiteoutLinkDir = whiteoutMetaPrefix + "plnk" - -// whiteoutOpaqueDir file means directory has been made opaque - meaning -// readdir calls to this directory do not follow to lower layers. -const whiteoutOpaqueDir = whiteoutMetaPrefix + ".opq" - // detectDirDiff returns diff dir options if a directory could // be found in the mount info for upper which is the direct // diff with the provided lower directory @@ -45,26 +21,6 @@ func detectDirDiff(upper, lower string) *diffDirOptions { return nil } -func aufsMetadataSkip(path string) (skip bool, err error) { - skip, err = filepath.Match(string(os.PathSeparator)+whiteoutMetaPrefix+"*", path) - if err != nil { - skip = true - } - return -} - -func aufsDeletedFile(root, path string, fi os.FileInfo) (string, error) { - f := filepath.Base(path) - - // If there is a whiteout, then the file was removed - if strings.HasPrefix(f, whiteoutPrefix) { - originalFile := f[len(whiteoutPrefix):] - return filepath.Join(filepath.Dir(path), originalFile), nil - } - - return "", nil -} - // compareSysStat returns whether the stats are equivalent, // whether the files are considered the same file, and // an error diff --git a/fs/path_test.go b/fs/path_test.go index f85416a98..90920c7fc 100644 --- a/fs/path_test.go +++ b/fs/path_test.go @@ -24,7 +24,6 @@ func TestRootPath(t *testing.T) { name string apply fstest.Applier checks []RootCheck - scope func(string) (string, error) }{ { name: "SymlinkAbsolute", diff --git a/gc/gc_test.go b/gc/gc_test.go index c3c6a9590..7e9fdfcc3 100644 --- a/gc/gc_test.go +++ b/gc/gc_test.go @@ -108,47 +108,3 @@ func toNodes(s []string) []Node { } return n } - -func newScanner(refs []string) *stringScanner { - return &stringScanner{ - i: -1, - s: refs, - } -} - -type stringScanner struct { - i int - s []string -} - -func (ss *stringScanner) Next() bool { - ss.i++ - return ss.i < len(ss.s) -} - -func (ss *stringScanner) Node() Node { - return Node{ - Key: ss.s[ss.i], - } -} - -func (ss *stringScanner) Cleanup() error { - ss.s[ss.i] = "" - return nil -} - -func (ss *stringScanner) Err() error { - return nil -} - -func (ss *stringScanner) All() []Node { - remaining := make([]Node, 0, len(ss.s)) - for _, s := range ss.s { - if s != "" { - remaining = append(remaining, Node{ - Key: s, - }) - } - } - return remaining -} diff --git a/helpers_unix_test.go b/helpers_unix_test.go index bb25c75f3..089be2620 100644 --- a/helpers_unix_test.go +++ b/helpers_unix_test.go @@ -40,8 +40,6 @@ func withExecArgs(s *specs.Process, args ...string) { } var ( - withRemappedSnapshot = WithRemappedSnapshot - withRemappedSnapshotView = WithRemappedSnapshotView - withNewSnapshot = WithNewSnapshot - withImageConfig = WithImageConfig + withNewSnapshot = WithNewSnapshot + withImageConfig = WithImageConfig ) diff --git a/helpers_windows_test.go b/helpers_windows_test.go index fd2f9b2c1..3ad33f8f8 100644 --- a/helpers_windows_test.go +++ b/helpers_windows_test.go @@ -52,19 +52,3 @@ func withNewSnapshot(id string, i Image) NewContainerOpts { return nil } } - -func withRemappedSnapshot(id string, i Image, u, g uint32) NewContainerOpts { - return func(ctx context.Context, client *Client, c *containers.Container) error { - return nil - } -} - -func withRemappedSnapshotView(id string, i Image, u, g uint32) NewContainerOpts { - return func(ctx context.Context, client *Client, c *containers.Container) error { - return nil - } -} - -func withNoop(_ context.Context, _ *Client, _ *containers.Container, _ *specs.Spec) error { - return nil -} diff --git a/linux/proc/io.go b/linux/proc/io.go index 1907d4362..e78b38300 100644 --- a/linux/proc/io.go +++ b/linux/proc/io.go @@ -9,44 +9,10 @@ import ( "sync" "syscall" - "github.com/containerd/console" "github.com/containerd/fifo" runc "github.com/containerd/go-runc" ) -func copyConsole(ctx context.Context, console console.Console, stdin, stdout, stderr string, wg, cwg *sync.WaitGroup) error { - if stdin != "" { - in, err := fifo.OpenFifo(ctx, stdin, syscall.O_RDONLY, 0) - if err != nil { - return err - } - cwg.Add(1) - go func() { - cwg.Done() - io.Copy(console, in) - }() - } - outw, err := fifo.OpenFifo(ctx, stdout, syscall.O_WRONLY, 0) - if err != nil { - return err - } - outr, err := fifo.OpenFifo(ctx, stdout, syscall.O_RDONLY, 0) - if err != nil { - return err - } - wg.Add(1) - cwg.Add(1) - go func() { - cwg.Done() - io.Copy(outw, console) - console.Close() - outr.Close() - outw.Close() - wg.Done() - }() - return nil -} - func copyPipes(ctx context.Context, rio runc.IO, stdin, stdout, stderr string, wg, cwg *sync.WaitGroup) error { for name, dest := range map[string]func(wc io.WriteCloser, rc io.Closer){ stdout: func(wc io.WriteCloser, rc io.Closer) { diff --git a/linux/shim/client/client.go b/linux/shim/client/client.go index 00976ac6a..7525dada7 100644 --- a/linux/shim/client/client.go +++ b/linux/shim/client/client.go @@ -154,11 +154,6 @@ func connect(address string, d func(string, time.Duration) (net.Conn, error)) (* return conn, nil } -func dialer(address string, timeout time.Duration) (net.Conn, error) { - address = strings.TrimPrefix(address, "unix://") - return net.DialTimeout("unix", address, timeout) -} - func annonDialer(address string, timeout time.Duration) (net.Conn, error) { address = strings.TrimPrefix(address, "unix://") return net.DialTimeout("unix", "\x00"+address, timeout) diff --git a/metadata/buckets.go b/metadata/buckets.go index b6a66ba48..9325f1698 100644 --- a/metadata/buckets.go +++ b/metadata/buckets.go @@ -31,7 +31,6 @@ var ( bucketKeyVersion = []byte(schemaVersion) bucketKeyDBVersion = []byte("version") // stores the version of the schema bucketKeyObjectLabels = []byte("labels") // stores the labels for a namespace. - bucketKeyObjectIndexes = []byte("indexes") // reserved bucketKeyObjectImages = []byte("images") // stores image objects bucketKeyObjectContainers = []byte("containers") // stores container objects bucketKeyObjectSnapshots = []byte("snapshots") // stores snapshot references diff --git a/metadata/gc_test.go b/metadata/gc_test.go index 9cef83269..f85569bbf 100644 --- a/metadata/gc_test.go +++ b/metadata/gc_test.go @@ -402,22 +402,6 @@ func addLeaseContent(ns, lid string, dgst digest.Digest) alterFunc { } } -func addContainer(ns, name, snapshotter, snapshot string, labels map[string]string) alterFunc { - return func(bkt *bolt.Bucket) error { - cbkt, err := createBuckets(bkt, ns, string(bucketKeyObjectContainers), name) - if err != nil { - return err - } - if err := cbkt.Put(bucketKeySnapshotter, []byte(snapshotter)); err != nil { - return err - } - if err := cbkt.Put(bucketKeySnapshotKey, []byte(snapshot)); err != nil { - return err - } - return boltutil.WriteLabels(cbkt, labels) - } -} - func createBuckets(bkt *bolt.Bucket, names ...string) (*bolt.Bucket, error) { for _, name := range names { nbkt, err := bkt.CreateBucketIfNotExists([]byte(name)) diff --git a/metadata/snapshot.go b/metadata/snapshot.go index cdc0768c9..760cac80e 100644 --- a/metadata/snapshot.go +++ b/metadata/snapshot.go @@ -39,14 +39,6 @@ func createKey(id uint64, namespace, key string) string { return fmt.Sprintf("%s/%d/%s", namespace, id, key) } -func trimKey(key string) string { - parts := strings.SplitN(key, "/", 3) - if len(parts) < 3 { - return "" - } - return parts[2] -} - func getKey(tx *bolt.Tx, ns, name, key string) string { bkt := getSnapshotterBucket(tx, ns, name) if bkt == nil { diff --git a/progress/escape.go b/progress/escape.go index 5889efed8..7233e9b92 100644 --- a/progress/escape.go +++ b/progress/escape.go @@ -3,6 +3,6 @@ package progress const ( escape = "\x1b" reset = escape + "[0m" - red = escape + "[31m" + red = escape + "[31m" // nolint: unused, varcheck green = escape + "[32m" ) diff --git a/remotes/docker/resolver.go b/remotes/docker/resolver.go index a23e16e82..57a18b664 100644 --- a/remotes/docker/resolver.go +++ b/remotes/docker/resolver.go @@ -7,7 +7,6 @@ import ( "io" "io/ioutil" "net/http" - "net/textproto" "net/url" "path" "strconv" @@ -405,22 +404,6 @@ func copyRequest(req *http.Request) (*http.Request, error) { return &ireq, nil } -func isManifestAccept(h http.Header) bool { - for _, ah := range h[textproto.CanonicalMIMEHeaderKey("Accept")] { - switch ah { - case images.MediaTypeDockerSchema2Manifest: - fallthrough - case images.MediaTypeDockerSchema2ManifestList: - fallthrough - case ocispec.MediaTypeImageManifest: - fallthrough - case ocispec.MediaTypeImageIndex: - return true - } - } - return false -} - func (r *dockerBase) setTokenAuth(ctx context.Context, params map[string]string) error { realm, ok := params["realm"] if !ok { diff --git a/remotes/docker/schema1/converter.go b/remotes/docker/schema1/converter.go index 52f83d43f..dfc58e322 100644 --- a/remotes/docker/schema1/converter.go +++ b/remotes/docker/schema1/converter.go @@ -29,10 +29,6 @@ import ( const manifestSizeLimit = 8e6 // 8MB -var ( - mediaTypeManifest = "application/vnd.docker.distribution.manifest.v1+json" -) - type blobState struct { diffID digest.Digest empty bool diff --git a/services/images/helpers.go b/services/images/helpers.go index 374aefd6b..3d5be065c 100644 --- a/services/images/helpers.go +++ b/services/images/helpers.go @@ -17,16 +17,6 @@ func imagesToProto(images []images.Image) []imagesapi.Image { return imagespb } -func imagesFromProto(imagespb []imagesapi.Image) []images.Image { - var images []images.Image - - for _, image := range imagespb { - images = append(images, imageFromProto(&image)) - } - - return images -} - func imageToProto(image *images.Image) imagesapi.Image { return imagesapi.Image{ Name: image.Name, diff --git a/snapshot/overlay/overlay.go b/snapshot/overlay/overlay.go index e5c655f4a..33a1edd92 100644 --- a/snapshot/overlay/overlay.go +++ b/snapshot/overlay/overlay.go @@ -38,13 +38,6 @@ type snapshotter struct { ms *storage.MetaStore } -type activeSnapshot struct { - id string - name string - parentID interface{} - readonly bool -} - // NewSnapshotter returns a Snapshotter which uses overlayfs. The overlayfs // diffs are stored under the provided root. A metadata file is stored under // the root. diff --git a/snapshot/storage/metastore_test.go b/snapshot/storage/metastore_test.go index 91455a295..b34efa743 100644 --- a/snapshot/storage/metastore_test.go +++ b/snapshot/storage/metastore_test.go @@ -444,11 +444,6 @@ func testCommit(ctx context.Context, t *testing.T, ms *MetaStore) { assertNotActive(t, err) } -func testCommitNotExist(ctx context.Context, t *testing.T, ms *MetaStore) { - _, err := CommitActive(ctx, "active-not-exist", "committed-1", snapshot.Usage{}) - assertNotExist(t, err) -} - func testCommitExist(ctx context.Context, t *testing.T, ms *MetaStore) { if err := basePopulate(ctx, ms); err != nil { t.Fatalf("Populate failed: %+v", err) diff --git a/snapshot/testsuite/issues.go b/snapshot/testsuite/issues.go index eb317aff5..8d94aa192 100644 --- a/snapshot/testsuite/issues.go +++ b/snapshot/testsuite/issues.go @@ -99,6 +99,7 @@ func checkChown(ctx context.Context, t *testing.T, sn snapshot.Snapshotter, work // checkRename // https://github.com/docker/docker/issues/25409 func checkRename(ctx context.Context, t *testing.T, sn snapshot.Snapshotter, work string) { + t.Skip("rename test still fails on some kernels with overlay") l1Init := fstest.Apply( fstest.CreateDir("/dir1", 0700), fstest.CreateDir("/somefiles", 0700), diff --git a/snapshot/testsuite/testsuite.go b/snapshot/testsuite/testsuite.go index 1ff7101e8..9ed18a71f 100644 --- a/snapshot/testsuite/testsuite.go +++ b/snapshot/testsuite/testsuite.go @@ -38,8 +38,7 @@ func SnapshotterSuite(t *testing.T, name string, snapshotterFn func(ctx context. t.Run("RemoveIntermediateSnapshot", makeTest(name, snapshotterFn, checkRemoveIntermediateSnapshot)) t.Run("DeletedFilesInChildSnapshot", makeTest(name, snapshotterFn, checkDeletedFilesInChildSnapshot)) t.Run("MoveFileFromLowerLayer", makeTest(name, snapshotterFn, checkFileFromLowerLayer)) - // Rename test still fails on some kernels with overlay - //t.Run("Rename", makeTest(name, snapshotterFn, checkRename)) + t.Run("Rename", makeTest(name, snapshotterFn, checkRename)) t.Run("ViewReadonly", makeTest(name, snapshotterFn, checkSnapshotterViewReadonly)) diff --git a/task.go b/task.go index 8d447b32f..c69579764 100644 --- a/task.go +++ b/task.go @@ -8,7 +8,6 @@ import ( "io" goruntime "runtime" "strings" - "sync" "syscall" "time" @@ -152,8 +151,6 @@ type task struct { io cio.IO id string pid uint32 - - mu sync.Mutex } // Pid returns the pid or process id for the task diff --git a/testutil/mount_other.go b/testutil/mount_other.go index da3cb9e79..6e5853438 100644 --- a/testutil/mount_other.go +++ b/testutil/mount_other.go @@ -1,4 +1,4 @@ -// +build !linux +// +build !linux,!windows package testutil diff --git a/windows/hcsshim.go b/windows/hcsshim.go index 98ddee816..7801da749 100644 --- a/windows/hcsshim.go +++ b/windows/hcsshim.go @@ -10,7 +10,6 @@ import ( "strings" "github.com/Microsoft/hcsshim" - "github.com/Microsoft/opengcs/client" "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/log" specs "github.com/opencontainers/runtime-spec/specs-go" @@ -147,53 +146,6 @@ func newWindowsContainerConfig(ctx context.Context, owner, id string, spec *spec return conf, nil } -// newLinuxConfig generates a hcsshim Linux container configuration from the -// provided OCI Spec -func newLinuxConfig(ctx context.Context, owner, id string, spec *specs.Spec) (*hcsshim.ContainerConfig, error) { - conf, err := newContainerConfig(ctx, owner, id, spec) - if err != nil { - return nil, err - } - - conf.ContainerType = "Linux" - conf.HvPartition = true - - if len(spec.Windows.LayerFolders) < 1 { - return nil, errors.Wrap(errdefs.ErrInvalidArgument, - "spec.Windows.LayerFolders must have at least 1 layer") - } - var ( - layerFolders = spec.Windows.LayerFolders - ) - - config := &client.Config{} - if err := config.GenerateDefault(nil); err != nil { - return nil, err - } - - conf.HvRuntime = &hcsshim.HvRuntime{ - ImagePath: config.KirdPath, - LinuxKernelFile: config.KernelFile, - LinuxInitrdFile: config.InitrdFile, - LinuxBootParameters: config.BootParameters, - } - - // TODO: use the create request Mount for those - for _, layerPath := range layerFolders { - _, filename := filepath.Split(layerPath) - guid, err := hcsshim.NameToGuid(filename) - if err != nil { - return nil, errors.Wrapf(err, "unable to get GUID for %s", filename) - } - conf.Layers = append(conf.Layers, hcsshim.Layer{ - ID: guid.ToString(), - Path: filepath.Join(layerPath, "layer.vhd"), - }) - } - - return conf, nil -} - // removeLayer deletes the given layer, all associated containers must have // been shutdown for this to succeed. func removeLayer(ctx context.Context, path string) error { @@ -260,9 +212,3 @@ func newWindowsProcessConfig(processSpec *specs.Process, pset *pipeSet) *hcsshim conf.CommandLine = strings.Join(processSpec.Args, " ") return conf } - -func newLinuxProcessConfig(processSpec *specs.Process, pset *pipeSet) (*hcsshim.ProcessConfig, error) { - conf := newProcessConfig(processSpec, pset) - conf.CommandArgs = processSpec.Args - return conf, nil -}