1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Windows: libcontainerd cleanup

Signed-off-by: John Howard <jhoward@microsoft.com>
This commit is contained in:
John Howard 2016-03-18 20:29:27 -07:00
parent b77573f48e
commit e331df5aee
4 changed files with 17 additions and 74 deletions

View file

@ -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

View file

@ -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 {

View file

@ -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
}

View file

@ -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"