MCPcopy
hub / github.com/google/seesaw / updateState

Method updateState

engine/vserver.go:1163–1190  ·  view source on GitHub ↗

updateState updates the state of an IP for a vserver based on the state of that IP's services.

(ip seesaw.IP)

Source from the content-addressed store, hash-verified

1161// updateState updates the state of an IP for a vserver based on the state of
1162// that IP's services.
1163func (v *vserver) updateState(ip seesaw.IP) {
1164 // A vserver anycast IP is healthy if *all* services for that IP are healthy.
1165 // A vserver unicast IP is healthy if *any* services for that IP are healthy.
1166 var healthy bool
1167 for _, s := range v.services {
1168 if !s.ip.Equal(ip) {
1169 continue
1170 }
1171 healthy = s.healthy
1172 if !healthy && seesaw.IsAnycast(ip.IP()) {
1173 break
1174 }
1175 if healthy && !seesaw.IsAnycast(ip.IP()) {
1176 break
1177 }
1178 }
1179
1180 if v.active[ip] == healthy {
1181 v.updateServices(ip)
1182 return
1183 }
1184 switch {
1185 case !healthy && v.active[ip]:
1186 v.down(ip)
1187 case healthy && !v.active[ip]:
1188 v.up(ip)
1189 }
1190}
1191
1192// updateServices brings the services for a vserver up or down based on the
1193// state of the vserver and the health of each service.

Callers 2

configUpdateMethod · 0.95
deleteServiceMethod · 0.95

Calls 6

updateServicesMethod · 0.95
downMethod · 0.95
upMethod · 0.95
IsAnycastFunction · 0.92
EqualMethod · 0.45
IPMethod · 0.45

Tested by

no test coverage detected