@@ -71,6 +71,8 @@ func NewRemoteRuntimeService(endpoint string, connectionTimeout time.Duration) (
71
71
72
72
// Version returns the runtime name, runtime version and runtime API version.
73
73
func (r * RemoteRuntimeService ) Version (apiVersion string ) (* runtimeapi.VersionResponse , error ) {
74
+ klog .V (10 ).Infof ("[RemoteRuntimeService] Version (apiVersion=%v, timeout=%v)" , apiVersion , r .timeout )
75
+
74
76
ctx , cancel := getContextWithTimeout (r .timeout )
75
77
defer cancel ()
76
78
@@ -82,6 +84,8 @@ func (r *RemoteRuntimeService) Version(apiVersion string) (*runtimeapi.VersionRe
82
84
return nil , err
83
85
}
84
86
87
+ klog .V (10 ).Infof ("[RemoteRuntimeService] Version Response (typedVersion=%v)" , typedVersion )
88
+
85
89
if typedVersion .Version == "" || typedVersion .RuntimeName == "" || typedVersion .RuntimeApiVersion == "" || typedVersion .RuntimeVersion == "" {
86
90
return nil , fmt .Errorf ("not all fields are set in VersionResponse (%q)" , * typedVersion )
87
91
}
@@ -94,7 +98,11 @@ func (r *RemoteRuntimeService) Version(apiVersion string) (*runtimeapi.VersionRe
94
98
func (r * RemoteRuntimeService ) RunPodSandbox (config * runtimeapi.PodSandboxConfig , runtimeHandler string ) (string , error ) {
95
99
// Use 2 times longer timeout for sandbox operation (4 mins by default)
96
100
// TODO: Make the pod sandbox timeout configurable.
97
- ctx , cancel := getContextWithTimeout (r .timeout * 2 )
101
+ timeout := r .timeout * 2
102
+
103
+ klog .V (10 ).Infof ("[RemoteRuntimeService] RunPodSandbox (config=%v, runtimeHandler=%v, timeout=%v)" , config , runtimeHandler , timeout )
104
+
105
+ ctx , cancel := getContextWithTimeout (timeout )
98
106
defer cancel ()
99
107
100
108
resp , err := r .runtimeClient .RunPodSandbox (ctx , & runtimeapi.RunPodSandboxRequest {
@@ -112,12 +120,16 @@ func (r *RemoteRuntimeService) RunPodSandbox(config *runtimeapi.PodSandboxConfig
112
120
return "" , errors .New (errorMessage )
113
121
}
114
122
123
+ klog .V (10 ).Infof ("[RemoteRuntimeService] RunPodSandbox Response (PodSandboxId=%v)" , resp .PodSandboxId )
124
+
115
125
return resp .PodSandboxId , nil
116
126
}
117
127
118
128
// StopPodSandbox stops the sandbox. If there are any running containers in the
119
129
// sandbox, they should be forced to termination.
120
130
func (r * RemoteRuntimeService ) StopPodSandbox (podSandBoxID string ) error {
131
+ klog .V (10 ).Infof ("[RemoteRuntimeService] StopPodSandbox (podSandboxID=%v, timeout=%v)" , podSandBoxID , r .timeout )
132
+
121
133
ctx , cancel := getContextWithTimeout (r .timeout )
122
134
defer cancel ()
123
135
@@ -129,12 +141,15 @@ func (r *RemoteRuntimeService) StopPodSandbox(podSandBoxID string) error {
129
141
return err
130
142
}
131
143
144
+ klog .V (10 ).Infof ("[RemoteRuntimeService] StopPodSandbox Response (podSandboxID=%v)" , podSandBoxID )
145
+
132
146
return nil
133
147
}
134
148
135
149
// RemovePodSandbox removes the sandbox. If there are any containers in the
136
150
// sandbox, they should be forcibly removed.
137
151
func (r * RemoteRuntimeService ) RemovePodSandbox (podSandBoxID string ) error {
152
+ klog .V (10 ).Infof ("[RemoteRuntimeService] RemovePodSandbox (podSandboxID=%v, timeout=%v)" , podSandBoxID , r .timeout )
138
153
ctx , cancel := getContextWithTimeout (r .timeout )
139
154
defer cancel ()
140
155
@@ -146,11 +161,14 @@ func (r *RemoteRuntimeService) RemovePodSandbox(podSandBoxID string) error {
146
161
return err
147
162
}
148
163
164
+ klog .V (10 ).Infof ("[RemoteRuntimeService] RemovePodSandbox Response (podSandboxID=%v)" , podSandBoxID )
165
+
149
166
return nil
150
167
}
151
168
152
169
// PodSandboxStatus returns the status of the PodSandbox.
153
170
func (r * RemoteRuntimeService ) PodSandboxStatus (podSandBoxID string ) (* runtimeapi.PodSandboxStatus , error ) {
171
+ klog .V (10 ).Infof ("[RemoteRuntimeService] PodSandboxStatus (podSandboxID=%v, timeout=%v)" , podSandBoxID , r .timeout )
154
172
ctx , cancel := getContextWithTimeout (r .timeout )
155
173
defer cancel ()
156
174
@@ -161,6 +179,8 @@ func (r *RemoteRuntimeService) PodSandboxStatus(podSandBoxID string) (*runtimeap
161
179
return nil , err
162
180
}
163
181
182
+ klog .V (10 ).Infof ("[RemoteRuntimeService] PodSandboxStatus Response (podSandboxID=%v, status=%v)" , podSandBoxID , resp .Status )
183
+
164
184
if resp .Status != nil {
165
185
if err := verifySandboxStatus (resp .Status ); err != nil {
166
186
return nil , err
@@ -172,6 +192,7 @@ func (r *RemoteRuntimeService) PodSandboxStatus(podSandBoxID string) (*runtimeap
172
192
173
193
// ListPodSandbox returns a list of PodSandboxes.
174
194
func (r * RemoteRuntimeService ) ListPodSandbox (filter * runtimeapi.PodSandboxFilter ) ([]* runtimeapi.PodSandbox , error ) {
195
+ klog .V (10 ).Infof ("[RemoteRuntimeService] ListPodSandbox (filter=%v, timeout=%v)" , filter , r .timeout )
175
196
ctx , cancel := getContextWithTimeout (r .timeout )
176
197
defer cancel ()
177
198
@@ -183,11 +204,14 @@ func (r *RemoteRuntimeService) ListPodSandbox(filter *runtimeapi.PodSandboxFilte
183
204
return nil , err
184
205
}
185
206
207
+ klog .V (10 ).Infof ("[RemoteRuntimeService] ListPodSandbox Response (filter=%v, items=%v)" , filter , resp .Items )
208
+
186
209
return resp .Items , nil
187
210
}
188
211
189
212
// CreateContainer creates a new container in the specified PodSandbox.
190
213
func (r * RemoteRuntimeService ) CreateContainer (podSandBoxID string , config * runtimeapi.ContainerConfig , sandboxConfig * runtimeapi.PodSandboxConfig ) (string , error ) {
214
+ klog .V (10 ).Infof ("[RemoteRuntimeService] CreateContainer (podSandBoxID=%v, timeout=%v)" , podSandBoxID , r .timeout )
191
215
ctx , cancel := getContextWithTimeout (r .timeout )
192
216
defer cancel ()
193
217
@@ -201,6 +225,7 @@ func (r *RemoteRuntimeService) CreateContainer(podSandBoxID string, config *runt
201
225
return "" , err
202
226
}
203
227
228
+ klog .V (10 ).Infof ("[RemoteRuntimeService] CreateContainer (podSandBoxID=%v, ContainerId=%v)" , podSandBoxID , resp .ContainerId )
204
229
if resp .ContainerId == "" {
205
230
errorMessage := fmt .Sprintf ("ContainerId is not set for container %q" , config .GetMetadata ())
206
231
klog .Errorf ("CreateContainer failed: %s" , errorMessage )
@@ -212,6 +237,7 @@ func (r *RemoteRuntimeService) CreateContainer(podSandBoxID string, config *runt
212
237
213
238
// StartContainer starts the container.
214
239
func (r * RemoteRuntimeService ) StartContainer (containerID string ) error {
240
+ klog .V (10 ).Infof ("[RemoteRuntimeService] StartContainer (containerID=%v, timeout=%v)" , containerID , r .timeout )
215
241
ctx , cancel := getContextWithTimeout (r .timeout )
216
242
defer cancel ()
217
243
@@ -222,12 +248,14 @@ func (r *RemoteRuntimeService) StartContainer(containerID string) error {
222
248
klog .Errorf ("StartContainer %q from runtime service failed: %v" , containerID , err )
223
249
return err
224
250
}
251
+ klog .V (10 ).Infof ("[RemoteRuntimeService] StartContainer Response (containerID=%v)" , containerID )
225
252
226
253
return nil
227
254
}
228
255
229
256
// StopContainer stops a running container with a grace period (i.e., timeout).
230
257
func (r * RemoteRuntimeService ) StopContainer (containerID string , timeout int64 ) error {
258
+ klog .V (10 ).Infof ("[RemoteRuntimeService] StopContainer (containerID=%v, timeout=%v)" , containerID , timeout )
231
259
// Use timeout + default timeout (2 minutes) as timeout to leave extra time
232
260
// for SIGKILL container and request latency.
233
261
t := r .timeout + time .Duration (timeout )* time .Second
@@ -243,13 +271,15 @@ func (r *RemoteRuntimeService) StopContainer(containerID string, timeout int64)
243
271
klog .Errorf ("StopContainer %q from runtime service failed: %v" , containerID , err )
244
272
return err
245
273
}
274
+ klog .V (10 ).Infof ("[RemoteRuntimeService] StopContainer Response (containerID=%v)" , containerID )
246
275
247
276
return nil
248
277
}
249
278
250
279
// RemoveContainer removes the container. If the container is running, the container
251
280
// should be forced to removal.
252
281
func (r * RemoteRuntimeService ) RemoveContainer (containerID string ) error {
282
+ klog .V (10 ).Infof ("[RemoteRuntimeService] RemoveContainer (containerID=%v, timeout=%v)" , containerID , r .timeout )
253
283
ctx , cancel := getContextWithTimeout (r .timeout )
254
284
defer cancel ()
255
285
@@ -261,12 +291,14 @@ func (r *RemoteRuntimeService) RemoveContainer(containerID string) error {
261
291
klog .Errorf ("RemoveContainer %q from runtime service failed: %v" , containerID , err )
262
292
return err
263
293
}
294
+ klog .V (10 ).Infof ("[RemoteRuntimeService] RemoveContainer Response (containerID=%v)" , containerID )
264
295
265
296
return nil
266
297
}
267
298
268
299
// ListContainers lists containers by filters.
269
300
func (r * RemoteRuntimeService ) ListContainers (filter * runtimeapi.ContainerFilter ) ([]* runtimeapi.Container , error ) {
301
+ klog .V (10 ).Infof ("[RemoteRuntimeService] ListContainers (filter=%v, timeout=%v)" , filter , r .timeout )
270
302
ctx , cancel := getContextWithTimeout (r .timeout )
271
303
defer cancel ()
272
304
@@ -277,12 +309,14 @@ func (r *RemoteRuntimeService) ListContainers(filter *runtimeapi.ContainerFilter
277
309
klog .Errorf ("ListContainers with filter %+v from runtime service failed: %v" , filter , err )
278
310
return nil , err
279
311
}
312
+ klog .V (10 ).Infof ("[RemoteRuntimeService] ListContainers Response (filter=%v, containers=%v)" , filter , resp .Containers )
280
313
281
314
return resp .Containers , nil
282
315
}
283
316
284
317
// ContainerStatus returns the container status.
285
318
func (r * RemoteRuntimeService ) ContainerStatus (containerID string ) (* runtimeapi.ContainerStatus , error ) {
319
+ klog .V (10 ).Infof ("[RemoteRuntimeService] ContainerStatus (containerID=%v, timeout=%v)" , containerID , r .timeout )
286
320
ctx , cancel := getContextWithTimeout (r .timeout )
287
321
defer cancel ()
288
322
@@ -297,6 +331,7 @@ func (r *RemoteRuntimeService) ContainerStatus(containerID string) (*runtimeapi.
297
331
return nil , err
298
332
}
299
333
r .logReduction .ClearID (containerID )
334
+ klog .V (10 ).Infof ("[RemoteRuntimeService] ContainerStatus Response (containerID=%v, status=%v)" , containerID , resp .Status )
300
335
301
336
if resp .Status != nil {
302
337
if err := verifyContainerStatus (resp .Status ); err != nil {
@@ -310,6 +345,7 @@ func (r *RemoteRuntimeService) ContainerStatus(containerID string) (*runtimeapi.
310
345
311
346
// UpdateContainerResources updates a containers resource config
312
347
func (r * RemoteRuntimeService ) UpdateContainerResources (containerID string , resources * runtimeapi.LinuxContainerResources ) error {
348
+ klog .V (10 ).Infof ("[RemoteRuntimeService] UpdateContainerResources (containerID=%v, timeout=%v)" , containerID , r .timeout )
313
349
ctx , cancel := getContextWithTimeout (r .timeout )
314
350
defer cancel ()
315
351
@@ -321,13 +357,15 @@ func (r *RemoteRuntimeService) UpdateContainerResources(containerID string, reso
321
357
klog .Errorf ("UpdateContainerResources %q from runtime service failed: %v" , containerID , err )
322
358
return err
323
359
}
360
+ klog .V (10 ).Infof ("[RemoteRuntimeService] UpdateContainerResources Response (containerID=%v)" , containerID )
324
361
325
362
return nil
326
363
}
327
364
328
365
// ExecSync executes a command in the container, and returns the stdout output.
329
366
// If command exits with a non-zero exit code, an error is returned.
330
367
func (r * RemoteRuntimeService ) ExecSync (containerID string , cmd []string , timeout time.Duration ) (stdout []byte , stderr []byte , err error ) {
368
+ klog .V (10 ).Infof ("[RemoteRuntimeService] ExecSync (containerID=%v, timeout=%v)" , containerID , timeout )
331
369
// Do not set timeout when timeout is 0.
332
370
var ctx context.Context
333
371
var cancel context.CancelFunc
@@ -352,6 +390,7 @@ func (r *RemoteRuntimeService) ExecSync(containerID string, cmd []string, timeou
352
390
return nil , nil , err
353
391
}
354
392
393
+ klog .V (10 ).Infof ("[RemoteRuntimeService] ExecSync Response (containerID=%v, ExitCode=%v)" , containerID , resp .ExitCode )
355
394
err = nil
356
395
if resp .ExitCode != 0 {
357
396
err = utilexec.CodeExitError {
@@ -365,6 +404,7 @@ func (r *RemoteRuntimeService) ExecSync(containerID string, cmd []string, timeou
365
404
366
405
// Exec prepares a streaming endpoint to execute a command in the container, and returns the address.
367
406
func (r * RemoteRuntimeService ) Exec (req * runtimeapi.ExecRequest ) (* runtimeapi.ExecResponse , error ) {
407
+ klog .V (10 ).Infof ("[RemoteRuntimeService] Exec (timeout=%v)" , r .timeout )
368
408
ctx , cancel := getContextWithTimeout (r .timeout )
369
409
defer cancel ()
370
410
@@ -373,6 +413,7 @@ func (r *RemoteRuntimeService) Exec(req *runtimeapi.ExecRequest) (*runtimeapi.Ex
373
413
klog .Errorf ("Exec %s '%s' from runtime service failed: %v" , req .ContainerId , strings .Join (req .Cmd , " " ), err )
374
414
return nil , err
375
415
}
416
+ klog .V (10 ).Info ("[RemoteRuntimeService] Exec Response" )
376
417
377
418
if resp .Url == "" {
378
419
errorMessage := "URL is not set"
@@ -385,6 +426,7 @@ func (r *RemoteRuntimeService) Exec(req *runtimeapi.ExecRequest) (*runtimeapi.Ex
385
426
386
427
// Attach prepares a streaming endpoint to attach to a running container, and returns the address.
387
428
func (r * RemoteRuntimeService ) Attach (req * runtimeapi.AttachRequest ) (* runtimeapi.AttachResponse , error ) {
429
+ klog .V (10 ).Infof ("[RemoteRuntimeService] Attach (containerId=%v, timeout=%v)" , req .ContainerId , r .timeout )
388
430
ctx , cancel := getContextWithTimeout (r .timeout )
389
431
defer cancel ()
390
432
@@ -393,6 +435,7 @@ func (r *RemoteRuntimeService) Attach(req *runtimeapi.AttachRequest) (*runtimeap
393
435
klog .Errorf ("Attach %s from runtime service failed: %v" , req .ContainerId , err )
394
436
return nil , err
395
437
}
438
+ klog .V (10 ).Infof ("[RemoteRuntimeService] Attach Response (containerId=%v)" , req .ContainerId )
396
439
397
440
if resp .Url == "" {
398
441
errorMessage := "URL is not set"
@@ -404,6 +447,7 @@ func (r *RemoteRuntimeService) Attach(req *runtimeapi.AttachRequest) (*runtimeap
404
447
405
448
// PortForward prepares a streaming endpoint to forward ports from a PodSandbox, and returns the address.
406
449
func (r * RemoteRuntimeService ) PortForward (req * runtimeapi.PortForwardRequest ) (* runtimeapi.PortForwardResponse , error ) {
450
+ klog .V (10 ).Infof ("[RemoteRuntimeService] PortForward (podSandboxID=%v, port=%v, timeout=%v)" , req .PodSandboxId , req .Port , r .timeout )
407
451
ctx , cancel := getContextWithTimeout (r .timeout )
408
452
defer cancel ()
409
453
@@ -412,6 +456,7 @@ func (r *RemoteRuntimeService) PortForward(req *runtimeapi.PortForwardRequest) (
412
456
klog .Errorf ("PortForward %s from runtime service failed: %v" , req .PodSandboxId , err )
413
457
return nil , err
414
458
}
459
+ klog .V (10 ).Infof ("[RemoteRuntimeService] PortForward Response (podSandboxID=%v)" , req .PodSandboxId )
415
460
416
461
if resp .Url == "" {
417
462
errorMessage := "URL is not set"
@@ -426,6 +471,7 @@ func (r *RemoteRuntimeService) PortForward(req *runtimeapi.PortForwardRequest) (
426
471
// update payload currently supported is the pod CIDR assigned to a node,
427
472
// and the runtime service just proxies it down to the network plugin.
428
473
func (r * RemoteRuntimeService ) UpdateRuntimeConfig (runtimeConfig * runtimeapi.RuntimeConfig ) error {
474
+ klog .V (10 ).Infof ("[RemoteRuntimeService] UpdateRuntimeConfig (runtimeConfig=%v, timeout=%v)" , runtimeConfig , r .timeout )
429
475
ctx , cancel := getContextWithTimeout (r .timeout )
430
476
defer cancel ()
431
477
@@ -439,12 +485,14 @@ func (r *RemoteRuntimeService) UpdateRuntimeConfig(runtimeConfig *runtimeapi.Run
439
485
if err != nil {
440
486
return err
441
487
}
488
+ klog .V (10 ).Infof ("[RemoteRuntimeService] UpdateRuntimeConfig Response (runtimeConfig=%v)" , runtimeConfig )
442
489
443
490
return nil
444
491
}
445
492
446
493
// Status returns the status of the runtime.
447
494
func (r * RemoteRuntimeService ) Status () (* runtimeapi.RuntimeStatus , error ) {
495
+ klog .V (10 ).Infof ("[RemoteRuntimeService] Status (timeout=%v)" , r .timeout )
448
496
ctx , cancel := getContextWithTimeout (r .timeout )
449
497
defer cancel ()
450
498
@@ -454,6 +502,8 @@ func (r *RemoteRuntimeService) Status() (*runtimeapi.RuntimeStatus, error) {
454
502
return nil , err
455
503
}
456
504
505
+ klog .V (10 ).Infof ("[RemoteRuntimeService] Status Response (status=%v)" , resp .Status )
506
+
457
507
if resp .Status == nil || len (resp .Status .Conditions ) < 2 {
458
508
errorMessage := "RuntimeReady or NetworkReady condition are not set"
459
509
klog .Errorf ("Status failed: %s" , errorMessage )
@@ -465,6 +515,7 @@ func (r *RemoteRuntimeService) Status() (*runtimeapi.RuntimeStatus, error) {
465
515
466
516
// ContainerStats returns the stats of the container.
467
517
func (r * RemoteRuntimeService ) ContainerStats (containerID string ) (* runtimeapi.ContainerStats , error ) {
518
+ klog .V (10 ).Infof ("[RemoteRuntimeService] ContainerStats (containerID=%v, timeout=%v)" , containerID , r .timeout )
468
519
ctx , cancel := getContextWithTimeout (r .timeout )
469
520
defer cancel ()
470
521
@@ -478,11 +529,13 @@ func (r *RemoteRuntimeService) ContainerStats(containerID string) (*runtimeapi.C
478
529
return nil , err
479
530
}
480
531
r .logReduction .ClearID (containerID )
532
+ klog .V (10 ).Infof ("[RemoteRuntimeService] ContainerStats Response (containerID=%v, stats=%v)" , containerID , resp .GetStats ())
481
533
482
534
return resp .GetStats (), nil
483
535
}
484
536
485
537
func (r * RemoteRuntimeService ) ListContainerStats (filter * runtimeapi.ContainerStatsFilter ) ([]* runtimeapi.ContainerStats , error ) {
538
+ klog .V (10 ).Infof ("[RemoteRuntimeService] ListContainerStats (filter=%v)" , filter )
486
539
// Do not set timeout, because writable layer stats collection takes time.
487
540
// TODO(random-liu): Should we assume runtime should cache the result, and set timeout here?
488
541
ctx , cancel := getContextWithCancel ()
@@ -495,11 +548,13 @@ func (r *RemoteRuntimeService) ListContainerStats(filter *runtimeapi.ContainerSt
495
548
klog .Errorf ("ListContainerStats with filter %+v from runtime service failed: %v" , filter , err )
496
549
return nil , err
497
550
}
551
+ klog .V (10 ).Infof ("[RemoteRuntimeService] ListContainerStats Response (filter=%v, stats=%v)" , filter , resp .GetStats ())
498
552
499
553
return resp .GetStats (), nil
500
554
}
501
555
502
556
func (r * RemoteRuntimeService ) ReopenContainerLog (containerID string ) error {
557
+ klog .V (10 ).Infof ("[RemoteRuntimeService] ReopenContainerLog (containerID=%v, timeout=%v)" , containerID , r .timeout )
503
558
ctx , cancel := getContextWithTimeout (r .timeout )
504
559
defer cancel ()
505
560
@@ -508,5 +563,7 @@ func (r *RemoteRuntimeService) ReopenContainerLog(containerID string) error {
508
563
klog .Errorf ("ReopenContainerLog %q from runtime service failed: %v" , containerID , err )
509
564
return err
510
565
}
566
+
567
+ klog .V (10 ).Infof ("[RemoteRuntimeService] ReopenContainerLog Response (containerID=%v)" , containerID )
511
568
return nil
512
569
}
0 commit comments