Signed-off-by: David Calavera <david.calavera@gmail.com>
David Calavera authored on 2016/02/11 05:16:59... | ... |
@@ -5,7 +5,6 @@ import ( |
5 | 5 |
"time" |
6 | 6 |
|
7 | 7 |
"github.com/docker/docker/api/types/backend" |
8 |
- "github.com/docker/docker/daemon/exec" |
|
9 | 8 |
"github.com/docker/docker/pkg/archive" |
10 | 9 |
"github.com/docker/docker/pkg/version" |
11 | 10 |
"github.com/docker/engine-api/types" |
... | ... |
@@ -15,7 +14,7 @@ import ( |
15 | 15 |
// execBackend includes functions to implement to provide exec functionality. |
16 | 16 |
type execBackend interface { |
17 | 17 |
ContainerExecCreate(config *types.ExecConfig) (string, error) |
18 |
- ContainerExecInspect(id string) (*exec.Config, error) |
|
18 |
+ ContainerExecInspect(id string) (*backend.ExecInspect, error) |
|
19 | 19 |
ContainerExecResize(name string, height, width int) error |
20 | 20 |
ContainerExecStart(name string, stdin io.ReadCloser, stdout io.Writer, stderr io.Writer) error |
21 | 21 |
ExecExists(name string) (bool, error) |
... | ... |
@@ -9,14 +9,6 @@ import ( |
9 | 9 |
"github.com/Sirupsen/logrus" |
10 | 10 |
"github.com/docker/docker/api/server/httputils" |
11 | 11 |
"github.com/docker/docker/api/server/router" |
12 |
- "github.com/docker/docker/api/server/router/build" |
|
13 |
- "github.com/docker/docker/api/server/router/container" |
|
14 |
- "github.com/docker/docker/api/server/router/image" |
|
15 |
- "github.com/docker/docker/api/server/router/network" |
|
16 |
- "github.com/docker/docker/api/server/router/system" |
|
17 |
- "github.com/docker/docker/api/server/router/volume" |
|
18 |
- "github.com/docker/docker/builder/dockerfile" |
|
19 |
- "github.com/docker/docker/daemon" |
|
20 | 12 |
"github.com/docker/docker/pkg/authorization" |
21 | 13 |
"github.com/docker/docker/utils" |
22 | 14 |
"github.com/docker/go-connections/sockets" |
... | ... |
@@ -174,14 +166,11 @@ func (s *Server) makeHTTPHandler(handler httputils.APIFunc) http.HandlerFunc { |
174 | 174 |
} |
175 | 175 |
} |
176 | 176 |
|
177 |
-// InitRouters initializes a list of routers for the server. |
|
178 |
-func (s *Server) InitRouters(d *daemon.Daemon) { |
|
179 |
- s.addRouter(container.NewRouter(d)) |
|
180 |
- s.addRouter(image.NewRouter(d)) |
|
181 |
- s.addRouter(network.NewRouter(d)) |
|
182 |
- s.addRouter(system.NewRouter(d)) |
|
183 |
- s.addRouter(volume.NewRouter(d)) |
|
184 |
- s.addRouter(build.NewRouter(dockerfile.NewBuildManager(d))) |
|
177 |
+// AddRouters initializes a list of routers for the server. |
|
178 |
+func (s *Server) AddRouters(routers ...router.Router) { |
|
179 |
+ for _, r := range routers { |
|
180 |
+ s.addRouter(r) |
|
181 |
+ } |
|
185 | 182 |
} |
186 | 183 |
|
187 | 184 |
// addRouter adds a new router to the server. |
... | ... |
@@ -231,13 +220,13 @@ func (s *Server) initRouterSwapper() { |
231 | 231 |
// Reload reads configuration changes and modifies the |
232 | 232 |
// server according to those changes. |
233 | 233 |
// Currently, only the --debug configuration is taken into account. |
234 |
-func (s *Server) Reload(config *daemon.Config) { |
|
234 |
+func (s *Server) Reload(debug bool) { |
|
235 | 235 |
debugEnabled := utils.IsDebugEnabled() |
236 | 236 |
switch { |
237 |
- case debugEnabled && !config.Debug: // disable debug |
|
237 |
+ case debugEnabled && !debug: // disable debug |
|
238 | 238 |
utils.DisableDebug() |
239 | 239 |
s.routerSwapper.Swap(s.createMux()) |
240 |
- case config.Debug && !debugEnabled: // enable debug |
|
240 |
+ case debug && !debugEnabled: // enable debug |
|
241 | 241 |
utils.EnableDebug() |
242 | 242 |
s.routerSwapper.Swap(s.createMux()) |
243 | 243 |
} |
... | ... |
@@ -42,3 +42,28 @@ type ContainerStatsConfig struct { |
42 | 42 |
Stop <-chan bool |
43 | 43 |
Version string |
44 | 44 |
} |
45 |
+ |
|
46 |
+// ExecInspect holds information about a running process started |
|
47 |
+// with docker exec. |
|
48 |
+type ExecInspect struct { |
|
49 |
+ ID string |
|
50 |
+ Running bool |
|
51 |
+ ExitCode *int |
|
52 |
+ ProcessConfig *ExecProcessConfig |
|
53 |
+ OpenStdin bool |
|
54 |
+ OpenStderr bool |
|
55 |
+ OpenStdout bool |
|
56 |
+ CanRemove bool |
|
57 |
+ ContainerID string |
|
58 |
+ DetachKeys []byte |
|
59 |
+} |
|
60 |
+ |
|
61 |
+// ExecProcessConfig holds information about the exec process |
|
62 |
+// running on the host. |
|
63 |
+type ExecProcessConfig struct { |
|
64 |
+ Tty bool `json:"tty"` |
|
65 |
+ Entrypoint string `json:"entrypoint"` |
|
66 |
+ Arguments []string `json:"arguments"` |
|
67 |
+ Privileged *bool `json:"privileged,omitempty"` |
|
68 |
+ User string `json:"user,omitempty"` |
|
69 |
+} |
... | ... |
@@ -4,8 +4,8 @@ import ( |
4 | 4 |
"fmt" |
5 | 5 |
"time" |
6 | 6 |
|
7 |
+ "github.com/docker/docker/api/types/backend" |
|
7 | 8 |
"github.com/docker/docker/container" |
8 |
- "github.com/docker/docker/daemon/exec" |
|
9 | 9 |
"github.com/docker/docker/daemon/network" |
10 | 10 |
"github.com/docker/docker/pkg/version" |
11 | 11 |
"github.com/docker/engine-api/types" |
... | ... |
@@ -175,12 +175,26 @@ func (daemon *Daemon) getInspectData(container *container.Container, size bool) |
175 | 175 |
|
176 | 176 |
// ContainerExecInspect returns low-level information about the exec |
177 | 177 |
// command. An error is returned if the exec cannot be found. |
178 |
-func (daemon *Daemon) ContainerExecInspect(id string) (*exec.Config, error) { |
|
179 |
- eConfig, err := daemon.getExecConfig(id) |
|
178 |
+func (daemon *Daemon) ContainerExecInspect(id string) (*backend.ExecInspect, error) { |
|
179 |
+ e, err := daemon.getExecConfig(id) |
|
180 | 180 |
if err != nil { |
181 | 181 |
return nil, err |
182 | 182 |
} |
183 |
- return eConfig, nil |
|
183 |
+ |
|
184 |
+ pc := inspectExecProcessConfig(e) |
|
185 |
+ |
|
186 |
+ return &backend.ExecInspect{ |
|
187 |
+ ID: e.ID, |
|
188 |
+ Running: e.Running, |
|
189 |
+ ExitCode: e.ExitCode, |
|
190 |
+ ProcessConfig: pc, |
|
191 |
+ OpenStdin: e.OpenStdin, |
|
192 |
+ OpenStdout: e.OpenStdout, |
|
193 |
+ OpenStderr: e.OpenStderr, |
|
194 |
+ CanRemove: e.CanRemove, |
|
195 |
+ ContainerID: e.ContainerID, |
|
196 |
+ DetachKeys: e.DetachKeys, |
|
197 |
+ }, nil |
|
184 | 198 |
} |
185 | 199 |
|
186 | 200 |
// VolumeInspect looks up a volume by name. An error is returned if |
... | ... |
@@ -3,7 +3,9 @@ |
3 | 3 |
package daemon |
4 | 4 |
|
5 | 5 |
import ( |
6 |
+ "github.com/docker/docker/api/types/backend" |
|
6 | 7 |
"github.com/docker/docker/container" |
8 |
+ "github.com/docker/docker/daemon/exec" |
|
7 | 9 |
"github.com/docker/engine-api/types" |
8 | 10 |
"github.com/docker/engine-api/types/versions/v1p19" |
9 | 11 |
) |
... | ... |
@@ -77,3 +79,13 @@ func addMountPoints(container *container.Container) []types.MountPoint { |
77 | 77 |
} |
78 | 78 |
return mountPoints |
79 | 79 |
} |
80 |
+ |
|
81 |
+func inspectExecProcessConfig(e *exec.Config) *backend.ExecProcessConfig { |
|
82 |
+ return &backend.ExecProcessConfig{ |
|
83 |
+ Tty: e.ProcessConfig.Tty, |
|
84 |
+ Entrypoint: e.ProcessConfig.Entrypoint, |
|
85 |
+ Arguments: e.ProcessConfig.Arguments, |
|
86 |
+ Privileged: &e.ProcessConfig.Privileged, |
|
87 |
+ User: e.ProcessConfig.User, |
|
88 |
+ } |
|
89 |
+} |
... | ... |
@@ -1,7 +1,9 @@ |
1 | 1 |
package daemon |
2 | 2 |
|
3 | 3 |
import ( |
4 |
+ "github.com/docker/docker/api/types/backend" |
|
4 | 5 |
"github.com/docker/docker/container" |
6 |
+ "github.com/docker/docker/daemon/exec" |
|
5 | 7 |
"github.com/docker/engine-api/types" |
6 | 8 |
) |
7 | 9 |
|
... | ... |
@@ -28,3 +30,11 @@ func addMountPoints(container *container.Container) []types.MountPoint { |
28 | 28 |
func (daemon *Daemon) containerInspectPre120(name string) (*types.ContainerJSON, error) { |
29 | 29 |
return daemon.containerInspectCurrent(name, false) |
30 | 30 |
} |
31 |
+ |
|
32 |
+func inspectExecProcessConfig(e *exec.Config) *backend.ExecProcessConfig { |
|
33 |
+ return &backend.ExecProcessConfig{ |
|
34 |
+ Tty: e.ProcessConfig.Tty, |
|
35 |
+ Entrypoint: e.ProcessConfig.Entrypoint, |
|
36 |
+ Arguments: e.ProcessConfig.Arguments, |
|
37 |
+ } |
|
38 |
+} |
... | ... |
@@ -14,6 +14,13 @@ import ( |
14 | 14 |
"github.com/Sirupsen/logrus" |
15 | 15 |
"github.com/docker/distribution/uuid" |
16 | 16 |
apiserver "github.com/docker/docker/api/server" |
17 |
+ "github.com/docker/docker/api/server/router/build" |
|
18 |
+ "github.com/docker/docker/api/server/router/container" |
|
19 |
+ "github.com/docker/docker/api/server/router/image" |
|
20 |
+ "github.com/docker/docker/api/server/router/network" |
|
21 |
+ systemrouter "github.com/docker/docker/api/server/router/system" |
|
22 |
+ "github.com/docker/docker/api/server/router/volume" |
|
23 |
+ "github.com/docker/docker/builder/dockerfile" |
|
17 | 24 |
"github.com/docker/docker/cli" |
18 | 25 |
"github.com/docker/docker/cliconfig" |
19 | 26 |
"github.com/docker/docker/daemon" |
... | ... |
@@ -270,14 +277,14 @@ func (cli *DaemonCli) CmdDaemon(args ...string) error { |
270 | 270 |
"graphdriver": d.GraphDriverName(), |
271 | 271 |
}).Info("Docker daemon") |
272 | 272 |
|
273 |
- api.InitRouters(d) |
|
273 |
+ initRouters(api, d) |
|
274 | 274 |
|
275 | 275 |
reload := func(config *daemon.Config) { |
276 | 276 |
if err := d.Reload(config); err != nil { |
277 | 277 |
logrus.Errorf("Error reconfiguring the daemon: %v", err) |
278 | 278 |
return |
279 | 279 |
} |
280 |
- api.Reload(config) |
|
280 |
+ api.Reload(config.Debug) |
|
281 | 281 |
} |
282 | 282 |
|
283 | 283 |
setupConfigReloadTrap(*configFile, cli.flags, reload) |
... | ... |
@@ -373,3 +380,12 @@ func loadDaemonCliConfig(config *daemon.Config, daemonFlags *flag.FlagSet, commo |
373 | 373 |
|
374 | 374 |
return config, nil |
375 | 375 |
} |
376 |
+ |
|
377 |
+func initRouters(s *apiserver.Server, d *daemon.Daemon) { |
|
378 |
+ s.AddRouters(container.NewRouter(d), |
|
379 |
+ image.NewRouter(d), |
|
380 |
+ network.NewRouter(d), |
|
381 |
+ systemrouter.NewRouter(d), |
|
382 |
+ volume.NewRouter(d), |
|
383 |
+ build.NewRouter(dockerfile.NewBuildManager(d))) |
|
384 |
+} |