Browse code

Windows: libcontainerd cleanup

Signed-off-by: John Howard <jhoward@microsoft.com>

John Howard authored on 2016/03/19 12:29:27
Showing 4 changed files
... ...
@@ -58,8 +58,7 @@ type natSettings struct {
58 58
 
59 59
 type networkConnection struct {
60 60
 	NetworkName string
61
-	//EnableNat bool
62
-	Nat natSettings
61
+	Nat         natSettings
63 62
 }
64 63
 type networkSettings struct {
65 64
 	MacAddress string
... ...
@@ -77,7 +76,7 @@ type mappedDir struct {
77 77
 	ReadOnly      bool
78 78
 }
79 79
 
80
-// TODO Windows RTM: @darrenstahlmsft Add ProcessorCount
80
+// TODO Windows: @darrenstahlmsft Add ProcessorCount
81 81
 type containerInit struct {
82 82
 	SystemType              string      // HCS requires this to be hard-coded to "Container"
83 83
 	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
153 153
 		}
154 154
 	}
155 155
 
156
-	// TODO Ultimately need to set the path from HvRuntime.ImagePath
157 156
 	cu.HvPartition = (spec.Windows.HvRuntime != nil)
157
+
158
+	// TODO Windows @jhowardmsft. FIXME post TP5.
158 159
 	//	if spec.Windows.HvRuntime != nil {
159
-	//		cu.HvPartition = len(spec.Windows.HvRuntime.ImagePath) > 0
160
+	//		if spec.WIndows.HVRuntime.ImagePath != "" {
161
+	//			cu.TBD = spec.Windows.HvRuntime.ImagePath
162
+	//		}
160 163
 	//	}
161 164
 
162 165
 	if cu.HvPartition {
... ...
@@ -498,73 +500,12 @@ func (clnt *client) Stats(containerID string) (*Stats, error) {
498 498
 
499 499
 // Restore is the handler for restoring a container
500 500
 func (clnt *client) Restore(containerID string, unusedOnWindows ...CreateOption) error {
501
-
501
+	// TODO Windows: Implement this. For now, just tell the backend the container exited.
502 502
 	logrus.Debugf("lcd Restore %s", containerID)
503 503
 	return clnt.backend.StateChanged(containerID, StateInfo{
504 504
 		State:    StateExit,
505 505
 		ExitCode: 1 << 31,
506 506
 	})
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
568 507
 }
569 508
 
570 509
 // GetPidsForContainers is not implemented on Windows.
... ...
@@ -572,6 +513,7 @@ func (clnt *client) GetPidsForContainer(containerID string) ([]int, error) {
572 572
 	return nil, errors.New("GetPidsForContainer: GetPidsForContainer() not implemented")
573 573
 }
574 574
 
575
+// UpdateResources updates resources for a running container.
575 576
 func (clnt *client) UpdateResources(containerID string, resources Resources) error {
576 577
 	// Updating resource isn't supported on Windows
577 578
 	// but we should return nil for enabling updating container
... ...
@@ -5,10 +5,10 @@ import (
5 5
 )
6 6
 
7 7
 // process keeps the state for both main container process and exec process.
8
-
9
-// process keeps the state for both main container process and exec process.
10 8
 type process struct {
11 9
 	processCommon
10
+
11
+	// Platform specific fields are below here. There are none presently on Windows.
12 12
 }
13 13
 
14 14
 func openReaderFromPipe(p io.ReadCloser) io.Reader {
... ...
@@ -16,13 +16,12 @@ func (r *remote) Client(b Backend) (Client, error) {
16 16
 	return c, nil
17 17
 }
18 18
 
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.
21 20
 func (r *remote) Cleanup() {
22 21
 }
23 22
 
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.
26 25
 func New(_ string, _ ...RemoteOption) (Remote, error) {
27 26
 	return &remote{}, nil
28 27
 }
... ...
@@ -1,6 +1,8 @@
1 1
 package windowsoci
2 2
 
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
4 6
 
5 7
 import (
6 8
 	"fmt"