Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions reconciler/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package reconciler

import (
"fmt"
"time"

"github.com/cilium/hive/job"
Expand Down Expand Up @@ -81,9 +82,17 @@ func Register[Obj comparable](
progress: newProgressTracker(),
}

params.JobGroup.Add(job.OneShot("reconcile", r.reconcileLoop))
var scoped = func(jn string) string {
if cfg.Name == "" {
return jn
}

return fmt.Sprintf("%s-%s", jn, cfg.Name)
}

params.JobGroup.Add(job.OneShot(scoped("reconcile"), r.reconcileLoop))
if r.config.RefreshInterval > 0 {
params.JobGroup.Add(job.OneShot("refresh", r.refreshLoop))
params.JobGroup.Add(job.OneShot(scoped("refresh"), r.refreshLoop))
}
return r, nil
}
Expand Down
10 changes: 8 additions & 2 deletions reconciler/multi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ func TestMultipleReconcilersPerModuleMetrics(t *testing.T) {

var ops1, ops2 multiMockOps
var db *statedb.DB
var health *cell.SimpleHealth
metrics := reconciler.NewUnpublishedExpVarMetrics()

hive := hive.New(
Expand All @@ -228,8 +229,8 @@ func TestMultipleReconcilersPerModuleMetrics(t *testing.T) {
return r.NewGroup(h)
},
),
cell.Invoke(func(db_ *statedb.DB) (err error) {
db = db_
cell.Invoke(func(db_ *statedb.DB, h *cell.SimpleHealth) (err error) {
db, health = db_, h
table, err = statedb.NewTable(db, "objects", multiStatusIndex)
return err
}),
Expand Down Expand Up @@ -306,5 +307,10 @@ func TestMultipleReconcilersPerModuleMetrics(t *testing.T) {
assert.Equal(t, "0", metrics.ReconciliationCurrentErrorsVar.Get("test/right").String())
assert.Nil(t, metrics.ReconciliationCountVar.Get("test"))

assert.NotNil(t, health.GetChild("job-reconcile-left"))
assert.NotNil(t, health.GetChild("job-refresh-left"))
assert.NotNil(t, health.GetChild("job-reconcile-right"))
assert.NotNil(t, health.GetChild("job-refresh-right"))

require.NoError(t, hive.Stop(log, context.TODO()), "Stop")
}
Loading