mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-01-08 06:15:40 +00:00
Add controller name to periodical_enqueue_source
The code changes are related to the `NewPeriodicalEnqueueSource` function in the `kube/periodical_enqueue_source.go` file. This function is used to create a new instance of the `PeriodicalEnqueueSource` struct, which is responsible for periodically enqueueing objects into a work queue. The changes involve adding two new parameters to this function: `controllerName string` and modifying the existing `logger` parameter to include additional fields. Here's what changed: 1. A new `controllerName` parameter was added to the `NewPeriodicalEnqueueSource` function. These changes are to adding more context or metadata to the logging output, possibly for debugging or monitoring purposes. The other files (`restore_operations_controller.go`, `schedule_controller.go`, and their respective test files) were modified to use this updated `NewPeriodicalEnqueueSource` function with the new `controllerName` parameter. Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com>
This commit is contained in:
@@ -36,13 +36,16 @@ import (
|
||||
)
|
||||
|
||||
func NewPeriodicalEnqueueSource(
|
||||
controllerName string,
|
||||
logger logrus.FieldLogger,
|
||||
client client.Client,
|
||||
objList client.ObjectList,
|
||||
period time.Duration,
|
||||
option PeriodicalEnqueueSourceOption) *PeriodicalEnqueueSource {
|
||||
return &PeriodicalEnqueueSource{
|
||||
logger: logger.WithField("resource", reflect.TypeOf(objList).String()),
|
||||
logger: logger.
|
||||
WithField("resource", reflect.TypeOf(objList).String()).
|
||||
WithField("controller", controllerName),
|
||||
Client: client,
|
||||
objList: objList,
|
||||
period: period,
|
||||
|
||||
@@ -42,7 +42,7 @@ func TestStart(t *testing.T) {
|
||||
ctx, cancelFunc := context.WithCancel(context.TODO())
|
||||
client := (&fake.ClientBuilder{}).Build()
|
||||
queue := workqueue.NewRateLimitingQueue(workqueue.DefaultItemBasedRateLimiter())
|
||||
source := NewPeriodicalEnqueueSource(logrus.WithContext(ctx), client, &velerov1.ScheduleList{}, 1*time.Second, PeriodicalEnqueueSourceOption{})
|
||||
source := NewPeriodicalEnqueueSource("PES_TEST", logrus.WithContext(ctx), client, &velerov1.ScheduleList{}, 1*time.Second, PeriodicalEnqueueSourceOption{})
|
||||
|
||||
require.NoError(t, source.Start(ctx, nil, queue))
|
||||
|
||||
@@ -75,6 +75,7 @@ func TestPredicate(t *testing.T) {
|
||||
client := (&fake.ClientBuilder{}).Build()
|
||||
queue := workqueue.NewRateLimitingQueue(workqueue.DefaultItemBasedRateLimiter())
|
||||
source := NewPeriodicalEnqueueSource(
|
||||
"PES_TEST",
|
||||
logrus.WithContext(ctx),
|
||||
client,
|
||||
&velerov1.BackupStorageLocationList{},
|
||||
@@ -115,6 +116,7 @@ func TestOrder(t *testing.T) {
|
||||
client := (&fake.ClientBuilder{}).Build()
|
||||
queue := workqueue.NewRateLimitingQueue(workqueue.DefaultItemBasedRateLimiter())
|
||||
source := NewPeriodicalEnqueueSource(
|
||||
"PES_TEST",
|
||||
logrus.WithContext(ctx),
|
||||
client,
|
||||
&velerov1.BackupStorageLocationList{},
|
||||
|
||||
Reference in New Issue
Block a user