Fail the reload when a config entry is skipped with a warning (#1952)

This commit is contained in:
Nate Brown authored and GitHub committed 2026-10-15 23:22:47 -05:00
1 parent 316bf87780
commit a203d044bb
7 files changed
+91 -13

No files matched your search

+7 -5
View File
@@ -316,9 +316,9 @@ type cachedPacketMetrics struct {
func NewHostMapFromConfig(l *slog.Logger, c *config.C) *HostMap {
hm := newHostMap(l)
hm.reload(c, true)
c.RegisterReloadCallback(func(c *config.C, _ *config.Reload) {
hm.reload(c, false)
hm.reload(c, true, nil)
c.RegisterReloadCallback(func(c *config.C, r *config.Reload) {
hm.reload(c, false, r)
})
l.Info("Main HostMap created", "preferredRanges", hm.GetPreferredRanges())
@@ -337,7 +337,8 @@ func newHostMap(l *slog.Logger) *HostMap {
}
}
func (hm *HostMap) reload(c *config.C, initial bool) {
// r is nil on the initial load
func (hm *HostMap) reload(c *config.C, initial bool, r *config.Reload) {
if initial || c.HasChanged("preferred_ranges") {
var preferredRanges []netip.Prefix
rawPreferredRanges := c.GetStringSlice("preferred_ranges", []string{})
@@ -348,8 +349,9 @@ func (hm *HostMap) reload(c *config.C, initial bool) {
if err != nil {
hm.l.Warn("Failed to parse preferred ranges, ignoring",
"error", err,
"range", rawPreferredRanges,
"range", rawPreferredRange,
)
r.Failed()
continue
}