Skip to content
This repository was archived by the owner on Apr 17, 2019. It is now read-only.

Commit 06674d3

Browse files
committed
Get rid of default-zone everywhere.
1 parent 99deb71 commit 06674d3

File tree

6 files changed

+21
-15
lines changed

6 files changed

+21
-15
lines changed

ingress/controllers/gce/backends/backends_test.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,12 @@ import (
2727
"k8s.io/kubernetes/pkg/util/sets"
2828
)
2929

30+
const defaultZone = "zone-a"
31+
3032
func newBackendPool(f BackendServices, fakeIGs instances.InstanceGroups, syncWithCloud bool) BackendPool {
3133
namer := &utils.Namer{}
32-
nodePool := instances.NewNodePool(fakeIGs, "default-zone")
33-
nodePool.Init(&instances.FakeZoneLister{[]string{"zone-a"}})
34+
nodePool := instances.NewNodePool(fakeIGs)
35+
nodePool.Init(&instances.FakeZoneLister{[]string{defaultZone}})
3436
healthChecks := healthchecks.NewHealthChecker(healthchecks.NewFakeHealthChecks(), "/", namer)
3537
healthChecks.Init(&healthchecks.FakeHealthCheckGetter{nil})
3638
return NewBackendPool(
@@ -82,8 +84,14 @@ func TestBackendPoolAdd(t *testing.T) {
8284
t.Fatalf("Unexpected create for existing backend service")
8385
}
8486
}
85-
gotBackend, _ := f.GetBackendService(beName)
86-
gotGroup, _ := fakeIGs.GetInstanceGroup(namer.IGName(), "default-zone")
87+
gotBackend, err := f.GetBackendService(beName)
88+
if err != nil {
89+
t.Fatalf("Failed to find a backend with name %v: %v", beName, err)
90+
}
91+
gotGroup, err := fakeIGs.GetInstanceGroup(namer.IGName(), defaultZone)
92+
if err != nil {
93+
t.Fatalf("Failed to find instance group %v", namer.IGName())
94+
}
8795
if gotBackend.Backends[0].Group != gotGroup.SelfLink {
8896
t.Fatalf(
8997
"Broken instance group link: %v %v",

ingress/controllers/gce/controller/cluster_manager.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -261,13 +261,9 @@ func NewClusterManager(
261261

262262
// Names are fundamental to the cluster, the uid allocator makes sure names don't collide.
263263
cluster := ClusterManager{ClusterNamer: &utils.Namer{name}}
264-
zone, err := cloud.GetZone()
265-
if err != nil {
266-
return nil, err
267-
}
268264

269265
// NodePool stores GCE vms that are in this Kubernetes cluster.
270-
cluster.instancePool = instances.NewNodePool(cloud, zone.FailureDomain)
266+
cluster.instancePool = instances.NewNodePool(cloud)
271267

272268
// BackendPool creates GCE BackendServices and associated health checks.
273269
healthChecker := healthchecks.NewHealthChecker(cloud, defaultHealthCheckPath, cluster.ClusterNamer)

ingress/controllers/gce/controller/fakes.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func NewFakeClusterManager(clusterName string) *fakeClusterManager {
5050
fakeHCs := healthchecks.NewFakeHealthChecks()
5151
namer := &utils.Namer{clusterName}
5252

53-
nodePool := instances.NewNodePool(fakeIGs, defaultZone)
53+
nodePool := instances.NewNodePool(fakeIGs)
5454
nodePool.Init(&instances.FakeZoneLister{[]string{"zone-a"}})
5555

5656
healthChecker := healthchecks.NewHealthChecker(fakeHCs, "/", namer)

ingress/controllers/gce/instances/instances.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ type Instances struct {
4646
// NewNodePool creates a new node pool.
4747
// - cloud: implements InstanceGroups, used to sync Kubernetes nodes with
4848
// members of the cloud InstanceGroup.
49-
func NewNodePool(cloud InstanceGroups, defaultZone string) NodePool {
49+
func NewNodePool(cloud InstanceGroups) NodePool {
5050
return &Instances{cloud, storage.NewInMemoryPool(), nil}
5151
}
5252

@@ -146,6 +146,8 @@ func (i *Instances) Get(name, zone string) (*compute.InstanceGroup, error) {
146146
return ig, nil
147147
}
148148

149+
// splitNodesByZones takes a list of node names and returns a map of zone:node names.
150+
// It figures out the zones by asking the zoneLister.
149151
func (i *Instances) splitNodesByZone(names []string) map[string][]string {
150152
nodesByZone := map[string][]string{}
151153
for _, name := range names {

ingress/controllers/gce/instances/instances_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525
const defaultZone = "default-zone"
2626

2727
func newNodePool(f *FakeInstanceGroups, zone string) NodePool {
28-
pool := NewNodePool(f, zone)
28+
pool := NewNodePool(f)
2929
pool.Init(&FakeZoneLister{[]string{zone}})
3030
return pool
3131
}

ingress/controllers/gce/loadbalancers/loadbalancers_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import (
2929

3030
const (
3131
testDefaultBeNodePort = int64(3000)
32-
defaultZone = "default-zone"
32+
defaultZone = "zone-a"
3333
)
3434

3535
func newFakeLoadBalancerPool(f LoadBalancers, t *testing.T) LoadBalancerPool {
@@ -39,8 +39,8 @@ func newFakeLoadBalancerPool(f LoadBalancers, t *testing.T) LoadBalancerPool {
3939
namer := &utils.Namer{}
4040
healthChecker := healthchecks.NewHealthChecker(fakeHCs, "/", namer)
4141
healthChecker.Init(&healthchecks.FakeHealthCheckGetter{nil})
42-
nodePool := instances.NewNodePool(fakeIGs, defaultZone)
43-
nodePool.Init(&instances.FakeZoneLister{[]string{"zone-a"}})
42+
nodePool := instances.NewNodePool(fakeIGs)
43+
nodePool.Init(&instances.FakeZoneLister{[]string{defaultZone}})
4444
backendPool := backends.NewBackendPool(
4545
fakeBackends, healthChecker, nodePool, namer, []int64{}, false)
4646
return NewLoadBalancerPool(f, backendPool, testDefaultBeNodePort, namer)

0 commit comments

Comments
 (0)