Skip to content

Conversation

@andrewsykim
Copy link
Contributor

  • removes /app/watchers package and all it's global variables.
  • uses shared informer factory to consolidate event handling into one informer per resource
  • uses shared informers WatchForCacheSync to consolidate all calls to HasSynced
  • uses interfaces where possible for more testable code
  • makes a few optimizations since we can do less type assertions

sendHeartBeat(healthChan, "NPC")
}
glog.V(1).Info("Performing periodic sync of iptables to reflect network policies")
err := npc.Sync()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we can technically get rid of this because it should be covered by the resync period we pass into the informers (this was the case previously too)

Copy link
Contributor Author

@andrewsykim andrewsykim Apr 8, 2018

Choose a reason for hiding this comment

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

same with service and routes controller, we can probably rely on the OnUpdate events that are generated every resync period

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alternatively keep this but set the resync period to 0 for all informers

Copy link
Member

Choose a reason for hiding this comment

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

Writing controller that handles all the corner cases is hard :)

Ideally (in the sense of strong consistency) we recive an update and act on it. Additionally informer can be set to a resync period which will take care of any missed updates from API server for what ever reason.

If we remove periodic sync, in this scenario, there is no control loop to reconcile (eventual consistent) desired state and actual state.

Alternativley if we keep resync period to 0 then if for any reason cache/informer miss an update from API server, then it will have stale data.

AFAIK, earlier design and with your changes, controller (w.r.t resync period, and periodic loop) is similar to kube-proxy.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think the right thing for our case is to set resync period on informers to 0 and keep the main period sync loop we have for each controller (can be in a future PR). Reason being is that if each OnUpdate call is just calling npc.sync() then we're calling npc.sync() per resource update event when we only need to call it once.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right now we set resync period and run a separate syncloop which is is unnecessary.

return errors.New("Failed to create network routing controller: " + err.Error())
}

nodeInformer.AddEventHandler(nrc.NodeEventHandler)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will follow up in another PR so that routes controller has service and endpoints event handlers

npc.PodEventHandler = npc.newPodEventHandler()

npc.nsLister = nsInformer.GetIndexer()
npc.NamespaceEventHandler = npc.newNetworkPolicyEventHandler()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

oops

@andrewsykim andrewsykim force-pushed the shared-informer branch 2 times, most recently from 7a7bb57 to 8890e44 Compare April 8, 2018 21:19
@andrewsykim
Copy link
Contributor Author

There's some conflicts from #348 I'll fix it shortly

@andrewsykim andrewsykim force-pushed the shared-informer branch 4 times, most recently from 629ed43 to 81a8c7c Compare April 9, 2018 14:28
Copy link
Member

@murali-reddy murali-reddy left a comment

Choose a reason for hiding this comment

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

Tested out the changes in the pr. Overall looks good to me.

sendHeartBeat(healthChan, "NPC")
}
glog.V(1).Info("Performing periodic sync of iptables to reflect network policies")
err := npc.Sync()
Copy link
Member

Choose a reason for hiding this comment

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

Writing controller that handles all the corner cases is hard :)

Ideally (in the sense of strong consistency) we recive an update and act on it. Additionally informer can be set to a resync period which will take care of any missed updates from API server for what ever reason.

If we remove periodic sync, in this scenario, there is no control loop to reconcile (eventual consistent) desired state and actual state.

Alternativley if we keep resync period to 0 then if for any reason cache/informer miss an update from API server, then it will have stale data.

AFAIK, earlier design and with your changes, controller (w.r.t resync period, and periodic loop) is similar to kube-proxy.

@murali-reddy
Copy link
Member

thanks @andrewsykim this is massive clean up.

@roffe
Copy link
Contributor

roffe commented Apr 10, 2018

looks good, me and my morning coffe gives 5 sunny thumbs up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants