Skip to content

Commit

Permalink
Merge pull request #398 from rramkumar1/small-fixes
Browse files Browse the repository at this point in the history
Remove error return value from controller initialization
  • Loading branch information
nicksardo authored Jul 16, 2018
2 parents 50ce123 + 15222c2 commit f505c18
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 12 deletions.
4 changes: 2 additions & 2 deletions cmd/glbc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ func runControllers(ctx *context.ControllerContext) {
}

stopCh := make(chan struct{})
lbc, err := controller.NewLoadBalancerController(ctx, clusterManager, stopCh)
lbc := controller.NewLoadBalancerController(ctx, clusterManager, stopCh)
if err != nil {
glog.Fatalf("controller.NewLoadBalancerController(ctx, clusterManager, stopCh) = %v", err)
}
Expand All @@ -183,7 +183,7 @@ func runControllers(ctx *context.ControllerContext) {

if ctx.NEGEnabled {
// TODO: Refactor NEG to use cloud mocks so ctx.Cloud can be referenced within NewController.
negController, _ := neg.NewController(ctx.Cloud, ctx, lbc.Translator, namer, flags.F.ResyncPeriod)
negController := neg.NewController(ctx.Cloud, ctx, lbc.Translator, namer, flags.F.ResyncPeriod)
go negController.Run(stopCh)
glog.V(0).Infof("negController started")
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ type LoadBalancerController struct {
func NewLoadBalancerController(
ctx *context.ControllerContext,
clusterManager *ClusterManager,
stopCh chan struct{}) (*LoadBalancerController, error) {
stopCh chan struct{}) *LoadBalancerController {

broadcaster := record.NewBroadcaster()
broadcaster.StartLogging(glog.Infof)
Expand Down Expand Up @@ -180,7 +180,7 @@ func NewLoadBalancerController(

glog.V(3).Infof("Created new loadbalancer controller")

return &lbc, nil
return &lbc
}

// enqueueIngressForObject enqueues Ingresses that are associated with the
Expand Down
6 changes: 2 additions & 4 deletions pkg/controller/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,8 @@ func newLoadBalancerController(t *testing.T, cm *fakeClusterManager) *LoadBalanc

stopCh := make(chan struct{})
ctx := context.NewControllerContext(kubeClient, backendConfigClient, cm.fakeBackends, api_v1.NamespaceAll, 1*time.Minute, true, false)
lbc, err := NewLoadBalancerController(ctx, cm.ClusterManager, stopCh)
if err != nil {
t.Fatalf("%v", err)
}
lbc := NewLoadBalancerController(ctx, cm.ClusterManager, stopCh)

lbc.hasSynced = func() bool { return true }

// Create the default-backend service.
Expand Down
5 changes: 2 additions & 3 deletions pkg/neg/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ func NewController(
ctx *context.ControllerContext,
zoneGetter zoneGetter,
namer networkEndpointGroupNamer,
resyncPeriod time.Duration,
) (*Controller, error) {
resyncPeriod time.Duration) *Controller {
// init event recorder
// TODO: move event recorder initializer to main. Reuse it among controllers.
eventBroadcaster := record.NewBroadcaster()
Expand Down Expand Up @@ -137,7 +136,7 @@ func NewController(
},
})
ctx.AddHealthCheck("neg-controller", negController.IsHealthy)
return negController, nil
return negController
}

func (c *Controller) Run(stopCh <-chan struct{}) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/neg/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import (
func newTestController(kubeClient kubernetes.Interface) *Controller {
backendConfigClient := backendconfigclient.NewSimpleClientset()
context := context.NewControllerContext(kubeClient, backendConfigClient, nil, apiv1.NamespaceAll, 1*time.Second, true, false)
controller, _ := NewController(
controller := NewController(
NewFakeNetworkEndpointGroupCloud("test-subnetwork", "test-network"),
context,
NewFakeZoneGetter(),
Expand Down

0 comments on commit f505c18

Please sign in to comment.