Skip to content

Commit

Permalink
Add tunneling mode healthcheck in config.proto
Browse files Browse the repository at this point in the history
This is to allow healthcheck to happen through ipvs tunneling mode.
  • Loading branch information
unicell committed Jun 26, 2020
1 parent 7bed913 commit 4a6c732
Show file tree
Hide file tree
Showing 6 changed files with 179 additions and 128 deletions.
3 changes: 3 additions & 0 deletions common/seesaw/seesaw.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ type HealthcheckMode int
const (
HCModePlain HealthcheckMode = iota
HCModeDSR
HCModeTUN
)

// String returns the name for a given HealthcheckMode.
Expand All @@ -124,6 +125,8 @@ func (h HealthcheckMode) String() string {
return "PLAIN"
case HCModeDSR:
return "DSR"
case HCModeTUN:
return "TUN"
default:
return "(unknown)"
}
Expand Down
2 changes: 2 additions & 0 deletions engine/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,8 @@ func protoToHealthcheck(p *pb.Healthcheck, defaultPort uint16) *Healthcheck {
hcMode = seesaw.HCModePlain
case pb.Healthcheck_DSR:
hcMode = seesaw.HCModeDSR
case pb.Healthcheck_TUN:
hcMode = seesaw.HCModeTUN
}
var hcType seesaw.HealthcheckType
switch p.GetType() {
Expand Down
28 changes: 26 additions & 2 deletions engine/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -566,8 +566,32 @@ var vserverTests = []struct {
Healthchecks: make(map[string]*Healthcheck),
},
},
Backends: make(map[string]*seesaw.Backend),
Healthchecks: make(map[string]*Healthcheck),
Backends: map[string]*seesaw.Backend{
"gateway1-1.example.com.": {
Host: seesaw.Host{
Hostname: "gateway1-1.example.com.",
IPv4Addr: net.ParseIP("192.168.36.2").To4(),
IPv4Mask: net.CIDRMask(26, 32),
},
Weight: 5,
Enabled: true,
InService: true,
},
},
Healthchecks: map[string]*Healthcheck{
"HTTP/8001_0": {
Name: "HTTP/8001_0",
Mode: seesaw.HCModeTUN,
Type: seesaw.HCTypeHTTP,
Port: 8001,
Interval: time.Duration(10 * time.Second), // protobuf default
Timeout: time.Duration(5 * time.Second), // protobuf default
TLSVerify: false,
Send: "/healthz",
Receive: "Ok",
Code: 200,
},
},
VIPs: map[string]*seesaw.VIP{
"192.168.36.1 (Unicast)": {
IP: seesaw.NewIP(net.ParseIP("192.168.36.1")),
Expand Down
17 changes: 17 additions & 0 deletions engine/config/testdata/vservers2.pb
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,21 @@ vserver <
scheduler: MH
mode: TUN
>
backend: <
host: <
fqdn: "gateway1-1.example.com."
ipv4: "192.168.36.2/26"
status: PRODUCTION
>
weight: 5
>
healthcheck <
type: HTTP
port: 8001
send: "/healthz"
receive: "Ok"
code: 200
tls_verify: false
mode: TUN
>
>
Loading

0 comments on commit 4a6c732

Please sign in to comment.