up brings up all healthy services for an IP address for a vserver, then brings up the IP address.
(ip seesaw.IP)
| 1214 | // up brings up all healthy services for an IP address for a vserver, then |
| 1215 | // brings up the IP address. |
| 1216 | func (v *vserver) up(ip seesaw.IP) { |
| 1217 | ncc := v.ncc |
| 1218 | |
| 1219 | v.active[ip] = true |
| 1220 | v.updateServices(ip) |
| 1221 | |
| 1222 | // If this is an anycast VIP, start advertising a BGP route. |
| 1223 | nip := ip.IP() |
| 1224 | if seesaw.IsAnycast(nip) { |
| 1225 | // TODO(jsing): Create an LBVserver that only encapsulates |
| 1226 | // the necessary state, rather than storing a full vserver |
| 1227 | // snapshot. |
| 1228 | lbVserver := v.snapshot() |
| 1229 | lbVserver.Services = nil |
| 1230 | lbVserver.Warnings = nil |
| 1231 | if err := v.engine.lbInterface.AddVserver(lbVserver, ip.AF()); err != nil { |
| 1232 | log.Fatalf("%v: failed to add Vserver: %v", v, err) |
| 1233 | } |
| 1234 | v.lbVservers[ip] = lbVserver |
| 1235 | |
| 1236 | vip := seesaw.NewVIP(nip, nil) |
| 1237 | if err := v.engine.lbInterface.AddVIP(vip); err != nil { |
| 1238 | log.Fatalf("%v: failed to add VIP %v: %v", v, ip, err) |
| 1239 | } |
| 1240 | // TODO(angusc): Filter out anycast VIPs for non-anycast clusters further |
| 1241 | // upstream. |
| 1242 | if v.engine.config.AnycastEnabled { |
| 1243 | log.Infof("%v: advertising BGP route for %v", v, ip) |
| 1244 | if err := ncc.BGPAdvertiseVIP(nip); err != nil { |
| 1245 | log.Fatalf("%v: failed to advertise VIP %v: %v", v, ip, err) |
| 1246 | } |
| 1247 | } else { |
| 1248 | log.Warningf("%v: %v is an anycast VIP, but anycast is not enabled", v, ip) |
| 1249 | } |
| 1250 | } |
| 1251 | |
| 1252 | log.Infof("%v: VIP %v up", v, ip) |
| 1253 | } |
| 1254 | |
| 1255 | // downAll takes down all IP addresses and services for a vserver. |
| 1256 | func (v *vserver) downAll() { |
no test coverage detected