Merge pull request #258 from lavalamp/misc_cleanup

Use net.JoinHostPort
This commit is contained in:
brendandburns 2014-06-26 18:56:52 -07:00
commit ccc04336af
3 changed files with 11 additions and 6 deletions

View File

@ -21,6 +21,7 @@ import (
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"math/rand" "math/rand"
"net"
"net/http" "net/http"
"os" "os"
"os/exec" "os/exec"
@ -128,8 +129,7 @@ func (kl *Kubelet) RunKubelet(config_path, manifest_url, etcd_servers, address s
UpdateChannel: updateChannel, UpdateChannel: updateChannel,
} }
s := &http.Server{ s := &http.Server{
// TODO: This is broken if address is an ipv6 address. Addr: net.JoinHostPort(address, strconv.FormatUint(uint64(port), 10)),
Addr: fmt.Sprintf("%s:%d", address, port),
Handler: &handler, Handler: &handler,
ReadTimeout: 10 * time.Second, ReadTimeout: 10 * time.Second,
WriteTimeout: 10 * time.Second, WriteTimeout: 10 * time.Second,

View File

@ -898,8 +898,9 @@ func TestWatchEtcd(t *testing.T) {
close(updateChannel) close(updateChannel)
read := reader.GetList() read := reader.GetList()
if len(read) != 1 || if len(read) != 1 {
!reflect.DeepEqual(read[0], manifest) { t.Errorf("Expected number of results: %v", len(read))
} else if !reflect.DeepEqual(read[0], manifest) {
t.Errorf("Unexpected manifest(s) %#v %#v", read[0], manifest) t.Errorf("Unexpected manifest(s) %#v %#v", read[0], manifest)
} }
} }

View File

@ -17,7 +17,8 @@ limitations under the License.
package registry package registry
import ( import (
"fmt" "net"
"strconv"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
@ -52,7 +53,10 @@ func (e *EndpointController) SyncServiceEndpoints() error {
endpoints := make([]string, len(pods)) endpoints := make([]string, len(pods))
for ix, pod := range pods { for ix, pod := range pods {
// TODO: Use port names in the service object, don't just use port #0 // TODO: Use port names in the service object, don't just use port #0
endpoints[ix] = fmt.Sprintf("%s:%d", pod.CurrentState.Host, pod.DesiredState.Manifest.Containers[0].Ports[0].HostPort) endpoints[ix] = net.JoinHostPort(
pod.CurrentState.Host,
strconv.Itoa(pod.DesiredState.Manifest.Containers[0].Ports[0].HostPort),
)
} }
err = e.serviceRegistry.UpdateEndpoints(api.Endpoints{ err = e.serviceRegistry.UpdateEndpoints(api.Endpoints{
Name: service.ID, Name: service.ID,