@@ -17,7 +17,6 @@ import (
17
17
18
18
"github.com/Sirupsen/logrus"
19
19
"github.com/docker/docker/daemon/exec"
20
- "github.com/docker/docker/daemon/execdriver"
21
20
"github.com/docker/docker/daemon/logger"
22
21
"github.com/docker/docker/daemon/logger/jsonfilelog"
23
22
"github.com/docker/docker/daemon/network"
@@ -27,6 +26,7 @@ import (
27
26
"github.com/docker/docker/pkg/promise"
28
27
"github.com/docker/docker/pkg/signal"
29
28
"github.com/docker/docker/pkg/symlink"
29
+ "github.com/docker/docker/restartmanager"
30
30
"github.com/docker/docker/runconfig"
31
31
runconfigopts "github.com/docker/docker/runconfig/opts"
32
32
"github.com/docker/docker/volume"
@@ -74,13 +74,12 @@ type CommonContainer struct {
74
74
HasBeenManuallyStopped bool // used for unless-stopped restart policy
75
75
MountPoints map [string ]* volume.MountPoint
76
76
HostConfig * containertypes.HostConfig `json:"-"` // do not serialize the host config in the json, otherwise we'll make the container unportable
77
- Command * execdriver.Command `json:"-"`
78
- monitor * containerMonitor
79
- ExecCommands * exec.Store `json:"-"`
77
+ ExecCommands * exec.Store `json:"-"`
80
78
// logDriver for closing
81
- LogDriver logger.Logger `json:"-"`
82
- LogCopier * logger.Copier `json:"-"`
83
- attachContext * attachContext
79
+ LogDriver logger.Logger `json:"-"`
80
+ LogCopier * logger.Copier `json:"-"`
81
+ restartManager restartmanager.RestartManager
82
+ attachContext * attachContext
84
83
}
85
84
86
85
// NewBaseContainer creates a new container with its
@@ -276,19 +275,9 @@ func (container *Container) GetRootResourcePath(path string) (string, error) {
276
275
// ExitOnNext signals to the monitor that it should not restart the container
277
276
// after we send the kill signal.
278
277
func (container * Container ) ExitOnNext () {
279
- container .monitor .ExitOnNext ()
280
- }
281
-
282
- // Resize changes the TTY of the process running inside the container
283
- // to the given height and width. The container must be running.
284
- func (container * Container ) Resize (h , w int ) error {
285
- if container .Command .ProcessConfig .Terminal == nil {
286
- return fmt .Errorf ("Container %s does not have a terminal ready" , container .ID )
287
- }
288
- if err := container .Command .ProcessConfig .Terminal .Resize (h , w ); err != nil {
289
- return err
278
+ if container .restartManager != nil {
279
+ container .restartManager .Cancel ()
290
280
}
291
- return nil
292
281
}
293
282
294
283
// HostConfigPath returns the path to the container's JSON hostconfig
@@ -897,19 +886,33 @@ func (container *Container) BuildCreateEndpointOptions(n libnetwork.Network, epC
897
886
898
887
// UpdateMonitor updates monitor configure for running container
899
888
func (container * Container ) UpdateMonitor (restartPolicy containertypes.RestartPolicy ) {
900
- monitor := container .monitor
901
- // No need to update monitor if container hasn't got one
902
- // monitor will be generated correctly according to container
903
- if monitor == nil {
904
- return
889
+ type policySetter interface {
890
+ SetPolicy (containertypes.RestartPolicy )
891
+ }
892
+
893
+ if rm , ok := container .RestartManager (false ).(policySetter ); ok {
894
+ rm .SetPolicy (restartPolicy )
895
+ }
896
+ }
897
+
898
+ // FullHostname returns hostname and optional domain appended to it.
899
+ func (container * Container ) FullHostname () string {
900
+ fullHostname := container .Config .Hostname
901
+ if container .Config .Domainname != "" {
902
+ fullHostname = fmt .Sprintf ("%s.%s" , fullHostname , container .Config .Domainname )
905
903
}
904
+ return fullHostname
905
+ }
906
906
907
- monitor .mux .Lock ()
908
- // to check whether restart policy has changed.
909
- if restartPolicy .Name != "" && ! monitor .restartPolicy .IsSame (& restartPolicy ) {
910
- monitor .restartPolicy = restartPolicy
907
+ // RestartManager returns the current restartmanager instace connected to container.
908
+ func (container * Container ) RestartManager (reset bool ) restartmanager.RestartManager {
909
+ if reset {
910
+ container .RestartCount = 0
911
+ }
912
+ if container .restartManager == nil {
913
+ container .restartManager = restartmanager .New (container .HostConfig .RestartPolicy )
911
914
}
912
- monitor . mux . Unlock ()
915
+ return container . restartManager
913
916
}
914
917
915
918
type attachContext struct {
0 commit comments