[Bug] Filewatcher stops watching dns.extra_records_path #879

Closed
opened 2025-12-29 02:25:10 +01:00 by adam · 0 comments
Owner

Originally created by @nblock on GitHub (Dec 14, 2024).

Is this a support request?

  • This is not a support request

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

A read-edit-write cycle (with vim) causes headscale to lose track of the path in dns.extra_records_path.

Expected Behavior

Pickup changes made to the file. Headscale logs detected writes with log.level: trace when different versions of the config file are written. The sequence:

cp extra1.json .headscale-dns/extra.json
cp extra2.json .headscale-dns/extra.json
cp extra2.json .headscale-dns/extra.json    # no changes, OK

yields (fine)

2024-12-14T16:39:47+01:00 TRC ../runner/work/headscale/headscale/hscontrol/dns/extrarecords.go:87 > extra records received filewatch event op=WRITE path=.headscale-dns/extra.json
2024-12-14T16:39:47+01:00 TRC ../runner/work/headscale/headscale/hscontrol/dns/extrarecords.go:134 > extra records updated from path, count old: 1, new: 1 records=[{"Name":"grafana.myvpn.example.com","Type":"A","Value":"100.64.0.1"}]
2024-12-14T16:39:56+01:00 TRC ../runner/work/headscale/headscale/hscontrol/dns/extrarecords.go:87 > extra records received filewatch event op=WRITE path=.headscale-dns/extra.json
2024-12-14T16:39:56+01:00 TRC ../runner/work/headscale/headscale/hscontrol/dns/extrarecords.go:134 > extra records updated from path, count old: 1, new: 1 records=[{"Name":"grafana.myvpn.example.com","Type":"A","Value":"100.64.0.2"}]
2024-12-14T16:40:01+01:00 TRC ../runner/work/headscale/headscale/hscontrol/dns/extrarecords.go:87 > extra records received filewatch event op=WRITE path=.headscale-dns/extra.json

Steps To Reproduce

The following causes headscale to loose track of the file:

vim .headscale-dns/extra.json    # make some valid changes and save

yields sometimes:

2024-12-14T16:50:21+01:00 TRC ../runner/work/headscale/headscale/hscontrol/dns/extrarecords.go:87 > extra records received filewatch event op=RENAME path=.headscale-dns/extra.json
2024-12-14T16:50:21+01:00 ERR ../runner/work/headscale/headscale/hscontrol/dns/extrarecords.go:115 > reading extra records from path: .headscale-dns/extra.json error="reading path: .headscale-dns/extra.json, err: open .headscale-dns/extra.json: no such file or directory"

and yield sometimes:

2024-12-14T16:51:45+01:00 TRC ../runner/work/headscale/headscale/hscontrol/dns/extrarecords.go:87 > extra records received filewatch event op=RENAME path=.headscale-dns/extra.json
2024-12-14T16:51:45+01:00 TRC ../runner/work/headscale/headscale/hscontrol/dns/extrarecords.go:134 > extra records updated from path, count old: 1, new: 1 records=[{"Name":"grafana.myvpn.example.com","Type":"A","Value":"100.64.0.7"}]

Result is always the same:

  • Headscale no longer sends DNS updates to nodes - a query yields stale results
  • Changes to the file are no longer picked up. Sometimes an error message is emitted and sometimes not
  • Headscale needs to be restarted for the filewatcher to work again

This behavior can be triggered reliably with:

mv extra.json .headscale-dns/extra.json 

which yields:

2024-12-14T17:47:51+01:00 TRC ../runner/work/headscale/headscale/hscontrol/dns/extrarecords.go:87 > extra records received filewatch event op=CHMOD path=.headscale-dns/extra.json
2024-12-14T17:47:51+01:00 TRC ../runner/work/headscale/headscale/hscontrol/dns/extrarecords.go:134 > extra records updated from path, count old: 1, new: 1 records=[{"Name":"grafana.myvpn.example.com","Type":"A","Value":"100.64.0.1"}]
2024-12-14T17:47:51+01:00 TRC ../runner/work/headscale/headscale/hscontrol/dns/extrarecords.go:87 > extra records received filewatch event op=REMOVE path=.headscale-dns/extra.json

After that, changes to the file are no longer picked up.

Environment

- OS: Arch
- Headscale version: 0.24.0-beta.1
- Tailscale version: -

Runtime environment

  • Headscale is behind a (reverse) proxy
  • Headscale runs in a container

Anything else?

No response

