-
Notifications
You must be signed in to change notification settings - Fork 304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sync one ingress #106
Sync one ingress #106
Conversation
Also remove more state from LBC.
- If the Ingress was deleted, only perform a GC. - Only update the Ingress that was changed.
Look at this change on a commit wise basis, otherwise will be hard to review. |
@@ -54,6 +54,7 @@ func NewFirewallPool(cloud Firewall, namer *utils.Namer) SingleFirewallPool { | |||
|
|||
// Sync sync firewall rules with the cloud. | |||
func (fr *FirewallRules) Sync(nodePorts []int64, nodeNames []string) error { | |||
glog.V(4).Infof("Sync(%v, %v)", nodePorts, nodeNames) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Sync Firewall (%v, %v)"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be clear from the filename in the log line
} | ||
if igErr != nil { | ||
return igErr | ||
if len(lbNames) == 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
merge it with the previous if statement?
Add a comment to say if there is no lbs. Remove instance group and firewall
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Interface: kubeClient.Core().Events(""), | ||
}) | ||
lbc := LoadBalancerController{ | ||
client: kubeClient, | ||
ctx: ctx, | ||
ingLister: StoreToIngressLister{Store: ctx.IngressInformer.GetStore()}, | ||
nodeLister: ctx.NodeInformer.GetIndexer(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably makes sense to throw nodeLister and getReadyNodes into Translator.
IngressInformer cache.SharedIndexInformer | ||
ServiceInformer cache.SharedIndexInformer | ||
PodInformer cache.SharedIndexInformer | ||
NodeInformer cache.SharedIndexInformer | ||
EndpointInformer cache.SharedIndexInformer | ||
|
||
// Map of namespace => record.EventRecorder. | ||
recorders map[string]record.EventRecorder |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EventRecorder per namespace?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit confused by this too. The service controller doesn't specify the namespace:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's keep this for now, I'll remove in a later commit once we resolve the unit test log spam
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SGTM
) | ||
|
||
const ( | ||
nodeResyncPeriod = 1 * time.Second |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resync every second?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
? what do you want me to do here? This is the existing policy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we rename to something else? Looks like this is just the frequency that the PeriodicTaskQueue checks the queue, not at which items in the queue are re-enqueued. Am I mistaken?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed to nodeUpdatePeriod
|
||
// getReadyNodeNames returns names of schedulable, ready nodes from the node lister. | ||
func getReadyNodeNames(lister listers.NodeLister) ([]string, error) { | ||
nodeNames := []string{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know you didn't write this, but
Nit: var nodeNames []string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -51,6 +51,26 @@ func NewControllerContext(kubeClient kubernetes.Interface, namespace string, res | |||
return context | |||
} | |||
|
|||
// HasSynced returns true if all relevant informers has been synced. | |||
func (ctx *ControllerContext) HasSynced() bool { | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra space
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -105,6 +105,8 @@ 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)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Provided only 5 values - expected 6.
Typo: "lne(backendServicePorts)"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -174,15 +174,17 @@ func (c *ClusterManager) GC(lbNames []string, nodePorts []backends.ServicePort) | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// This method ignores googleapi 404 errors (StatusNotFound). (line 155)
Is this true? If so, where does it happen in this function?
} | ||
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
report value of 'defaultBackend'(?)
@@ -0,0 +1,317 @@ | |||
/* | |||
Copyright 2017 The Kubernetes Authors. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/2017/2018/
@@ -0,0 +1,72 @@ | |||
/* | |||
Copyright 2017 The Kubernetes Authors. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2018
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We typically don't update the year as it causes too much spam.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't an update. This is a new file. (I agree for changes to files the copyright isn't normally changed.)
// NodeController synchronizes the state of the nodes to the unmanaged instance | ||
// groups. | ||
type NodeController struct { | ||
lister cache.Indexer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
newbie comment: is it worth commenting members? Is there style guidance on always commenting struct/class member variables? (In google c++, we say we should.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point, yes in general unless extremely obvious.
portMap := map[int64]bool{} | ||
for _, p := range svcPorts { | ||
if p.NEGEnabled { | ||
if t.negEnabled && p.NEGEnabled { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a bug fix? If so, should it go in its own commit?
|
||
ctx.NodeInformer.AddEventHandler(cache.ResourceEventHandlerFuncs{ | ||
AddFunc: c.queue.Enqueue, | ||
DeleteFunc: c.queue.Enqueue, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a TODO here that we need to improve this NodeController?
We don't react on the UpdateFunc because it's supposedly very noisy. However, when new nodes are added, they are typically NotReady. This means in practice that instance groups are synced when the NodeInformer re-calls AddFunc (every 10 minutes).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
/retest |
A bunch of patches: