Cleanup of several areas
This commit is contained in:
parent
26fccdc48b
commit
15a377c2ab
4 changed files with 29 additions and 12 deletions
|
@ -443,6 +443,7 @@ func (b *Backends) Status(name string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func applyLegacyHCToHC(existing *compute.HttpHealthCheck, hc *healthchecks.HealthCheck) {
|
func applyLegacyHCToHC(existing *compute.HttpHealthCheck, hc *healthchecks.HealthCheck) {
|
||||||
|
hc.Description = existing.Description
|
||||||
hc.CheckIntervalSec = existing.CheckIntervalSec
|
hc.CheckIntervalSec = existing.CheckIntervalSec
|
||||||
hc.HealthyThreshold = existing.HealthyThreshold
|
hc.HealthyThreshold = existing.HealthyThreshold
|
||||||
hc.Host = existing.Host
|
hc.Host = existing.Host
|
||||||
|
|
|
@ -63,7 +63,9 @@ func (i *Instances) Init(zl zoneLister) {
|
||||||
// all of which have the exact same named port.
|
// all of which have the exact same named port.
|
||||||
func (i *Instances) AddInstanceGroup(name string, port int64) ([]*compute.InstanceGroup, *compute.NamedPort, error) {
|
func (i *Instances) AddInstanceGroup(name string, port int64) ([]*compute.InstanceGroup, *compute.NamedPort, error) {
|
||||||
igs := []*compute.InstanceGroup{}
|
igs := []*compute.InstanceGroup{}
|
||||||
namedPort := &compute.NamedPort{}
|
namedPort := &compute.NamedPort{Name: fmt.Sprintf("port%v", port), Port: port}
|
||||||
|
|
||||||
|
defer i.snapshotter.Add(name, struct{}{})
|
||||||
|
|
||||||
zones, err := i.ListZones()
|
zones, err := i.ListZones()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -79,14 +81,25 @@ func (i *Instances) AddInstanceGroup(name string, port int64) ([]*compute.Instan
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
glog.V(3).Infof("Instance group %v already exists in zone %v, adding port %d to it", name, zone, port)
|
|
||||||
}
|
}
|
||||||
defer i.snapshotter.Add(name, struct{}{})
|
|
||||||
namedPort, err = i.cloud.AddPortToInstanceGroup(ig, port)
|
found := false
|
||||||
if err != nil {
|
for _, np := range ig.NamedPorts {
|
||||||
return nil, nil, err
|
if np.Name == namedPort.Name && np.Port == namedPort.Port {
|
||||||
|
glog.V(3).Infof("Instance group %v/%v already has named port %+v", zone, name, np)
|
||||||
|
found = true
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !found {
|
||||||
|
glog.V(3).Infof("Adding port %d to instance group %v/%v", port, zone, name)
|
||||||
|
namedPort, err = i.cloud.AddPortToInstanceGroup(ig, port)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
igs = append(igs, ig)
|
igs = append(igs, ig)
|
||||||
}
|
}
|
||||||
return igs, namedPort, nil
|
return igs, namedPort, nil
|
||||||
|
|
|
@ -163,7 +163,7 @@ func (l *L7s) Delete(name string) error {
|
||||||
|
|
||||||
// Sync loadbalancers with the given runtime info from the controller.
|
// Sync loadbalancers with the given runtime info from the controller.
|
||||||
func (l *L7s) Sync(lbs []*L7RuntimeInfo) error {
|
func (l *L7s) Sync(lbs []*L7RuntimeInfo) error {
|
||||||
glog.V(3).Infof("Creating loadbalancers %+v", lbs)
|
glog.V(3).Infof("Syncing loadbalancers %v", lbs)
|
||||||
|
|
||||||
if len(lbs) != 0 {
|
if len(lbs) != 0 {
|
||||||
// Lazily create a default backend so we don't tax users who don't care
|
// Lazily create a default backend so we don't tax users who don't care
|
||||||
|
@ -257,6 +257,11 @@ type L7RuntimeInfo struct {
|
||||||
StaticIPName string
|
StaticIPName string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// String returns the load balancer name
|
||||||
|
func (l *L7RuntimeInfo) String() string {
|
||||||
|
return l.Name
|
||||||
|
}
|
||||||
|
|
||||||
// L7 represents a single L7 loadbalancer.
|
// L7 represents a single L7 loadbalancer.
|
||||||
type L7 struct {
|
type L7 struct {
|
||||||
Name string
|
Name string
|
||||||
|
@ -757,7 +762,6 @@ func (l *L7) UpdateUrlMap(ingressRules utils.GCEURLMap) error {
|
||||||
if l.um == nil {
|
if l.um == nil {
|
||||||
return fmt.Errorf("cannot add url without an urlmap")
|
return fmt.Errorf("cannot add url without an urlmap")
|
||||||
}
|
}
|
||||||
glog.V(3).Infof("Updating urlmap for l7 %v", l.Name)
|
|
||||||
|
|
||||||
// All UrlMaps must have a default backend. If the Ingress has a default
|
// All UrlMaps must have a default backend. If the Ingress has a default
|
||||||
// backend, it applies to all host rules as well as to the urlmap itself.
|
// backend, it applies to all host rules as well as to the urlmap itself.
|
||||||
|
@ -807,7 +811,8 @@ func (l *L7) UpdateUrlMap(ingressRules utils.GCEURLMap) error {
|
||||||
glog.Infof("UrlMap for l7 %v is unchanged", l.Name)
|
glog.Infof("UrlMap for l7 %v is unchanged", l.Name)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
glog.Infof("Updating url map: %+v", ingressRules)
|
|
||||||
|
glog.V(3).Infof("Updating URLMap: %q", l.Name)
|
||||||
um, err := l.cloud.UpdateUrlMap(l.um)
|
um, err := l.cloud.UpdateUrlMap(l.um)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -191,7 +191,6 @@ func (n *Namer) ParseName(name string) *NameComponents {
|
||||||
// NameBelongsToCluster checks if a given name is tagged with this cluster's UID.
|
// NameBelongsToCluster checks if a given name is tagged with this cluster's UID.
|
||||||
func (n *Namer) NameBelongsToCluster(name string) bool {
|
func (n *Namer) NameBelongsToCluster(name string) bool {
|
||||||
if !strings.HasPrefix(name, "k8s-") {
|
if !strings.HasPrefix(name, "k8s-") {
|
||||||
glog.V(4).Infof("%v not part of cluster", name)
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
parts := strings.Split(name, clusterNameDelimiter)
|
parts := strings.Split(name, clusterNameDelimiter)
|
||||||
|
@ -203,7 +202,6 @@ func (n *Namer) NameBelongsToCluster(name string) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if len(parts) > 2 {
|
if len(parts) > 2 {
|
||||||
glog.Warningf("Too many parts to name %v, ignoring", name)
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return parts[1] == clusterName
|
return parts[1] == clusterName
|
||||||
|
|
Loading…
Reference in a new issue