Skip to content

Commit

Permalink
Containerd version upgrade and handle nameless images (#8)
Browse files Browse the repository at this point in the history
Co-authored-by: Saurabh <saurabh.kumar@deepfence.io>
  • Loading branch information
saurabh2253 and Saurabh authored Dec 23, 2021
1 parent c49ad43 commit f32d297
Show file tree
Hide file tree
Showing 3 changed files with 335 additions and 42 deletions.
9 changes: 7 additions & 2 deletions containerd/containerd.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"errors"
"fmt"
containerdApi "github.com/containerd/containerd"
"github.com/containerd/containerd/images"
"github.com/containerd/containerd/images/archive"
"github.com/containerd/containerd/namespaces"
"github.com/containerd/containerd/oci"
"github.com/deepfence/vessel/constants"
Expand Down Expand Up @@ -166,7 +168,9 @@ func (c Containerd) ExtractFileSystem(imageTarPath string, outputTarPath string,
fmt.Println("Error while opening image")
return err
}
imgs, err := client.Import(ctx, reader)
imgs, err := client.Import(ctx, reader,
containerdApi.WithSkipDigestRef(func(name string) bool { return name != "" }),
containerdApi.WithDigestRef(archive.DigestTranslator(imageName)))
if err != nil {
fmt.Println("Error while Importing image")
return err
Expand Down Expand Up @@ -217,8 +221,9 @@ func (c Containerd) ExtractFileSystem(imageTarPath string, outputTarPath string,
fmt.Println("Error while packing tar")
return err
}
defer container.Delete(ctx, containerdApi.WithSnapshotCleanup)
exec.Command("umount", target).Output()
exec.Command("rm", "-rf", target).Output()
container.Delete(ctx, containerdApi.WithSnapshotCleanup)
client.ImageService().Delete(ctx, imgs[0].Name, images.SynchronousDelete())
return nil
}
36 changes: 20 additions & 16 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/deepfence/vessel
go 1.17

require (
github.com/containerd/containerd v1.5.8
github.com/containerd/containerd v1.6.0-beta.4
github.com/docker/docker v20.10.9+incompatible
github.com/joho/godotenv v1.4.0
github.com/pkg/errors v0.9.1
Expand All @@ -12,11 +12,12 @@ require (
)

require (
github.com/Microsoft/go-winio v0.4.17 // indirect
github.com/Microsoft/hcsshim v0.8.23 // indirect
github.com/Microsoft/go-winio v0.5.1 // indirect
github.com/Microsoft/hcsshim v0.9.1 // indirect
github.com/bits-and-blooms/bitset v1.2.0 // indirect
github.com/containerd/cgroups v1.0.1 // indirect
github.com/containerd/continuity v0.1.0 // indirect
github.com/containerd/cgroups v1.0.2 // indirect
github.com/containerd/containerd/api v1.6.0-beta.3 // indirect
github.com/containerd/continuity v0.2.2-0.20211201162329-8e53e7cac79d // indirect
github.com/containerd/fifo v1.0.0 // indirect
github.com/containerd/ttrpc v1.1.0 // indirect
github.com/containerd/typeurl v1.0.2 // indirect
Expand All @@ -26,23 +27,26 @@ require (
github.com/docker/go-units v0.4.0 // indirect
github.com/gogo/googleapis v1.4.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect
github.com/golang/protobuf v1.5.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/uuid v1.2.0 // indirect
github.com/klauspost/compress v1.11.13 // indirect
github.com/moby/locker v1.0.1 // indirect
github.com/moby/sys/mountinfo v0.4.1 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/moby/sys/mountinfo v0.5.0 // indirect
github.com/moby/sys/signal v0.6.0 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.0.1 // indirect
github.com/opencontainers/runc v1.0.2 // indirect
github.com/opencontainers/image-spec v1.0.2-0.20211117181255-693428a734f5 // indirect
github.com/opencontainers/runc v1.0.3 // indirect
github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417 // indirect
github.com/opencontainers/selinux v1.8.2 // indirect
go.opencensus.io v0.22.3 // indirect
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110 // indirect
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a // indirect
golang.org/x/sys v0.0.0-20210426230700-d19ff857e887 // indirect
golang.org/x/text v0.3.4 // indirect
google.golang.org/genproto v0.0.0-20201110150050-8816d57aaa9a // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.24.0 // indirect
go.opentelemetry.io/otel v1.0.1 // indirect
go.opentelemetry.io/otel/trace v1.0.1 // indirect
golang.org/x/net v0.0.0-20210825183410-e898025ed96a // indirect
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359 // indirect
golang.org/x/text v0.3.6 // indirect
google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c // indirect
google.golang.org/protobuf v1.27.1 // indirect
)
Loading

0 comments on commit f32d297

Please sign in to comment.