google / seesaw

Seesaw v2 is a Linux Virtual Server (LVS) based load balancing platform.
Apache License 2.0
5.63k stars 511 forks source link

Exit seesaw_ha quickly after seesaw_engine exits #78

Closed liuyuan10 closed 4 years ago

liuyuan10 commented 4 years ago

seesaw_engine may exits in two cases:

  1. seesaw_engine triggers os.Exit. This is common whenever log.Fatal/Exit is called.
  2. SIGTERM is received.

In both cases seesaw_ha may still keep announcing as master which causes traffic disruption.

This commit fixes this by watching seesaw engine socket file in seesaw_ha:

  1. os.Exit doesn't clean up so engine socket file is not removed. But all ipvs services keep working until a new seesaw_engine instance wipes out previous config. So we remove leftover engine socket file first thing to exit seesaw_ha before wipe out.
  2. SIGTERM will be handled gracefully and engine socket is removed before exiting. seesaw_ha will notice the deletion and exit together.