Error on no rootfs provided

Signed-off-by: Darren Stahl <darst@microsoft.com>
This commit is contained in:
Darren Stahl 2018-01-16 16:32:27 -08:00
parent e981cc6289
commit acf2087db9

View File

@ -11,6 +11,7 @@ import (
"github.com/Microsoft/hcsshim"
eventstypes "github.com/containerd/containerd/api/events"
"github.com/containerd/containerd/api/types"
"github.com/containerd/containerd/errdefs"
"github.com/containerd/containerd/events"
"github.com/containerd/containerd/log"
@ -114,6 +115,10 @@ func (r *windowsRuntime) Create(ctx context.Context, id string, opts runtime.Cre
if createOpts.TerminateDuration == 0 {
createOpts.TerminateDuration = defaultTerminateDuration
}
if len(opts.Rootfs) == 0 {
return nil, errors.Wrap(errdefs.ErrInvalidArgument, "rootfs was not provided to container create")
}
spec.Windows.LayerFolders = append(spec.Windows.LayerFolders, opts.Rootfs[0].Source)
parentLayerPaths, err := opts.Rootfs[0].GetParentPaths()
if err != nil {
@ -301,6 +306,15 @@ func (r *windowsRuntime) newTask(ctx context.Context, namespace, id string, root
}
r.tasks.Add(ctx, t)
var eventRootfs []*types.Mount
for _, m := range rootfs {
eventRootfs = append(eventRootfs, &types.Mount{
Type: m.Type,
Source: m.Source,
Options: m.Options,
})
}
r.publisher.Publish(ctx,
runtime.TaskCreateEventTopic,
&eventstypes.TaskCreate{
@ -312,7 +326,7 @@ func (r *windowsRuntime) newTask(ctx context.Context, namespace, id string, root
Terminal: io.Terminal,
},
Pid: t.pid,
//???Rootfs: rootfs,
Rootfs: eventRootfs,
// TODO: what should be in Bundle for windows?
})