Skip to content

Commit

Permalink
Updated containerd snapshotter to be configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
ernoaapa committed Apr 29, 2018
1 parent 6d55d30 commit b69bd4d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 15 deletions.
6 changes: 6 additions & 0 deletions cmd/eliotd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ func main() {
EnvVar: "ELIOT_CONTAINERD",
Value: "/run/containerd/containerd.sock",
},
cli.StringFlag{
Name: "containerd-snapshotter",
Usage: "containerd snapshotter to use",
EnvVar: "ELIOT_CONTAINERD_SNAPSHOTTER",
Value: "overlayfs",
},
cli.DurationFlag{
Name: "timeout, t",
Usage: "total timeout for runtime requests",
Expand Down
1 change: 1 addition & 0 deletions cmd/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ func GetRuntimeClient(clicontext *cli.Context, hostname string) runtime.Client {
context.Background(),
clicontext.GlobalDuration("timeout"),
clicontext.GlobalString("containerd"),
clicontext.String("containerd-snapshotter"),
hostname,
)
}
Expand Down
28 changes: 13 additions & 15 deletions pkg/runtime/containerd.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,23 @@ import (
log "github.com/sirupsen/logrus"
)

var (
snapshotter = "overlayfs"
)

// ContainerdClient is containerd client wrapper
type ContainerdClient struct {
context context.Context
timeout time.Duration
address string
hostname string
context context.Context
timeout time.Duration
snapshotter string
address string
hostname string
}

// NewContainerdClient creates new containerd client with given timeout
func NewContainerdClient(context context.Context, timeout time.Duration, address, hostname string) *ContainerdClient {
func NewContainerdClient(context context.Context, timeout time.Duration, snapshotter, address, hostname string) *ContainerdClient {
return &ContainerdClient{
context: context,
timeout: timeout,
address: address,
hostname: hostname,
context: context,
timeout: timeout,
address: address,
snapshotter: snapshotter,
hostname: hostname,
}
}

Expand Down Expand Up @@ -209,7 +207,7 @@ func (c *ContainerdClient) CreateContainer(pod model.Pod, container model.Contai
containerOpts := []containerd.NewContainerOpts{
containerd.WithContainerLabels(mapping.NewLabels(pod, container)),
containerd.WithNewSpec(specOpts...),
containerd.WithSnapshotter(snapshotter),
containerd.WithSnapshotter(c.snapshotter),
containerd.WithNewSnapshot(id.String(), image),
containerd.WithRuntime(fmt.Sprintf("%s.%s", plugin.RuntimePlugin, "linux"), nil),
extensions.WithLifecycleExtension,
Expand Down Expand Up @@ -438,7 +436,7 @@ func (c *ContainerdClient) PullImage(namespace, ref string, progress *progress.I
return ErrWithMessagef(ErrNotSupported, "Image [%s] does not available for [%s/%s]", ref, runtime.GOOS, runtime.GOARCH)
}

if err := img.Unpack(ctx, snapshotter); err != nil {
if err := img.Unpack(ctx, c.snapshotter); err != nil {
return errors.Wrapf(err, "Error while unpacking image [%s] to namespace [%s]", ref, namespace)
}

Expand Down

0 comments on commit b69bd4d

Please sign in to comment.