Skip to content

Commit e331df5

Browse files
author
John Howard
committed
Windows: libcontainerd cleanup
Signed-off-by: John Howard <jhoward@microsoft.com>
1 parent b77573f commit e331df5

File tree

4 files changed

+17
-74
lines changed

4 files changed

+17
-74
lines changed

libcontainerd/client_windows.go

Lines changed: 9 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ type natSettings struct {
5858

5959
type networkConnection struct {
6060
NetworkName string
61-
//EnableNat bool
62-
Nat natSettings
61+
Nat natSettings
6362
}
6463
type networkSettings struct {
6564
MacAddress string
@@ -77,7 +76,7 @@ type mappedDir struct {
7776
ReadOnly bool
7877
}
7978

80-
// TODO Windows RTM: @darrenstahlmsft Add ProcessorCount
79+
// TODO Windows: @darrenstahlmsft Add ProcessorCount
8180
type containerInit struct {
8281
SystemType string // HCS requires this to be hard-coded to "Container"
8382
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
153152
}
154153
}
155154

156-
// TODO Ultimately need to set the path from HvRuntime.ImagePath
157155
cu.HvPartition = (spec.Windows.HvRuntime != nil)
156+
157+
// TODO Windows @jhowardmsft. FIXME post TP5.
158158
// if spec.Windows.HvRuntime != nil {
159-
// cu.HvPartition = len(spec.Windows.HvRuntime.ImagePath) > 0
159+
// if spec.WIndows.HVRuntime.ImagePath != "" {
160+
// cu.TBD = spec.Windows.HvRuntime.ImagePath
161+
// }
160162
// }
161163

162164
if cu.HvPartition {
@@ -498,80 +500,20 @@ func (clnt *client) Stats(containerID string) (*Stats, error) {
498500

499501
// Restore is the handler for restoring a container
500502
func (clnt *client) Restore(containerID string, unusedOnWindows ...CreateOption) error {
501-
503+
// TODO Windows: Implement this. For now, just tell the backend the container exited.
502504
logrus.Debugf("lcd Restore %s", containerID)
503505
return clnt.backend.StateChanged(containerID, StateInfo{
504506
State: StateExit,
505507
ExitCode: 1 << 31,
506508
})
507-
508-
// var err error
509-
// clnt.lock(containerID)
510-
// defer clnt.unlock(containerID)
511-
512-
// logrus.Debugf("restore container %s state %s", containerID)
513-
514-
// if _, err := clnt.getContainer(containerID); err == nil {
515-
// return fmt.Errorf("container %s is aleady active", containerID)
516-
// }
517-
518-
// defer func() {
519-
// if err != nil {
520-
// clnt.deleteContainer(containerID)
521-
// }
522-
// }()
523-
524-
// // ====> BUGBUG Where does linux get the pid from systemPid: pid,
525-
// container := &container{
526-
// containerCommon: containerCommon{
527-
// process: process{
528-
// processCommon: processCommon{
529-
// containerID: containerID,
530-
// client: clnt,
531-
// friendlyName: InitFriendlyName,
532-
// },
533-
// },
534-
// processes: make(map[string]*process),
535-
// },
536-
// }
537-
538-
// container.systemPid = systemPid(cont)
539-
540-
// var terminal bool
541-
// for _, p := range cont.Processes {
542-
// if p.Pid == InitFriendlyName {
543-
// terminal = p.Terminal
544-
// }
545-
// }
546-
547-
// iopipe, err := container.openFifos(terminal)
548-
// if err != nil {
549-
// return err
550-
// }
551-
552-
// if err := clnt.backend.AttachStreams(containerID, *iopipe); err != nil {
553-
// return err
554-
// }
555-
556-
// clnt.appendContainer(container)
557-
558-
// err = clnt.backend.StateChanged(containerID, StateInfo{
559-
// State: StateRestore,
560-
// Pid: container.systemPid,
561-
// })
562-
563-
// if err != nil {
564-
// return err
565-
// }
566-
567-
// return nil
568509
}
569510

570511
// GetPidsForContainers is not implemented on Windows.
571512
func (clnt *client) GetPidsForContainer(containerID string) ([]int, error) {
572513
return nil, errors.New("GetPidsForContainer: GetPidsForContainer() not implemented")
573514
}
574515

516+
// UpdateResources updates resources for a running container.
575517
func (clnt *client) UpdateResources(containerID string, resources Resources) error {
576518
// Updating resource isn't supported on Windows
577519
// but we should return nil for enabling updating container

libcontainerd/process_windows.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import (
44
"io"
55
)
66

7-
// process keeps the state for both main container process and exec process.
8-
97
// process keeps the state for both main container process and exec process.
108
type process struct {
119
processCommon
10+
11+
// Platform specific fields are below here. There are none presently on Windows.
1212
}
1313

1414
func openReaderFromPipe(p io.ReadCloser) io.Reader {

libcontainerd/remote_windows.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,12 @@ func (r *remote) Client(b Backend) (Client, error) {
1616
return c, nil
1717
}
1818

19-
// Cleanup is a no-op on Windows. It is here to implement the same interface
20-
// to meet compilation requirements.
19+
// Cleanup is a no-op on Windows. It is here to implement the interface.
2120
func (r *remote) Cleanup() {
2221
}
2322

24-
// New creates a fresh instance of libcontainerd remote. This is largely
25-
// a no-op on Windows.
23+
// New creates a fresh instance of libcontainerd remote. On Windows,
24+
// this is not used as there is no remote containerd process.
2625
func New(_ string, _ ...RemoteOption) (Remote, error) {
2726
return &remote{}, nil
2827
}

libcontainerd/windowsoci/oci_windows.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package windowsoci
22

3-
// This file is a hack - essentially a mirror of OCI spec for Windows.
3+
// This file contains the Windows spec for a container. At the time of
4+
// writing, Windows does not have a spec defined in opencontainers/specs,
5+
// hence this is an interim workaround. TODO Windows: FIXME @jhowardmsft
46

57
import (
68
"fmt"

0 commit comments

Comments
 (0)