client_windows.go 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633
  1. package libcontainerd
  2. import (
  3. "errors"
  4. "fmt"
  5. "io"
  6. "io/ioutil"
  7. "os"
  8. "path/filepath"
  9. "strings"
  10. "syscall"
  11. "golang.org/x/net/context"
  12. "github.com/Microsoft/hcsshim"
  13. "github.com/Sirupsen/logrus"
  14. "github.com/docker/docker/pkg/sysinfo"
  15. specs "github.com/opencontainers/runtime-spec/specs-go"
  16. )
  17. type client struct {
  18. clientCommon
  19. // Platform specific properties below here (none presently on Windows)
  20. }
  21. // Win32 error codes that are used for various workarounds
  22. // These really should be ALL_CAPS to match golangs syscall library and standard
  23. // Win32 error conventions, but golint insists on CamelCase.
  24. const (
  25. CoEClassstring = syscall.Errno(0x800401F3) // Invalid class string
  26. ErrorNoNetwork = syscall.Errno(1222) // The network is not present or not started
  27. ErrorBadPathname = syscall.Errno(161) // The specified path is invalid
  28. ErrorInvalidObject = syscall.Errno(0x800710D8) // The object identifier does not represent a valid object
  29. )
  30. // defaultOwner is a tag passed to HCS to allow it to differentiate between
  31. // container creator management stacks. We hard code "docker" in the case
  32. // of docker.
  33. const defaultOwner = "docker"
  34. // Create is the entrypoint to create a container from a spec, and if successfully
  35. // created, start it too. Table below shows the fields required for HCS JSON calling parameters,
  36. // where if not populated, is omitted.
  37. // +-----------------+--------------------------------------------+---------------------------------------------------+
  38. // | | Isolation=Process | Isolation=Hyper-V |
  39. // +-----------------+--------------------------------------------+---------------------------------------------------+
  40. // | VolumePath | \\?\\Volume{GUIDa} | |
  41. // | LayerFolderPath | %root%\windowsfilter\containerID | %root%\windowsfilter\containerID (servicing only) |
  42. // | Layers[] | ID=GUIDb;Path=%root%\windowsfilter\layerID | ID=GUIDb;Path=%root%\windowsfilter\layerID |
  43. // | SandboxPath | | %root%\windowsfilter |
  44. // | HvRuntime | | ImagePath=%root%\BaseLayerID\UtilityVM |
  45. // +-----------------+--------------------------------------------+---------------------------------------------------+
  46. //
  47. // Isolation=Process example:
  48. //
  49. // {
  50. // "SystemType": "Container",
  51. // "Name": "5e0055c814a6005b8e57ac59f9a522066e0af12b48b3c26a9416e23907698776",
  52. // "Owner": "docker",
  53. // "IsDummy": false,
  54. // "VolumePath": "\\\\\\\\?\\\\Volume{66d1ef4c-7a00-11e6-8948-00155ddbef9d}",
  55. // "IgnoreFlushesDuringBoot": true,
  56. // "LayerFolderPath": "C:\\\\control\\\\windowsfilter\\\\5e0055c814a6005b8e57ac59f9a522066e0af12b48b3c26a9416e23907698776",
  57. // "Layers": [{
  58. // "ID": "18955d65-d45a-557b-bf1c-49d6dfefc526",
  59. // "Path": "C:\\\\control\\\\windowsfilter\\\\65bf96e5760a09edf1790cb229e2dfb2dbd0fcdc0bf7451bae099106bfbfea0c"
  60. // }],
  61. // "HostName": "5e0055c814a6",
  62. // "MappedDirectories": [],
  63. // "HvPartition": false,
  64. // "EndpointList": ["eef2649d-bb17-4d53-9937-295a8efe6f2c"],
  65. // "Servicing": false
  66. //}
  67. //
  68. // Isolation=Hyper-V example:
  69. //
  70. //{
  71. // "SystemType": "Container",
  72. // "Name": "475c2c58933b72687a88a441e7e0ca4bd72d76413c5f9d5031fee83b98f6045d",
  73. // "Owner": "docker",
  74. // "IsDummy": false,
  75. // "IgnoreFlushesDuringBoot": true,
  76. // "Layers": [{
  77. // "ID": "18955d65-d45a-557b-bf1c-49d6dfefc526",
  78. // "Path": "C:\\\\control\\\\windowsfilter\\\\65bf96e5760a09edf1790cb229e2dfb2dbd0fcdc0bf7451bae099106bfbfea0c"
  79. // }],
  80. // "HostName": "475c2c58933b",
  81. // "MappedDirectories": [],
  82. // "SandboxPath": "C:\\\\control\\\\windowsfilter",
  83. // "HvPartition": true,
  84. // "EndpointList": ["e1bb1e61-d56f-405e-b75d-fd520cefa0cb"],
  85. // "HvRuntime": {
  86. // "ImagePath": "C:\\\\control\\\\windowsfilter\\\\65bf96e5760a09edf1790cb229e2dfb2dbd0fcdc0bf7451bae099106bfbfea0c\\\\UtilityVM"
  87. // },
  88. // "Servicing": false
  89. //}
  90. func (clnt *client) Create(containerID string, checkpoint string, checkpointDir string, spec specs.Spec, attachStdio StdioCallback, options ...CreateOption) error {
  91. clnt.lock(containerID)
  92. defer clnt.unlock(containerID)
  93. logrus.Debugln("libcontainerd: client.Create() with spec", spec)
  94. configuration := &hcsshim.ContainerConfig{
  95. SystemType: "Container",
  96. Name: containerID,
  97. Owner: defaultOwner,
  98. IgnoreFlushesDuringBoot: false,
  99. HostName: spec.Hostname,
  100. HvPartition: false,
  101. }
  102. if spec.Windows.Resources != nil {
  103. if spec.Windows.Resources.CPU != nil {
  104. if spec.Windows.Resources.CPU.Count != nil {
  105. // This check is being done here rather than in adaptContainerSettings
  106. // because we don't want to update the HostConfig in case this container
  107. // is moved to a host with more CPUs than this one.
  108. cpuCount := *spec.Windows.Resources.CPU.Count
  109. hostCPUCount := uint64(sysinfo.NumCPU())
  110. if cpuCount > hostCPUCount {
  111. logrus.Warnf("Changing requested CPUCount of %d to current number of processors, %d", cpuCount, hostCPUCount)
  112. cpuCount = hostCPUCount
  113. }
  114. configuration.ProcessorCount = uint32(cpuCount)
  115. }
  116. if spec.Windows.Resources.CPU.Shares != nil {
  117. configuration.ProcessorWeight = uint64(*spec.Windows.Resources.CPU.Shares)
  118. }
  119. if spec.Windows.Resources.CPU.Percent != nil {
  120. configuration.ProcessorMaximum = int64(*spec.Windows.Resources.CPU.Percent) * 100 // ProcessorMaximum is a value between 1 and 10000
  121. }
  122. }
  123. if spec.Windows.Resources.Memory != nil {
  124. if spec.Windows.Resources.Memory.Limit != nil {
  125. configuration.MemoryMaximumInMB = int64(*spec.Windows.Resources.Memory.Limit) / 1024 / 1024
  126. }
  127. }
  128. if spec.Windows.Resources.Storage != nil {
  129. if spec.Windows.Resources.Storage.Bps != nil {
  130. configuration.StorageBandwidthMaximum = *spec.Windows.Resources.Storage.Bps
  131. }
  132. if spec.Windows.Resources.Storage.Iops != nil {
  133. configuration.StorageIOPSMaximum = *spec.Windows.Resources.Storage.Iops
  134. }
  135. }
  136. }
  137. var layerOpt *LayerOption
  138. for _, option := range options {
  139. if s, ok := option.(*ServicingOption); ok {
  140. configuration.Servicing = s.IsServicing
  141. continue
  142. }
  143. if f, ok := option.(*FlushOption); ok {
  144. configuration.IgnoreFlushesDuringBoot = f.IgnoreFlushesDuringBoot
  145. continue
  146. }
  147. if h, ok := option.(*HyperVIsolationOption); ok {
  148. configuration.HvPartition = h.IsHyperV
  149. configuration.SandboxPath = h.SandboxPath
  150. continue
  151. }
  152. if l, ok := option.(*LayerOption); ok {
  153. layerOpt = l
  154. }
  155. if n, ok := option.(*NetworkEndpointsOption); ok {
  156. configuration.EndpointList = n.Endpoints
  157. configuration.AllowUnqualifiedDNSQuery = n.AllowUnqualifiedDNSQuery
  158. continue
  159. }
  160. if c, ok := option.(*CredentialsOption); ok {
  161. configuration.Credentials = c.Credentials
  162. continue
  163. }
  164. }
  165. // We must have a layer option with at least one path
  166. if layerOpt == nil || layerOpt.LayerPaths == nil {
  167. return fmt.Errorf("no layer option or paths were supplied to the runtime")
  168. }
  169. if configuration.HvPartition {
  170. // Find the upper-most utility VM image, since the utility VM does not
  171. // use layering in RS1.
  172. // TODO @swernli/jhowardmsft at some point post RS1 this may be re-locatable.
  173. var uvmImagePath string
  174. for _, path := range layerOpt.LayerPaths {
  175. fullPath := filepath.Join(path, "UtilityVM")
  176. _, err := os.Stat(fullPath)
  177. if err == nil {
  178. uvmImagePath = fullPath
  179. break
  180. }
  181. if !os.IsNotExist(err) {
  182. return err
  183. }
  184. }
  185. if uvmImagePath == "" {
  186. return errors.New("utility VM image could not be found")
  187. }
  188. configuration.HvRuntime = &hcsshim.HvRuntime{ImagePath: uvmImagePath}
  189. } else {
  190. configuration.VolumePath = spec.Root.Path
  191. }
  192. configuration.LayerFolderPath = layerOpt.LayerFolderPath
  193. for _, layerPath := range layerOpt.LayerPaths {
  194. _, filename := filepath.Split(layerPath)
  195. g, err := hcsshim.NameToGuid(filename)
  196. if err != nil {
  197. return err
  198. }
  199. configuration.Layers = append(configuration.Layers, hcsshim.Layer{
  200. ID: g.ToString(),
  201. Path: layerPath,
  202. })
  203. }
  204. // Add the mounts (volumes, bind mounts etc) to the structure
  205. mds := make([]hcsshim.MappedDir, len(spec.Mounts))
  206. for i, mount := range spec.Mounts {
  207. mds[i] = hcsshim.MappedDir{
  208. HostPath: mount.Source,
  209. ContainerPath: mount.Destination,
  210. ReadOnly: false,
  211. }
  212. for _, o := range mount.Options {
  213. if strings.ToLower(o) == "ro" {
  214. mds[i].ReadOnly = true
  215. }
  216. }
  217. }
  218. configuration.MappedDirectories = mds
  219. hcsContainer, err := hcsshim.CreateContainer(containerID, configuration)
  220. if err != nil {
  221. return err
  222. }
  223. // Construct a container object for calling start on it.
  224. container := &container{
  225. containerCommon: containerCommon{
  226. process: process{
  227. processCommon: processCommon{
  228. containerID: containerID,
  229. client: clnt,
  230. friendlyName: InitFriendlyName,
  231. },
  232. commandLine: strings.Join(spec.Process.Args, " "),
  233. },
  234. processes: make(map[string]*process),
  235. },
  236. ociSpec: spec,
  237. hcsContainer: hcsContainer,
  238. }
  239. container.options = options
  240. for _, option := range options {
  241. if err := option.Apply(container); err != nil {
  242. logrus.Errorf("libcontainerd: %v", err)
  243. }
  244. }
  245. // Call start, and if it fails, delete the container from our
  246. // internal structure, start will keep HCS in sync by deleting the
  247. // container there.
  248. logrus.Debugf("libcontainerd: Create() id=%s, Calling start()", containerID)
  249. if err := container.start(attachStdio); err != nil {
  250. clnt.deleteContainer(containerID)
  251. return err
  252. }
  253. logrus.Debugf("libcontainerd: Create() id=%s completed successfully", containerID)
  254. return nil
  255. }
  256. // AddProcess is the handler for adding a process to an already running
  257. // container. It's called through docker exec. It returns the system pid of the
  258. // exec'd process.
  259. func (clnt *client) AddProcess(ctx context.Context, containerID, processFriendlyName string, procToAdd Process, attachStdio StdioCallback) (int, error) {
  260. clnt.lock(containerID)
  261. defer clnt.unlock(containerID)
  262. container, err := clnt.getContainer(containerID)
  263. if err != nil {
  264. return -1, err
  265. }
  266. // Note we always tell HCS to
  267. // create stdout as it's required regardless of '-i' or '-t' options, so that
  268. // docker can always grab the output through logs. We also tell HCS to always
  269. // create stdin, even if it's not used - it will be closed shortly. Stderr
  270. // is only created if it we're not -t.
  271. createProcessParms := hcsshim.ProcessConfig{
  272. EmulateConsole: procToAdd.Terminal,
  273. CreateStdInPipe: true,
  274. CreateStdOutPipe: true,
  275. CreateStdErrPipe: !procToAdd.Terminal,
  276. }
  277. createProcessParms.ConsoleSize[0] = uint(procToAdd.ConsoleSize.Height)
  278. createProcessParms.ConsoleSize[1] = uint(procToAdd.ConsoleSize.Width)
  279. // Take working directory from the process to add if it is defined,
  280. // otherwise take from the first process.
  281. if procToAdd.Cwd != "" {
  282. createProcessParms.WorkingDirectory = procToAdd.Cwd
  283. } else {
  284. createProcessParms.WorkingDirectory = container.ociSpec.Process.Cwd
  285. }
  286. // Configure the environment for the process
  287. createProcessParms.Environment = setupEnvironmentVariables(procToAdd.Env)
  288. createProcessParms.CommandLine = strings.Join(procToAdd.Args, " ")
  289. createProcessParms.User = procToAdd.User.Username
  290. logrus.Debugf("libcontainerd: commandLine: %s", createProcessParms.CommandLine)
  291. // Start the command running in the container.
  292. var stdout, stderr io.ReadCloser
  293. var stdin io.WriteCloser
  294. newProcess, err := container.hcsContainer.CreateProcess(&createProcessParms)
  295. if err != nil {
  296. logrus.Errorf("libcontainerd: AddProcess(%s) CreateProcess() failed %s", containerID, err)
  297. return -1, err
  298. }
  299. pid := newProcess.Pid()
  300. stdin, stdout, stderr, err = newProcess.Stdio()
  301. if err != nil {
  302. logrus.Errorf("libcontainerd: %s getting std pipes failed %s", containerID, err)
  303. return -1, err
  304. }
  305. iopipe := &IOPipe{Terminal: procToAdd.Terminal}
  306. iopipe.Stdin = createStdInCloser(stdin, newProcess)
  307. // Convert io.ReadClosers to io.Readers
  308. if stdout != nil {
  309. iopipe.Stdout = ioutil.NopCloser(&autoClosingReader{ReadCloser: stdout})
  310. }
  311. if stderr != nil {
  312. iopipe.Stderr = ioutil.NopCloser(&autoClosingReader{ReadCloser: stderr})
  313. }
  314. proc := &process{
  315. processCommon: processCommon{
  316. containerID: containerID,
  317. friendlyName: processFriendlyName,
  318. client: clnt,
  319. systemPid: uint32(pid),
  320. },
  321. commandLine: createProcessParms.CommandLine,
  322. hcsProcess: newProcess,
  323. }
  324. // Add the process to the container's list of processes
  325. container.processes[processFriendlyName] = proc
  326. // Tell the engine to attach streams back to the client
  327. if err := attachStdio(*iopipe); err != nil {
  328. return -1, err
  329. }
  330. // Spin up a go routine waiting for exit to handle cleanup
  331. go container.waitExit(proc, false)
  332. return pid, nil
  333. }
  334. // Signal handles `docker stop` on Windows. While Linux has support for
  335. // the full range of signals, signals aren't really implemented on Windows.
  336. // We fake supporting regular stop and -9 to force kill.
  337. func (clnt *client) Signal(containerID string, sig int) error {
  338. var (
  339. cont *container
  340. err error
  341. )
  342. // Get the container as we need it to get the container handle.
  343. clnt.lock(containerID)
  344. defer clnt.unlock(containerID)
  345. if cont, err = clnt.getContainer(containerID); err != nil {
  346. return err
  347. }
  348. cont.manualStopRequested = true
  349. logrus.Debugf("libcontainerd: Signal() containerID=%s sig=%d pid=%d", containerID, sig, cont.systemPid)
  350. if syscall.Signal(sig) == syscall.SIGKILL {
  351. // Terminate the compute system
  352. if err := cont.hcsContainer.Terminate(); err != nil {
  353. if !hcsshim.IsPending(err) {
  354. logrus.Errorf("libcontainerd: failed to terminate %s - %q", containerID, err)
  355. }
  356. }
  357. } else {
  358. // Shut down the container
  359. if err := cont.hcsContainer.Shutdown(); err != nil {
  360. if !hcsshim.IsPending(err) && !hcsshim.IsAlreadyStopped(err) {
  361. // ignore errors
  362. logrus.Warnf("libcontainerd: failed to shutdown container %s: %q", containerID, err)
  363. }
  364. }
  365. }
  366. return nil
  367. }
  368. // While Linux has support for the full range of signals, signals aren't really implemented on Windows.
  369. // We try to terminate the specified process whatever signal is requested.
  370. func (clnt *client) SignalProcess(containerID string, processFriendlyName string, sig int) error {
  371. clnt.lock(containerID)
  372. defer clnt.unlock(containerID)
  373. cont, err := clnt.getContainer(containerID)
  374. if err != nil {
  375. return err
  376. }
  377. for _, p := range cont.processes {
  378. if p.friendlyName == processFriendlyName {
  379. return p.hcsProcess.Kill()
  380. }
  381. }
  382. return fmt.Errorf("SignalProcess could not find process %s in %s", processFriendlyName, containerID)
  383. }
  384. // Resize handles a CLI event to resize an interactive docker run or docker exec
  385. // window.
  386. func (clnt *client) Resize(containerID, processFriendlyName string, width, height int) error {
  387. // Get the libcontainerd container object
  388. clnt.lock(containerID)
  389. defer clnt.unlock(containerID)
  390. cont, err := clnt.getContainer(containerID)
  391. if err != nil {
  392. return err
  393. }
  394. h, w := uint16(height), uint16(width)
  395. if processFriendlyName == InitFriendlyName {
  396. logrus.Debugln("libcontainerd: resizing systemPID in", containerID, cont.process.systemPid)
  397. return cont.process.hcsProcess.ResizeConsole(w, h)
  398. }
  399. for _, p := range cont.processes {
  400. if p.friendlyName == processFriendlyName {
  401. logrus.Debugln("libcontainerd: resizing exec'd process", containerID, p.systemPid)
  402. return p.hcsProcess.ResizeConsole(w, h)
  403. }
  404. }
  405. return fmt.Errorf("Resize could not find containerID %s to resize", containerID)
  406. }
  407. // Pause handles pause requests for containers
  408. func (clnt *client) Pause(containerID string) error {
  409. unlockContainer := true
  410. // Get the libcontainerd container object
  411. clnt.lock(containerID)
  412. defer func() {
  413. if unlockContainer {
  414. clnt.unlock(containerID)
  415. }
  416. }()
  417. container, err := clnt.getContainer(containerID)
  418. if err != nil {
  419. return err
  420. }
  421. for _, option := range container.options {
  422. if h, ok := option.(*HyperVIsolationOption); ok {
  423. if !h.IsHyperV {
  424. return errors.New("cannot pause Windows Server Containers")
  425. }
  426. break
  427. }
  428. }
  429. err = container.hcsContainer.Pause()
  430. if err != nil {
  431. return err
  432. }
  433. // Unlock container before calling back into the daemon
  434. unlockContainer = false
  435. clnt.unlock(containerID)
  436. return clnt.backend.StateChanged(containerID, StateInfo{
  437. CommonStateInfo: CommonStateInfo{
  438. State: StatePause,
  439. }})
  440. }
  441. // Resume handles resume requests for containers
  442. func (clnt *client) Resume(containerID string) error {
  443. unlockContainer := true
  444. // Get the libcontainerd container object
  445. clnt.lock(containerID)
  446. defer func() {
  447. if unlockContainer {
  448. clnt.unlock(containerID)
  449. }
  450. }()
  451. container, err := clnt.getContainer(containerID)
  452. if err != nil {
  453. return err
  454. }
  455. // This should never happen, since Windows Server Containers cannot be paused
  456. for _, option := range container.options {
  457. if h, ok := option.(*HyperVIsolationOption); ok {
  458. if !h.IsHyperV {
  459. return errors.New("cannot resume Windows Server Containers")
  460. }
  461. break
  462. }
  463. }
  464. err = container.hcsContainer.Resume()
  465. if err != nil {
  466. return err
  467. }
  468. // Unlock container before calling back into the daemon
  469. unlockContainer = false
  470. clnt.unlock(containerID)
  471. return clnt.backend.StateChanged(containerID, StateInfo{
  472. CommonStateInfo: CommonStateInfo{
  473. State: StateResume,
  474. }})
  475. }
  476. // Stats handles stats requests for containers
  477. func (clnt *client) Stats(containerID string) (*Stats, error) {
  478. // Get the libcontainerd container object
  479. clnt.lock(containerID)
  480. defer clnt.unlock(containerID)
  481. container, err := clnt.getContainer(containerID)
  482. if err != nil {
  483. return nil, err
  484. }
  485. s, err := container.hcsContainer.Statistics()
  486. if err != nil {
  487. return nil, err
  488. }
  489. st := Stats(s)
  490. return &st, nil
  491. }
  492. // Restore is the handler for restoring a container
  493. func (clnt *client) Restore(containerID string, _ StdioCallback, unusedOnWindows ...CreateOption) error {
  494. // TODO Windows: Implement this. For now, just tell the backend the container exited.
  495. logrus.Debugf("libcontainerd: Restore(%s)", containerID)
  496. return clnt.backend.StateChanged(containerID, StateInfo{
  497. CommonStateInfo: CommonStateInfo{
  498. State: StateExit,
  499. ExitCode: 1 << 31,
  500. }})
  501. }
  502. // GetPidsForContainer returns a list of process IDs running in a container.
  503. // Although implemented, this is not used in Windows.
  504. func (clnt *client) GetPidsForContainer(containerID string) ([]int, error) {
  505. var pids []int
  506. clnt.lock(containerID)
  507. defer clnt.unlock(containerID)
  508. cont, err := clnt.getContainer(containerID)
  509. if err != nil {
  510. return nil, err
  511. }
  512. // Add the first process
  513. pids = append(pids, int(cont.containerCommon.systemPid))
  514. // And add all the exec'd processes
  515. for _, p := range cont.processes {
  516. pids = append(pids, int(p.processCommon.systemPid))
  517. }
  518. return pids, nil
  519. }
  520. // Summary returns a summary of the processes running in a container.
  521. // This is present in Windows to support docker top. In linux, the
  522. // engine shells out to ps to get process information. On Windows, as
  523. // the containers could be Hyper-V containers, they would not be
  524. // visible on the container host. However, libcontainerd does have
  525. // that information.
  526. func (clnt *client) Summary(containerID string) ([]Summary, error) {
  527. // Get the libcontainerd container object
  528. clnt.lock(containerID)
  529. defer clnt.unlock(containerID)
  530. container, err := clnt.getContainer(containerID)
  531. if err != nil {
  532. return nil, err
  533. }
  534. p, err := container.hcsContainer.ProcessList()
  535. if err != nil {
  536. return nil, err
  537. }
  538. pl := make([]Summary, len(p))
  539. for i := range p {
  540. pl[i] = Summary(p[i])
  541. }
  542. return pl, nil
  543. }
  544. // UpdateResources updates resources for a running container.
  545. func (clnt *client) UpdateResources(containerID string, resources Resources) error {
  546. // Updating resource isn't supported on Windows
  547. // but we should return nil for enabling updating container
  548. return nil
  549. }
  550. func (clnt *client) CreateCheckpoint(containerID string, checkpointID string, checkpointDir string, exit bool) error {
  551. return errors.New("Windows: Containers do not support checkpoints")
  552. }
  553. func (clnt *client) DeleteCheckpoint(containerID string, checkpointID string, checkpointDir string) error {
  554. return errors.New("Windows: Containers do not support checkpoints")
  555. }
  556. func (clnt *client) ListCheckpoints(containerID string, checkpointDir string) (*Checkpoints, error) {
  557. return nil, errors.New("Windows: Containers do not support checkpoints")
  558. }
  559. func (clnt *client) GetServerVersion(ctx context.Context) (*ServerVersion, error) {
  560. return &ServerVersion{}, nil
  561. }