Fix the rest of the code

This commit is contained in:
Clayton Coleman
2016-04-27 00:35:14 -04:00
parent 8d0187add2
commit fdb110c859
129 changed files with 625 additions and 663 deletions

View File

@@ -330,7 +330,7 @@ func CleanupLeftovers(ipt utiliptables.Interface) (encounteredError bool) {
}
func (proxier *Proxier) sameConfig(info *serviceInfo, service *api.Service, port *api.ServicePort) bool {
if info.protocol != port.Protocol || info.port != port.Port || info.nodePort != port.NodePort {
if info.protocol != port.Protocol || info.port != int(port.Port) || info.nodePort != int(port.NodePort) {
return false
}
if !info.clusterIP.Equal(net.ParseIP(service.Spec.ClusterIP)) {
@@ -426,9 +426,9 @@ func (proxier *Proxier) OnServiceUpdate(allServices []api.Service) {
glog.V(1).Infof("Adding new service %q at %s:%d/%s", serviceName, serviceIP, servicePort.Port, servicePort.Protocol)
info = newServiceInfo(serviceName)
info.clusterIP = serviceIP
info.port = servicePort.Port
info.port = int(servicePort.Port)
info.protocol = servicePort.Protocol
info.nodePort = servicePort.NodePort
info.nodePort = int(servicePort.NodePort)
info.externalIPs = service.Spec.ExternalIPs
// Deep-copy in case the service instance changes
info.loadBalancerStatus = *api.LoadBalancerStatusDeepCopy(&service.Status.LoadBalancer)
@@ -483,7 +483,7 @@ func (proxier *Proxier) OnEndpointsUpdate(allEndpoints []api.Endpoints) {
port := &ss.Ports[i]
for i := range ss.Addresses {
addr := &ss.Addresses[i]
portsToEndpoints[port.Name] = append(portsToEndpoints[port.Name], hostPortPair{addr.IP, port.Port})
portsToEndpoints[port.Name] = append(portsToEndpoints[port.Name], hostPortPair{addr.IP, int(port.Port)})
}
}
}

View File

@@ -419,11 +419,11 @@ func (proxier *Proxier) OnServiceUpdate(services []api.Service) {
continue
}
info.portal.ip = serviceIP
info.portal.port = servicePort.Port
info.portal.port = int(servicePort.Port)
info.externalIPs = service.Spec.ExternalIPs
// Deep-copy in case the service instance changes
info.loadBalancerStatus = *api.LoadBalancerStatusDeepCopy(&service.Status.LoadBalancer)
info.nodePort = servicePort.NodePort
info.nodePort = int(servicePort.NodePort)
info.sessionAffinityType = service.Spec.SessionAffinity
glog.V(4).Infof("info: %+v", info)
@@ -452,7 +452,7 @@ func (proxier *Proxier) OnServiceUpdate(services []api.Service) {
}
func sameConfig(info *serviceInfo, service *api.Service, port *api.ServicePort) bool {
if info.protocol != port.Protocol || info.portal.port != port.Port || info.nodePort != port.NodePort {
if info.protocol != port.Protocol || info.portal.port != int(port.Port) || info.nodePort != int(port.NodePort) {
return false
}
if !info.portal.ip.Equal(net.ParseIP(service.Spec.ClusterIP)) {

View File

@@ -82,8 +82,8 @@ func waitForClosedPortUDP(p *Proxier, proxyPort int) error {
return fmt.Errorf("port %d still open", proxyPort)
}
var tcpServerPort int
var udpServerPort int
var tcpServerPort int32
var udpServerPort int32
func init() {
// Don't handle panics
@@ -103,10 +103,11 @@ func init() {
if err != nil {
panic(fmt.Sprintf("failed to parse: %v", err))
}
tcpServerPort, err = strconv.Atoi(port)
tcpServerPortValue, err := strconv.Atoi(port)
if err != nil {
panic(fmt.Sprintf("failed to atoi(%s): %v", port, err))
}
tcpServerPort = int32(tcpServerPortValue)
// UDP setup.
udp, err := newUDPEchoServer()
@@ -117,10 +118,11 @@ func init() {
if err != nil {
panic(fmt.Sprintf("failed to parse: %v", err))
}
udpServerPort, err = strconv.Atoi(port)
udpServerPortValue, err := strconv.Atoi(port)
if err != nil {
panic(fmt.Sprintf("failed to atoi(%s): %v", port, err))
}
udpServerPort = int32(udpServerPortValue)
go udp.Loop()
}
@@ -564,7 +566,7 @@ func TestTCPProxyUpdateDeleteUpdate(t *testing.T) {
ObjectMeta: api.ObjectMeta{Name: service.Name, Namespace: service.Namespace},
Spec: api.ServiceSpec{ClusterIP: "1.2.3.4", Ports: []api.ServicePort{{
Name: "p",
Port: svcInfo.proxyPort,
Port: int32(svcInfo.proxyPort),
Protocol: "TCP",
}}},
}})
@@ -616,7 +618,7 @@ func TestUDPProxyUpdateDeleteUpdate(t *testing.T) {
ObjectMeta: api.ObjectMeta{Name: service.Name, Namespace: service.Namespace},
Spec: api.ServiceSpec{ClusterIP: "1.2.3.4", Ports: []api.ServicePort{{
Name: "p",
Port: svcInfo.proxyPort,
Port: int32(svcInfo.proxyPort),
Protocol: "UDP",
}}},
}})
@@ -752,7 +754,7 @@ func TestProxyUpdatePublicIPs(t *testing.T) {
Spec: api.ServiceSpec{
Ports: []api.ServicePort{{
Name: "p",
Port: svcInfo.portal.port,
Port: int32(svcInfo.portal.port),
Protocol: "TCP",
}},
ClusterIP: svcInfo.portal.ip.String(),
@@ -803,7 +805,7 @@ func TestProxyUpdatePortal(t *testing.T) {
ObjectMeta: api.ObjectMeta{Name: service.Name, Namespace: service.Namespace},
Spec: api.ServiceSpec{ClusterIP: "", Ports: []api.ServicePort{{
Name: "p",
Port: svcInfo.proxyPort,
Port: int32(svcInfo.proxyPort),
Protocol: "TCP",
}}},
}})
@@ -816,7 +818,7 @@ func TestProxyUpdatePortal(t *testing.T) {
ObjectMeta: api.ObjectMeta{Name: service.Name, Namespace: service.Namespace},
Spec: api.ServiceSpec{ClusterIP: "None", Ports: []api.ServicePort{{
Name: "p",
Port: svcInfo.proxyPort,
Port: int32(svcInfo.proxyPort),
Protocol: "TCP",
}}},
}})
@@ -829,7 +831,7 @@ func TestProxyUpdatePortal(t *testing.T) {
ObjectMeta: api.ObjectMeta{Name: service.Name, Namespace: service.Namespace},
Spec: api.ServiceSpec{ClusterIP: "1.2.3.4", Ports: []api.ServicePort{{
Name: "p",
Port: svcInfo.proxyPort,
Port: int32(svcInfo.proxyPort),
Protocol: "TCP",
}}},
}})

View File

@@ -244,7 +244,7 @@ func (lb *LoadBalancerRR) OnEndpointsUpdate(allEndpoints []api.Endpoints) {
port := &ss.Ports[i]
for i := range ss.Addresses {
addr := &ss.Addresses[i]
portsToEndpoints[port.Name] = append(portsToEndpoints[port.Name], hostPortPair{addr.IP, port.Port})
portsToEndpoints[port.Name] = append(portsToEndpoints[port.Name], hostPortPair{addr.IP, int(port.Port)})
// Ignore the protocol field - we'll get that from the Service objects.
}
}