mirror of
https://github.com/tailscale/tailscale.git
synced 2025-02-28 19:27:41 +00:00
cmd/containerboot: fix nil pointer exception (#15090)
Updates tailscale/tailscale#15081 Signed-off-by: Irbe Krumina <irbe@tailscale.com>
This commit is contained in:
parent
b85d18d14e
commit
6df0aa58bb
@ -35,6 +35,8 @@ func watchServeConfigChanges(ctx context.Context, path string, cdChanged <-chan
|
|||||||
var tickChan <-chan time.Time
|
var tickChan <-chan time.Time
|
||||||
var eventChan <-chan fsnotify.Event
|
var eventChan <-chan fsnotify.Event
|
||||||
if w, err := fsnotify.NewWatcher(); err != nil {
|
if w, err := fsnotify.NewWatcher(); err != nil {
|
||||||
|
// Creating a new fsnotify watcher would fail for example if inotify was not able to create a new file descriptor.
|
||||||
|
// See https://github.com/tailscale/tailscale/issues/15081
|
||||||
log.Printf("serve proxy: failed to create fsnotify watcher, timer-only mode: %v", err)
|
log.Printf("serve proxy: failed to create fsnotify watcher, timer-only mode: %v", err)
|
||||||
ticker := time.NewTicker(5 * time.Second)
|
ticker := time.NewTicker(5 * time.Second)
|
||||||
defer ticker.Stop()
|
defer ticker.Stop()
|
||||||
|
@ -173,11 +173,14 @@ func tailscaleSet(ctx context.Context, cfg *settings) error {
|
|||||||
func watchTailscaledConfigChanges(ctx context.Context, path string, lc *local.Client, errCh chan<- error) {
|
func watchTailscaledConfigChanges(ctx context.Context, path string, lc *local.Client, errCh chan<- error) {
|
||||||
var (
|
var (
|
||||||
tickChan <-chan time.Time
|
tickChan <-chan time.Time
|
||||||
|
eventChan <-chan fsnotify.Event
|
||||||
|
errChan <-chan error
|
||||||
tailscaledCfgDir = filepath.Dir(path)
|
tailscaledCfgDir = filepath.Dir(path)
|
||||||
prevTailscaledCfg []byte
|
prevTailscaledCfg []byte
|
||||||
)
|
)
|
||||||
w, err := fsnotify.NewWatcher()
|
if w, err := fsnotify.NewWatcher(); err != nil {
|
||||||
if err != nil {
|
// Creating a new fsnotify watcher would fail for example if inotify was not able to create a new file descriptor.
|
||||||
|
// See https://github.com/tailscale/tailscale/issues/15081
|
||||||
log.Printf("tailscaled config watch: failed to create fsnotify watcher, timer-only mode: %v", err)
|
log.Printf("tailscaled config watch: failed to create fsnotify watcher, timer-only mode: %v", err)
|
||||||
ticker := time.NewTicker(5 * time.Second)
|
ticker := time.NewTicker(5 * time.Second)
|
||||||
defer ticker.Stop()
|
defer ticker.Stop()
|
||||||
@ -188,6 +191,8 @@ func watchTailscaledConfigChanges(ctx context.Context, path string, lc *local.Cl
|
|||||||
errCh <- fmt.Errorf("failed to add fsnotify watch: %w", err)
|
errCh <- fmt.Errorf("failed to add fsnotify watch: %w", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
eventChan = w.Events
|
||||||
|
errChan = w.Errors
|
||||||
}
|
}
|
||||||
b, err := os.ReadFile(path)
|
b, err := os.ReadFile(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -205,11 +210,11 @@ func watchTailscaledConfigChanges(ctx context.Context, path string, lc *local.Cl
|
|||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
return
|
return
|
||||||
case err := <-w.Errors:
|
case err := <-errChan:
|
||||||
errCh <- fmt.Errorf("watcher error: %w", err)
|
errCh <- fmt.Errorf("watcher error: %w", err)
|
||||||
return
|
return
|
||||||
case <-tickChan:
|
case <-tickChan:
|
||||||
case event := <-w.Events:
|
case event := <-eventChan:
|
||||||
if event.Name != toWatch {
|
if event.Name != toWatch {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user