Skip to content

Commit

Permalink
kubernetes: fix, test GetNodes
Browse files Browse the repository at this point in the history
Broken in my cleanup golang.org/cl/36692

Change-Id: I5f82314b8ff703cf2c894771fbc0eb16834fc47b
Reviewed-on: https://go-review.googlesource.com/37216
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
  • Loading branch information
bradfitz committed Feb 17, 2017
1 parent b8aa0be commit c5562d0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion kubernetes/client.go
Expand Up @@ -429,7 +429,7 @@ func (c *Client) PodLog(ctx context.Context, podName string) (string, error) {
// PodNodes returns the list of nodes that comprise the Kubernetes cluster
func (c *Client) GetNodes(ctx context.Context) ([]api.Node, error) {
var list api.NodeList
if err := c.do(ctx, "GET", c.nsEndpoint()+"nodes", &list); err != nil {
if err := c.do(ctx, "GET", c.endpointURL+"/nodes", &list); err != nil {
return nil, err
}
return list.Items, nil
Expand Down
16 changes: 16 additions & 0 deletions kubernetes/gke/gke_test.go
Expand Up @@ -150,3 +150,19 @@ func foreachCluster(t *testing.T, fn func(*container.Cluster, *kubernetes.Client
kc.Close()
}
}

func TestGetNodes(t *testing.T) {
var passed bool
ctx := context.Background()
foreachCluster(t, func(cl *container.Cluster, kc *kubernetes.Client) {
if passed {
return
}
nodes, err := kc.GetNodes(ctx)
if err != nil {
t.Fatal(err)
}
t.Logf("%d nodes in cluster %s", len(nodes), cl.Name)
passed = true
})
}

0 comments on commit c5562d0

Please sign in to comment.