plugin/file: trigger reload of zones based on mtime (#8085)

* Added fs.FileInfo.ModTime() based reload feature

Signed-off-by: Endre Szabo <git@end.re>

* Updated the plugin documentation.

Signed-off-by: Endre Szabo <git@end.re>

---------

Signed-off-by: Endre Szabo <git@end.re>
This commit is contained in:
Endre Szabo
2026-05-20 04:43:46 +02:00
committed by GitHub
parent ee7ff82cf5
commit 35391dd8a9
6 changed files with 283 additions and 4 deletions

View File

@@ -5,6 +5,7 @@ import (
"context"
"fmt"
"io"
"os"
"github.com/coredns/coredns/plugin"
"github.com/coredns/coredns/plugin/pkg/fall"
@@ -148,6 +149,15 @@ func Parse(f io.Reader, origin, fileName string, serial int64) (*Zone, error) {
zp := dns.NewZoneParser(f, dns.Fqdn(origin), fileName)
zp.SetIncludeAllowed(true)
z := NewZone(origin, fileName)
if z.ReloadByMtime {
fi, err := os.Stat(fileName)
if err != nil {
return nil, fmt.Errorf("failed to stat file %q with error %v", fileName, err)
}
z.file_mtime = fi.ModTime()
}
seenSOA := false
for rr, ok := zp.Next(); ok; rr, ok = zp.Next() {
if !seenSOA {