Originally created by @nblock on GitHub (Dec 14, 2024). ### Is this a support request? - [X] This is not a support request ### Is there an existing issue for this? - [X] I have searched the existing issues ### Current Behavior A read-edit-write cycle (with vim) causes headscale to lose track of the path in `dns.extra_records_path`. ### Expected Behavior Pickup changes made to the file. Headscale logs detected writes with `log.level: trace` when different versions of the config file are written. The sequence: ```bash cp extra1.json .headscale-dns/extra.json cp extra2.json .headscale-dns/extra.json cp extra2.json .headscale-dns/extra.json # no changes, OK ``` yields (fine) ``` 2024-12-14T16:39:47+01:00 TRC ../runner/work/headscale/headscale/hscontrol/dns/extrarecords.go:87 > extra records received filewatch event op=WRITE path=.headscale-dns/extra.json 2024-12-14T16:39:47+01:00 TRC ../runner/work/headscale/headscale/hscontrol/dns/extrarecords.go:134 > extra records updated from path, count old: 1, new: 1 records=[{"Name":"grafana.myvpn.example.com","Type":"A","Value":"100.64.0.1"}] 2024-12-14T16:39:56+01:00 TRC ../runner/work/headscale/headscale/hscontrol/dns/extrarecords.go:87 > extra records received filewatch event op=WRITE path=.headscale-dns/extra.json 2024-12-14T16:39:56+01:00 TRC ../runner/work/headscale/headscale/hscontrol/dns/extrarecords.go:134 > extra records updated from path, count old: 1, new: 1 records=[{"Name":"grafana.myvpn.example.com","Type":"A","Value":"100.64.0.2"}] 2024-12-14T16:40:01+01:00 TRC ../runner/work/headscale/headscale/hscontrol/dns/extrarecords.go:87 > extra records received filewatch event op=WRITE path=.headscale-dns/extra.json ``` ### Steps To Reproduce The following causes headscale to loose track of the file: ```bash vim .headscale-dns/extra.json # make some valid changes and save ``` yields sometimes: ``` 2024-12-14T16:50:21+01:00 TRC ../runner/work/headscale/headscale/hscontrol/dns/extrarecords.go:87 > extra records received filewatch event op=RENAME path=.headscale-dns/extra.json 2024-12-14T16:50:21+01:00 ERR ../runner/work/headscale/headscale/hscontrol/dns/extrarecords.go:115 > reading extra records from path: .headscale-dns/extra.json error="reading path: .headscale-dns/extra.json, err: open .headscale-dns/extra.json: no such file or directory" ``` and yield sometimes: ``` 2024-12-14T16:51:45+01:00 TRC ../runner/work/headscale/headscale/hscontrol/dns/extrarecords.go:87 > extra records received filewatch event op=RENAME path=.headscale-dns/extra.json 2024-12-14T16:51:45+01:00 TRC ../runner/work/headscale/headscale/hscontrol/dns/extrarecords.go:134 > extra records updated from path, count old: 1, new: 1 records=[{"Name":"grafana.myvpn.example.com","Type":"A","Value":"100.64.0.7"}] ``` Result is always the same: * Headscale no longer sends DNS updates to nodes - a query yields stale results * Changes to the file are no longer picked up. Sometimes an error message is emitted and sometimes not * Headscale needs to be restarted for the filewatcher to work again --- This behavior can be triggered reliably with: ```bash mv extra.json .headscale-dns/extra.json ``` which yields: ``` 2024-12-14T17:47:51+01:00 TRC ../runner/work/headscale/headscale/hscontrol/dns/extrarecords.go:87 > extra records received filewatch event op=CHMOD path=.headscale-dns/extra.json 2024-12-14T17:47:51+01:00 TRC ../runner/work/headscale/headscale/hscontrol/dns/extrarecords.go:134 > extra records updated from path, count old: 1, new: 1 records=[{"Name":"grafana.myvpn.example.com","Type":"A","Value":"100.64.0.1"}] 2024-12-14T17:47:51+01:00 TRC ../runner/work/headscale/headscale/hscontrol/dns/extrarecords.go:87 > extra records received filewatch event op=REMOVE path=.headscale-dns/extra.json ``` After that, changes to the file are no longer picked up. ### Environment ```markdown - OS: Arch - Headscale version: 0.24.0-beta.1 - Tailscale version: - ``` ### Runtime environment - [ ] Headscale is behind a (reverse) proxy - [ ] Headscale runs in a container ### Anything else? _No response_
adam added the bugDNS labels 2025-12-29 02:25:10 +01:00
adam closed this issue 2025-12-29 02:25:10 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/headscale#879