yangerd: Send sighup to yangerd on config change

This is to force yangerd to repoll polled things
This commit is contained in:
Mattias Walström
2026-06-27 08:39:48 +02:00
parent 2dffad67b7
commit b40f64492f
3 changed files with 17 additions and 4 deletions
+9
View File
@@ -674,6 +674,15 @@ static int change_cb(sr_session_ctx_t *session, uint32_t sub_id, const char *mod
return SR_ERR_SYS;
}
/*
Send sighup to yangerd to trigger a poll of polled values.
This will make sure that there is no stale data.
*/
if (systemf("initctl -b reload yangerd")) {
EMERG("Failed reloading yangerd");
return SR_ERR_SYS;
}
AUDIT("The new configuration has been applied.");
}
+7 -3
View File
@@ -21,14 +21,14 @@ type Collector interface {
// RunAll starts one goroutine per Collector, each ticking at the
// collector's configured interval. A failed Collect is logged and
// retried on the next tick. All goroutines exit when ctx is cancelled.
func RunAll(ctx context.Context, wg *sync.WaitGroup, t *tree.Tree, collectors []Collector) {
func RunAll(ctx context.Context, wg *sync.WaitGroup, t *tree.Tree, collectors []Collector, pokeCh <-chan struct{}) {
for _, c := range collectors {
wg.Add(1)
go runOne(ctx, wg, t, c)
go runOne(ctx, wg, t, c, pokeCh)
}
}
func runOne(ctx context.Context, wg *sync.WaitGroup, t *tree.Tree, c Collector) {
func runOne(ctx context.Context, wg *sync.WaitGroup, t *tree.Tree, c Collector, pokeCh <-chan struct{}) {
defer wg.Done()
if err := c.Collect(ctx, t); err != nil {
@@ -46,6 +46,10 @@ func runOne(ctx context.Context, wg *sync.WaitGroup, t *tree.Tree, c Collector)
if err := c.Collect(ctx, t); err != nil {
log.Printf("collector %s: %v", c.Name(), err)
}
case <-pokeCh:
if err := c.Collect(ctx, t); err != nil {
log.Printf("collector %s: poke: %v", c.Name(), err)
}
}
}
}