Skip to content

Commit

Permalink
Merge pull request #117 from bowei/missing-commit
Browse files Browse the repository at this point in the history
Code review comments
  • Loading branch information
nicksardo authored Jan 29, 2018
2 parents 572e8e5 + 77cf960 commit 20c4fe6
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 10 deletions.
1 change: 0 additions & 1 deletion pkg/context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ func NewControllerContext(kubeClient kubernetes.Interface, namespace string, res

// HasSynced returns true if all relevant informers has been synced.
func (ctx *ControllerContext) HasSynced() bool {

funcs := []func() bool{
ctx.IngressInformer.HasSynced,
ctx.ServiceInformer.HasSynced,
Expand Down
5 changes: 2 additions & 3 deletions pkg/controller/cluster_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func (c *ClusterManager) shutdown() error {
// If in performing the checkpoint the cluster manager runs out of quota, a
// googleapi 403 is returned.
func (c *ClusterManager) Checkpoint(lbs []*loadbalancers.L7RuntimeInfo, nodeNames []string, backendServicePorts []backends.ServicePort, namedPorts []backends.ServicePort, firewallPorts []int64) ([]*compute.InstanceGroup, error) {
glog.V(4).Infof("Checkpoint %q, len(lbs)=%v, len(nodeNames)=%v, lne(backendServicePorts)=%v, len(namedPorts)=%v, len(firewallPorts)=%v", len(lbs), len(nodeNames), len(backendServicePorts), len(namedPorts), len(firewallPorts))
glog.V(4).Infof("Checkpoint(%v lbs, %v nodeNames, %v backendServicePorts, %v namedPorts, %v firewallPorts)", len(lbs), len(nodeNames), len(backendServicePorts), len(namedPorts), len(firewallPorts))

if len(namedPorts) != 0 {
// Add the default backend node port to the list of named ports for instance groups.
Expand Down Expand Up @@ -180,8 +180,7 @@ func (c *ClusterManager) GC(lbNames []string, nodePorts []backends.ServicePort)
if err := c.instancePool.DeleteInstanceGroup(igName); err != err {
return err
}
}
if len(lbNames) == 0 {
glog.V(2).Infof("Shutting down firewall as there are no loadbalancers")
c.firewallPool.Shutdown()
}

Expand Down
14 changes: 10 additions & 4 deletions pkg/controller/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,18 @@ import (
)

const (
nodeResyncPeriod = 1 * time.Second
nodeUpdatePeriod = 1 * time.Second
)

// NodeController synchronizes the state of the nodes to the unmanaged instance
// groups.
type NodeController struct {
// lister is a cache of the k8s Node resources.
lister cache.Indexer
queue utils.TaskQueue
cm *ClusterManager
// queue is the TaskQueue used to manage the node worker updates.
queue utils.TaskQueue
// cm is the shared ClusterManager interface.
cm *ClusterManager
}

// NewNodeController returns a new node update controller.
Expand All @@ -48,14 +51,17 @@ func NewNodeController(ctx *context.ControllerContext, cm *ClusterManager) *Node
ctx.NodeInformer.AddEventHandler(cache.ResourceEventHandlerFuncs{
AddFunc: c.queue.Enqueue,
DeleteFunc: c.queue.Enqueue,
// TODO: watch updates for Nodes going from NotReady to Ready.
// Otherwise the controller will wait until the complete
// refresh to process the node.
})

return c
}

// Run a go routine to process updates for the controller.
func (c *NodeController) Run(stopCh chan struct{}) {
go c.queue.Run(nodeResyncPeriod, stopCh)
go c.queue.Run(nodeUpdatePeriod, stopCh)
}

// Run a go routine to process updates for the controller.
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/translator/translator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ func TestGatherFirewallPorts(t *testing.T) {
}
for _, p := range res {
if _, ok := int64ToMap(tc.want)[p]; !ok {
t.Errorf("firewall port %v is missing, (got %v, want %v)", p, res, tc.want)
t.Errorf("firewall port %v is missing, (got %v, want %v); defaultBackend=%v", p, res, tc.want, tc.defaultBackend)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ func uniq(nodePorts []backends.ServicePort) []backends.ServicePort {

// getReadyNodeNames returns names of schedulable, ready nodes from the node lister.
func getReadyNodeNames(lister listers.NodeLister) ([]string, error) {
nodeNames := []string{}
var nodeNames []string
nodes, err := lister.ListWithPredicate(utils.NodeIsReady)
if err != nil {
return nodeNames, err
Expand Down

0 comments on commit 20c4fe6

Please sign in to comment.