From e331df5aeefc1ebaa7a79ceb78350aba8cdabba1 Mon Sep 17 00:00:00 2001 From: John Howard Date: Fri, 18 Mar 2016 20:29:27 -0700 Subject: [PATCH] Windows: libcontainerd cleanup Signed-off-by: John Howard --- libcontainerd/client_windows.go | 76 +++---------------------- libcontainerd/process_windows.go | 4 +- libcontainerd/remote_windows.go | 7 +-- libcontainerd/windowsoci/oci_windows.go | 4 +- 4 files changed, 17 insertions(+), 74 deletions(-) diff --git a/libcontainerd/client_windows.go b/libcontainerd/client_windows.go index b97d03d234..020bc894c1 100644 --- a/libcontainerd/client_windows.go +++ b/libcontainerd/client_windows.go @@ -58,8 +58,7 @@ type natSettings struct { type networkConnection struct { NetworkName string - //EnableNat bool - Nat natSettings + Nat natSettings } type networkSettings struct { MacAddress string @@ -77,7 +76,7 @@ type mappedDir struct { ReadOnly bool } -// TODO Windows RTM: @darrenstahlmsft Add ProcessorCount +// TODO Windows: @darrenstahlmsft Add ProcessorCount type containerInit struct { SystemType string // HCS requires this to be hard-coded to "Container" Name string // Name of the container. We use the docker ID. @@ -153,10 +152,13 @@ func (clnt *client) Create(containerID string, spec Spec, options ...CreateOptio } } - // TODO Ultimately need to set the path from HvRuntime.ImagePath cu.HvPartition = (spec.Windows.HvRuntime != nil) + + // TODO Windows @jhowardmsft. FIXME post TP5. // if spec.Windows.HvRuntime != nil { - // cu.HvPartition = len(spec.Windows.HvRuntime.ImagePath) > 0 + // if spec.WIndows.HVRuntime.ImagePath != "" { + // cu.TBD = spec.Windows.HvRuntime.ImagePath + // } // } if cu.HvPartition { @@ -498,73 +500,12 @@ func (clnt *client) Stats(containerID string) (*Stats, error) { // Restore is the handler for restoring a container func (clnt *client) Restore(containerID string, unusedOnWindows ...CreateOption) error { - + // TODO Windows: Implement this. For now, just tell the backend the container exited. logrus.Debugf("lcd Restore %s", containerID) return clnt.backend.StateChanged(containerID, StateInfo{ State: StateExit, ExitCode: 1 << 31, }) - - // var err error - // clnt.lock(containerID) - // defer clnt.unlock(containerID) - - // logrus.Debugf("restore container %s state %s", containerID) - - // if _, err := clnt.getContainer(containerID); err == nil { - // return fmt.Errorf("container %s is aleady active", containerID) - // } - - // defer func() { - // if err != nil { - // clnt.deleteContainer(containerID) - // } - // }() - - // // ====> BUGBUG Where does linux get the pid from systemPid: pid, - // container := &container{ - // containerCommon: containerCommon{ - // process: process{ - // processCommon: processCommon{ - // containerID: containerID, - // client: clnt, - // friendlyName: InitFriendlyName, - // }, - // }, - // processes: make(map[string]*process), - // }, - // } - - // container.systemPid = systemPid(cont) - - // var terminal bool - // for _, p := range cont.Processes { - // if p.Pid == InitFriendlyName { - // terminal = p.Terminal - // } - // } - - // iopipe, err := container.openFifos(terminal) - // if err != nil { - // return err - // } - - // if err := clnt.backend.AttachStreams(containerID, *iopipe); err != nil { - // return err - // } - - // clnt.appendContainer(container) - - // err = clnt.backend.StateChanged(containerID, StateInfo{ - // State: StateRestore, - // Pid: container.systemPid, - // }) - - // if err != nil { - // return err - // } - - // return nil } // GetPidsForContainers is not implemented on Windows. @@ -572,6 +513,7 @@ func (clnt *client) GetPidsForContainer(containerID string) ([]int, error) { return nil, errors.New("GetPidsForContainer: GetPidsForContainer() not implemented") } +// UpdateResources updates resources for a running container. func (clnt *client) UpdateResources(containerID string, resources Resources) error { // Updating resource isn't supported on Windows // but we should return nil for enabling updating container diff --git a/libcontainerd/process_windows.go b/libcontainerd/process_windows.go index 2905fad1fb..bb142243a3 100644 --- a/libcontainerd/process_windows.go +++ b/libcontainerd/process_windows.go @@ -4,11 +4,11 @@ import ( "io" ) -// process keeps the state for both main container process and exec process. - // process keeps the state for both main container process and exec process. type process struct { processCommon + + // Platform specific fields are below here. There are none presently on Windows. } func openReaderFromPipe(p io.ReadCloser) io.Reader { diff --git a/libcontainerd/remote_windows.go b/libcontainerd/remote_windows.go index b6133fe16c..c313779ee2 100644 --- a/libcontainerd/remote_windows.go +++ b/libcontainerd/remote_windows.go @@ -16,13 +16,12 @@ func (r *remote) Client(b Backend) (Client, error) { return c, nil } -// Cleanup is a no-op on Windows. It is here to implement the same interface -// to meet compilation requirements. +// Cleanup is a no-op on Windows. It is here to implement the interface. func (r *remote) Cleanup() { } -// New creates a fresh instance of libcontainerd remote. This is largely -// a no-op on Windows. +// New creates a fresh instance of libcontainerd remote. On Windows, +// this is not used as there is no remote containerd process. func New(_ string, _ ...RemoteOption) (Remote, error) { return &remote{}, nil } diff --git a/libcontainerd/windowsoci/oci_windows.go b/libcontainerd/windowsoci/oci_windows.go index c948805954..3b9f5a3a8a 100644 --- a/libcontainerd/windowsoci/oci_windows.go +++ b/libcontainerd/windowsoci/oci_windows.go @@ -1,6 +1,8 @@ package windowsoci -// This file is a hack - essentially a mirror of OCI spec for Windows. +// This file contains the Windows spec for a container. At the time of +// writing, Windows does not have a spec defined in opencontainers/specs, +// hence this is an interim workaround. TODO Windows: FIXME @jhowardmsft import ( "fmt"