mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-02 16:29:21 +00:00
Merge pull request #9749 from dchen1107/podstatus
Add logging at RunInContainer for future debugging docker exec issues.
This commit is contained in:
commit
cdef8ae844
@ -910,8 +910,10 @@ func (dm *DockerManager) RunInContainer(containerID string, cmd []string) ([]byt
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if !useNativeExec {
|
if !useNativeExec {
|
||||||
|
glog.V(2).Infof("Using nsinit to run the command %+v inside container %s", cmd, containerID)
|
||||||
return dm.runInContainerUsingNsinit(containerID, cmd)
|
return dm.runInContainerUsingNsinit(containerID, cmd)
|
||||||
}
|
}
|
||||||
|
glog.V(2).Infof("Using docker native exec to run cmd %+v inside container %s", cmd, containerID)
|
||||||
createOpts := docker.CreateExecOptions{
|
createOpts := docker.CreateExecOptions{
|
||||||
Container: containerID,
|
Container: containerID,
|
||||||
Cmd: cmd,
|
Cmd: cmd,
|
||||||
@ -934,16 +936,19 @@ func (dm *DockerManager) RunInContainer(containerID string, cmd []string) ([]byt
|
|||||||
}
|
}
|
||||||
err = dm.client.StartExec(execObj.ID, startOpts)
|
err = dm.client.StartExec(execObj.ID, startOpts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
glog.V(2).Infof("StartExec With error: %v", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
tick := time.Tick(2 * time.Second)
|
tick := time.Tick(2 * time.Second)
|
||||||
for {
|
for {
|
||||||
inspect, err2 := dm.client.InspectExec(execObj.ID)
|
inspect, err2 := dm.client.InspectExec(execObj.ID)
|
||||||
if err2 != nil {
|
if err2 != nil {
|
||||||
|
glog.V(2).Infof("InspectExec %s failed with error: %+v", execObj.ID, err2)
|
||||||
return buf.Bytes(), err2
|
return buf.Bytes(), err2
|
||||||
}
|
}
|
||||||
if !inspect.Running {
|
if !inspect.Running {
|
||||||
if inspect.ExitCode != 0 {
|
if inspect.ExitCode != 0 {
|
||||||
|
glog.V(2).Infof("InspectExec %s exit with result %+v", execObj.ID, inspect)
|
||||||
err = &dockerExitError{inspect}
|
err = &dockerExitError{inspect}
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
|
Loading…
Reference in New Issue
Block a user