@@ -20,6 +20,7 @@ import (
20
20
"context"
21
21
"errors"
22
22
"fmt"
23
+ "strconv"
23
24
"strings"
24
25
"sync"
25
26
"time"
@@ -236,6 +237,15 @@ func (w *baseWorker) GetResult() (rel *release.Release, isRuuing bool, err error
236
237
return w .release , w .isRunning , w .err
237
238
}
238
239
240
+ func (w * baseWorker ) logKV () []interface {} {
241
+ res := []interface {}{"workername" , w .name }
242
+ if w .plan != nil {
243
+ res = append (res , "planUID" , string (w .plan .UID ))
244
+ res = append (res , "planGeneration" , strconv .FormatInt (w .plan .Generation , 10 ))
245
+ }
246
+ return res
247
+ }
248
+
239
249
type installWorker struct {
240
250
baseWorker
241
251
}
@@ -254,11 +264,11 @@ func newInstallWorker(ctx context.Context, name, chartName string, logger logr.L
254
264
subCtx , cancel := context .WithCancel (ctx )
255
265
w .cancel = cancel
256
266
go func () {
257
- w .logger .V (1 ).Info ("start install worker" , "workername" , w . name )
267
+ w .logger .V (1 ).Info ("start install worker" , w . logKV () ... )
258
268
w .startTime = metav1 .Now ()
259
269
defer func () {
260
270
cost := time .Since (w .startTime .Time )
261
- w .logger .V (1 ).Info (fmt .Sprintf ("stop install worker, cost %s" , cost ), "workername" , w . name )
271
+ w .logger .V (1 ).Info (fmt .Sprintf ("stop install worker, cost %s" , cost ), w . logKV () ... )
262
272
w .isRunning = false
263
273
}()
264
274
w .status = release .StatusPendingInstall
@@ -314,10 +324,10 @@ func newUnInstallWorker(ctx context.Context, name string, logger logr.Logger, pl
314
324
subCtx , cancel := context .WithCancel (ctx )
315
325
w .cancel = cancel
316
326
go func () {
317
- w .logger .V (1 ).Info ("start uninstall worker" , "workername" , w . name )
327
+ w .logger .V (1 ).Info ("start uninstall worker" , w . logKV () ... )
318
328
startTime := metav1 .Now ()
319
329
defer func () {
320
- w .logger .V (1 ).Info (fmt .Sprintf ("stop uninstall worker, cost %s" , time .Since (startTime .Time )), "workername" , w . name )
330
+ w .logger .V (1 ).Info (fmt .Sprintf ("stop uninstall worker, cost %s" , time .Since (startTime .Time )), w . logKV () ... )
321
331
w .isRunning = false
322
332
}()
323
333
w .status = release .StatusUninstalling
@@ -362,10 +372,10 @@ func newRollBackWorker(ctx context.Context, name string, logger logr.Logger, pla
362
372
subCtx , cancel := context .WithCancel (ctx )
363
373
w .cancel = cancel
364
374
go func () {
365
- w .logger .V (1 ).Info ("start rollback worker" , "workername" , w . name )
375
+ w .logger .V (1 ).Info ("start rollback worker" , w . logKV () ... )
366
376
startTime := metav1 .Now ()
367
377
defer func () {
368
- w .logger .V (1 ).Info (fmt .Sprintf ("stop rollback worker, cost %s" , time .Since (startTime .Time )), "workername" , w . name )
378
+ w .logger .V (1 ).Info (fmt .Sprintf ("stop rollback worker, cost %s" , time .Since (startTime .Time )), w . logKV () ... )
369
379
w .isRunning = false
370
380
}()
371
381
w .status = release .StatusUninstalling
0 commit comments