Explorar o código

Windows: libcontainerd cleanup

Signed-off-by: John Howard <jhoward@microsoft.com>
John Howard %!s(int64=9) %!d(string=hai) anos
pai
achega
e331df5aee

+ 9 - 67
libcontainerd/client_windows.go

@@ -58,8 +58,7 @@ type natSettings struct {
 
 
 type networkConnection struct {
 type networkConnection struct {
 	NetworkName string
 	NetworkName string
-	//EnableNat bool
-	Nat natSettings
+	Nat         natSettings
 }
 }
 type networkSettings struct {
 type networkSettings struct {
 	MacAddress string
 	MacAddress string
@@ -77,7 +76,7 @@ type mappedDir struct {
 	ReadOnly      bool
 	ReadOnly      bool
 }
 }
 
 
-// TODO Windows RTM: @darrenstahlmsft Add ProcessorCount
+// TODO Windows: @darrenstahlmsft Add ProcessorCount
 type containerInit struct {
 type containerInit struct {
 	SystemType              string      // HCS requires this to be hard-coded to "Container"
 	SystemType              string      // HCS requires this to be hard-coded to "Container"
 	Name                    string      // Name of the container. We use the docker ID.
 	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)
 	cu.HvPartition = (spec.Windows.HvRuntime != nil)
+
+	// TODO Windows @jhowardmsft. FIXME post TP5.
 	//	if spec.Windows.HvRuntime != nil {
 	//	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 {
 	if cu.HvPartition {
@@ -498,73 +500,12 @@ func (clnt *client) Stats(containerID string) (*Stats, error) {
 
 
 // Restore is the handler for restoring a container
 // Restore is the handler for restoring a container
 func (clnt *client) Restore(containerID string, unusedOnWindows ...CreateOption) error {
 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)
 	logrus.Debugf("lcd Restore %s", containerID)
 	return clnt.backend.StateChanged(containerID, StateInfo{
 	return clnt.backend.StateChanged(containerID, StateInfo{
 		State:    StateExit,
 		State:    StateExit,
 		ExitCode: 1 << 31,
 		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.
 // 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")
 	return nil, errors.New("GetPidsForContainer: GetPidsForContainer() not implemented")
 }
 }
 
 
+// UpdateResources updates resources for a running container.
 func (clnt *client) UpdateResources(containerID string, resources Resources) error {
 func (clnt *client) UpdateResources(containerID string, resources Resources) error {
 	// Updating resource isn't supported on Windows
 	// Updating resource isn't supported on Windows
 	// but we should return nil for enabling updating container
 	// but we should return nil for enabling updating container

+ 2 - 2
libcontainerd/process_windows.go

@@ -4,11 +4,11 @@ import (
 	"io"
 	"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.
 // process keeps the state for both main container process and exec process.
 type process struct {
 type process struct {
 	processCommon
 	processCommon
+
+	// Platform specific fields are below here. There are none presently on Windows.
 }
 }
 
 
 func openReaderFromPipe(p io.ReadCloser) io.Reader {
 func openReaderFromPipe(p io.ReadCloser) io.Reader {

+ 3 - 4
libcontainerd/remote_windows.go

@@ -16,13 +16,12 @@ func (r *remote) Client(b Backend) (Client, error) {
 	return c, nil
 	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() {
 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) {
 func New(_ string, _ ...RemoteOption) (Remote, error) {
 	return &remote{}, nil
 	return &remote{}, nil
 }
 }

+ 3 - 1
libcontainerd/windowsoci/oci_windows.go

@@ -1,6 +1,8 @@
 package windowsoci
 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 (
 import (
 	"fmt"
 	"fmt"