@@ -152,7 +152,7 @@ func (pb *prober) runProbe(ctx context.Context, probeType probeType, p *v1.Probe
152
152
case p .Exec != nil :
153
153
klog .V (4 ).InfoS ("Exec-Probe runProbe" , "pod" , klog .KObj (pod ), "containerName" , container .Name , "execCommand" , p .Exec .Command )
154
154
command := kubecontainer .ExpandContainerCommandOnlyStatic (p .Exec .Command , container .Env )
155
- return pb .exec .Probe (pb .newExecInContainer (ctx , container , containerID , command , timeout ))
155
+ return pb .exec .Probe (pb .newExecInContainer (ctx , pod , container , containerID , command , timeout ))
156
156
157
157
case p .HTTPGet != nil :
158
158
req , err := httpprobe .NewRequestForHTTPGetAction (p .HTTPGet , & container , status .PodIP , "probe" )
@@ -202,14 +202,18 @@ func (pb *prober) runProbe(ctx context.Context, probeType probeType, p *v1.Probe
202
202
type execInContainer struct {
203
203
// run executes a command in a container. Combined stdout and stderr output is always returned. An
204
204
// error is returned if one occurred.
205
- run func () ([]byte , error )
206
- writer io.Writer
205
+ run func () ([]byte , error )
206
+ writer io.Writer
207
+ pod * v1.Pod
208
+ container v1.Container
207
209
}
208
210
209
- func (pb * prober ) newExecInContainer (ctx context.Context , container v1.Container , containerID kubecontainer.ContainerID , cmd []string , timeout time.Duration ) exec.Cmd {
210
- return & execInContainer {run : func () ([]byte , error ) {
211
- return pb .runner .RunInContainer (ctx , containerID , cmd , timeout )
212
- }}
211
+ func (pb * prober ) newExecInContainer (ctx context.Context , pod * v1.Pod , container v1.Container , containerID kubecontainer.ContainerID , cmd []string , timeout time.Duration ) exec.Cmd {
212
+ return & execInContainer {
213
+ run : func () ([]byte , error ) { return pb .runner .RunInContainer (ctx , containerID , cmd , timeout ) },
214
+ pod : pod ,
215
+ container : container ,
216
+ }
213
217
}
214
218
215
219
func (eic * execInContainer ) Run () error {
@@ -253,7 +257,7 @@ func (eic *execInContainer) Start() error {
253
257
if eic .writer != nil {
254
258
// only record the write error, do not cover the command run error
255
259
if p , err := eic .writer .Write (data ); err != nil {
256
- klog .ErrorS (err , "Unable to write all bytes from execInContainer" , "expectedBytes" , len (data ), "actualBytes" , p )
260
+ klog .ErrorS (err , "Unable to write all bytes from execInContainer" , "expectedBytes" , len (data ), "actualBytes" , p , "pod" , klog . KObj ( eic . pod ), "containerName" , eic . container . Name )
257
261
}
258
262
}
259
263
return err
0 commit comments