github / glb-director

GitHub Load Balancer Director and supporting tooling.
Other
2.38k stars 229 forks source link

XDP: Allow graceful reload of service. #99

Closed theojulienne closed 4 years ago

theojulienne commented 4 years ago

This PR adds graceful reload support to the XDP implementation. This is implemented by exec-ing an entire new copy of the XDP process, which replaces the program in the hot path, then signals (via the same notify socket style as systemd) that it's ready for the old pid to exit.

There's also some whitespace fixes due to a previously missing go fmt run.

The reload looks like this, note the messages printed which show the ordering of when the previous version exits:

Mar 31 20:42:24 glb-director-blah.example.net systemd[1]: Starting GLB Director XDP...
Mar 31 20:42:24 glb-director-blah.example.net sh[19135]: Got gateway MAC: 00:11:22:33:44:55 [00:11:22:33:44:55]
Mar 31 20:42:24 glb-director-blah.example.net sh[19135]: Got source IP: 10.10.10.10 [10.10.10.10]
Mar 31 20:42:24 glb-director-blah.example.net sh[19135]: {"timestamp": 1585712544.4408374, "level": "info", "message": "glb-config loading with size 24"}
Mar 31 20:42:24 glb-director-blah.example.net sh[19135]: {"timestamp": 1585712544.4409134, "level": "info", "message": "glb-config raw config loaded, validating..."}
Mar 31 20:42:24 glb-director-blah.example.net sh[19135]: Loaded forwarding table version=2
Mar 31 20:42:24 glb-director-blah.example.net sh[19135]:   num_tables=0
Mar 31 20:42:24 glb-director-blah.example.net sh[19135]:   table_entries=65536
Mar 31 20:42:24 glb-director-blah.example.net sh[19135]:   max_num_backends=256
Mar 31 20:42:24 glb-director-blah.example.net sh[19135]:   max_num_binds=256
Mar 31 20:42:24 glb-director-blah.example.net systemd[1]: Started GLB Director XDP.
Mar 31 20:42:39 glb-director-blah.example.net systemd[1]: Reloading GLB Director XDP.
Mar 31 20:42:39 glb-director-blah.example.net sh[19135]: Reloading by exec-ing a new version of glb-director-xdp
Mar 31 20:42:39 glb-director-blah.example.net systemd[1]: Reloaded GLB Director XDP.
Mar 31 20:42:39 glb-director-blah.example.net sh[19135]: New version of glb-director-xdp launched, waiting for READY signal...
Mar 31 20:42:39 glb-director-blah.example.net sh[19135]: Got gateway MAC: 00:11:22:33:44:55 [00:11:22:33:44:55]
Mar 31 20:42:39 glb-director-blah.example.net sh[19135]: Got source IP: 10.10.10.10 [10.10.10.10]
Mar 31 20:42:39 glb-director-blah.example.net sh[19135]: {"timestamp": 1585712559.8043571, "level": "info", "message": "glb-config loading with size 24"}
Mar 31 20:42:39 glb-director-blah.example.net sh[19135]: {"timestamp": 1585712559.8044207, "level": "info", "message": "glb-config raw config loaded, validating..."}
Mar 31 20:42:39 glb-director-blah.example.net sh[19135]: Loaded forwarding table version=2
Mar 31 20:42:39 glb-director-blah.example.net sh[19135]:   num_tables=0
Mar 31 20:42:39 glb-director-blah.example.net sh[19135]:   table_entries=65536
Mar 31 20:42:39 glb-director-blah.example.net sh[19135]:   max_num_backends=256
Mar 31 20:42:39 glb-director-blah.example.net sh[19135]:   max_num_binds=256
Mar 31 20:42:39 glb-director-blah.example.net sh[19135]: New process is READY, goodbye!