Skip to content
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

Merged
merged 10 commits into from
Jan 29, 2018
Merged

Sync one ingress #106

merged 10 commits into from
Jan 29, 2018

Conversation

bowei
Copy link
Member

@bowei bowei commented Jan 16, 2018

A bunch of patches:

  • A lot of clean up and movement
  • Sync one ingress (as opposed to all) in Checkpoint
  • Call GC explicitly when an Ingress is deleted
  • Shutdown() firewall when there are no more Ingresses

@bowei bowei requested a review from nicksardo January 16, 2018 18:35
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jan 16, 2018
@bowei
Copy link
Member Author

bowei commented Jan 16, 2018

@G-Harmon

@bowei
Copy link
Member Author

bowei commented Jan 16, 2018

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Sync Firewall (%v, %v)"

Copy link
Member Author

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 {
Copy link
Contributor

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

Copy link
Member Author

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(),
Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EventRecorder per namespace?

Copy link
Contributor

@nicksardo nicksardo Jan 17, 2018

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:

https://github.com/kubernetes/kubernetes/blob/master/pkg/controller/service/service_controller.go#L118

Copy link
Member Author

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

Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resync every second?

Copy link
Member Author

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.

Copy link
Contributor

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?

Copy link
Member Author

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{}
Copy link
Contributor

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

Copy link
Member Author

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 {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra space

Copy link
Member Author

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))
Copy link
Contributor

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)"

Copy link
Member Author

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)
}
Copy link
Contributor

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)
Copy link
Contributor

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.
Copy link
Contributor

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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2018

Copy link
Member Author

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.

Copy link
Contributor

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
Copy link
Contributor

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.)

Copy link
Member Author

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 {
Copy link
Contributor

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,
Copy link
Contributor

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).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@bowei
Copy link
Member Author

bowei commented Jan 29, 2018

/retest

@bowei bowei merged commit 572e8e5 into kubernetes:master Jan 29, 2018
@bowei bowei deleted the sync-one-ingress branch January 29, 2018 22:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants