-
Notifications
You must be signed in to change notification settings - Fork 239
/
shutdownterminatecomputesystem.go
43 lines (35 loc) · 1.18 KB
/
shutdownterminatecomputesystem.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package hcsshim
import "github.com/Sirupsen/logrus"
// TerminateComputeSystem force terminates a container.
func TerminateComputeSystem(id string, timeout uint32, context string) error {
return shutdownTerminate(false, id, timeout, context)
}
// ShutdownComputeSystem shuts down a container by requesting a shutdown within
// the container operating system.
func ShutdownComputeSystem(id string, timeout uint32, context string) error {
return shutdownTerminate(true, id, timeout, context)
}
// shutdownTerminate is a wrapper for ShutdownComputeSystem and TerminateComputeSystem
// which have very similar calling semantics
func shutdownTerminate(shutdown bool, id string, timeout uint32, context string) error {
var (
title = "HCSShim::"
)
if shutdown {
title = title + "ShutdownComputeSystem"
} else {
title = title + "TerminateComputeSystem"
}
logrus.Debugf(title+" id=%s context=%s", id, context)
var err error
if shutdown {
err = shutdownComputeSystem(id, timeout)
} else {
err = terminateComputeSystem(id)
}
if err != nil {
return makeErrorf(err, title, "id=%s context=%s", id, context)
}
logrus.Debugf(title+" succeeded id=%s context=%s", id, context)
return nil
}