Merge pull request #814 from runcom/cache-ip-sandbox
cache sandbox's IP address
This commit is contained in:
commit
ac12018973
16 changed files with 112 additions and 74 deletions
|
@ -4,13 +4,13 @@ import (
|
|||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/go-zoo/bone"
|
||||
)
|
||||
|
||||
// ContainerInfo stores information about containers
|
||||
type ContainerInfo struct {
|
||||
Name string `json:"name"`
|
||||
Pid int `json:"pid"`
|
||||
Image string `json:"image"`
|
||||
CreatedTime int64 `json:"created_time"`
|
||||
|
@ -19,6 +19,7 @@ type ContainerInfo struct {
|
|||
LogPath string `json:"log_path"`
|
||||
Root string `json:"root"`
|
||||
Sandbox string `json:"sandbox"`
|
||||
IP string `json:"ip_address"`
|
||||
}
|
||||
|
||||
// CrioInfo stores information about the crio daemon
|
||||
|
@ -62,16 +63,22 @@ func (s *Server) GetInfoMux() *bone.Mux {
|
|||
http.Error(w, fmt.Sprintf("container %s state is nil", containerID), http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
|
||||
sb := s.getSandbox(ctr.Sandbox())
|
||||
if sb == nil {
|
||||
http.Error(w, fmt.Sprintf("can't find the sandbox for container id, sandbox id %s: %s", containerID, ctr.Sandbox()), http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
ci := ContainerInfo{
|
||||
Name: ctr.Name(),
|
||||
Pid: ctrState.Pid,
|
||||
Image: ctr.Image(),
|
||||
CreatedTime: ctrState.Created.UnixNano(),
|
||||
Labels: ctr.Labels(),
|
||||
Annotations: ctr.Annotations(),
|
||||
Root: ctr.MountPoint(),
|
||||
LogPath: filepath.Dir(ctr.LogPath()),
|
||||
LogPath: ctr.LogPath(),
|
||||
Sandbox: ctr.Sandbox(),
|
||||
IP: sb.IP(),
|
||||
}
|
||||
js, err := json.Marshal(ci)
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue