server: Add sandbox pid as well to container info
We need it to get network stats in cadvisor stats and can avoid an additional REST call. Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
This commit is contained in:
parent
8538c4067a
commit
a4eaff5ac0
1 changed files with 12 additions and 0 deletions
|
@ -19,6 +19,7 @@ type ContainerInfo struct {
|
||||||
LogPath string `json:"log_path"`
|
LogPath string `json:"log_path"`
|
||||||
Root string `json:"root"`
|
Root string `json:"root"`
|
||||||
Sandbox string `json:"sandbox"`
|
Sandbox string `json:"sandbox"`
|
||||||
|
SandboxPid int `json:"sandbox_pid"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// CrioInfo stores information about the crio daemon
|
// CrioInfo stores information about the crio daemon
|
||||||
|
@ -60,6 +61,16 @@ func (s *Server) GetInfoMux() *bone.Mux {
|
||||||
http.Error(w, fmt.Sprintf("container %s state is nil", containerID), http.StatusNotFound)
|
http.Error(w, fmt.Sprintf("container %s state is nil", containerID), http.StatusNotFound)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
sbContainer := s.getInfraContainer(ctr.Sandbox())
|
||||||
|
if sbContainer == nil {
|
||||||
|
http.Error(w, fmt.Sprintf("can't find the sandbox container for container id: %s", containerID), http.StatusNotFound)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
sbContainerState := sbContainer.State()
|
||||||
|
if sbContainerState == nil {
|
||||||
|
http.Error(w, fmt.Sprintf("container %s state is nil", ctr.Sandbox()), http.StatusNotFound)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
ci := ContainerInfo{
|
ci := ContainerInfo{
|
||||||
Pid: ctrState.Pid,
|
Pid: ctrState.Pid,
|
||||||
|
@ -70,6 +81,7 @@ func (s *Server) GetInfoMux() *bone.Mux {
|
||||||
Root: ctr.MountPoint(),
|
Root: ctr.MountPoint(),
|
||||||
LogPath: filepath.Dir(ctr.LogPath()),
|
LogPath: filepath.Dir(ctr.LogPath()),
|
||||||
Sandbox: ctr.Sandbox(),
|
Sandbox: ctr.Sandbox(),
|
||||||
|
SandboxPid: sbContainerState.Pid,
|
||||||
}
|
}
|
||||||
js, err := json.Marshal(ci)
|
js, err := json.Marshal(ci)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue