metal-stack / metal-api

API to manage and control plane resources like machines, switches, operating system images, machine sizes, networks, IP addresses and more
GNU Affero General Public License v3.0
128 stars 9 forks source link

Headscale service initialization problems #499

Closed Gerrit91 closed 7 months ago

Gerrit91 commented 7 months ago

Found through GKE log console that this can happen:

 panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x13b6cfe]

goroutine 1 [running]:
github.com/metal-stack/metal-api/cmd/metal-api/internal/headscale.(*HeadscaleClient).MachinesConnected(0x0, {0x1d3a090, 0xc0005f2cb0})
    /home/runner/work/metal-api/metal-api/cmd/metal-api/internal/headscale/client.go:122 +0x3e
main.evaluateVPNConnected()
    /home/runner/work/metal-api/metal-api/cmd/metal-api/main.go:893 +0xb5 

I saw in the code that we just log an error if the connection to headscale cannot be established. But then we could have metal-api replicas after an rolling update which have no headscale client initialized and these will consistently panic on all headscale endpoints.