Skip to content

Commit 032fb6f

Browse files
committed
Added container-ip to process list
1 parent 9dad8e7 commit 032fb6f

File tree

4 files changed

+19
-0
lines changed

4 files changed

+19
-0
lines changed

service/runner.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ type Process interface {
2020
ProcessID() int
2121
// ContainerID returns the ID of the docker container that runs the process.
2222
ContainerID() string
23+
// ContainerIP returns the IP address of the docker container that runs the process.
24+
ContainerIP() string
2325

2426
// Wait until the process has terminated
2527
Wait()

service/runner_docker.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,14 @@ func (p *dockerContainer) ContainerID() string {
308308
return p.container.ID
309309
}
310310

311+
// ContainerIP returns the IP address of the docker container that runs the process.
312+
func (p *dockerContainer) ContainerIP() string {
313+
if ns := p.container.NetworkSettings; ns != nil {
314+
return ns.IPAddress
315+
}
316+
return ""
317+
}
318+
311319
func (p *dockerContainer) Wait() {
312320
p.client.WaitContainer(p.container.ID)
313321
}

service/runner_process.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ func (p *process) ContainerID() string {
6262
return ""
6363
}
6464

65+
// ContainerIP returns the IP address of the docker container that runs the process.
66+
func (p *process) ContainerIP() string {
67+
return ""
68+
}
69+
6570
func (p *process) Wait() {
6671
proc := p.cmd.Process
6772
if proc != nil {

service/server.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ type ServerProcess struct {
3737
Port int `json:"port"` // Port needed to reach the server
3838
ProcessID int `json:"pid,omitempty"` // PID of the process (0 when running in docker)
3939
ContainerID string `json:"container-id,omitempty"` // ID of docker container running the server
40+
ContainerIP string `json:"container-ip,omitempty"` // IP address of docker container running the server
4041
}
4142

4243
// startHTTPServer initializes and runs the HTTP server.
@@ -236,6 +237,7 @@ func (s *Service) processListHandler(w http.ResponseWriter, r *http.Request) {
236237
Port: s.MasterPort + portOffset + portOffsetAgent,
237238
ProcessID: p.ProcessID(),
238239
ContainerID: p.ContainerID(),
240+
ContainerIP: p.ContainerIP(),
239241
})
240242
}
241243
if p := s.servers.coordinatorProc; p != nil {
@@ -245,6 +247,7 @@ func (s *Service) processListHandler(w http.ResponseWriter, r *http.Request) {
245247
Port: s.MasterPort + portOffset + portOffsetCoordinator,
246248
ProcessID: p.ProcessID(),
247249
ContainerID: p.ContainerID(),
250+
ContainerIP: p.ContainerIP(),
248251
})
249252
}
250253
if p := s.servers.dbserverProc; p != nil {
@@ -254,6 +257,7 @@ func (s *Service) processListHandler(w http.ResponseWriter, r *http.Request) {
254257
Port: s.MasterPort + portOffset + portOffsetDBServer,
255258
ProcessID: p.ProcessID(),
256259
ContainerID: p.ContainerID(),
260+
ContainerIP: p.ContainerIP(),
257261
})
258262
}
259263
}

0 commit comments

Comments
 (0)