Skip to content

Commit

Permalink
remove fullSyncGroup
Browse files Browse the repository at this point in the history
  • Loading branch information
ceclinux committed Mar 30, 2021
1 parent bbf81dd commit 44b5abc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
17 changes: 5 additions & 12 deletions pkg/agent/controller/egress/egress_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,6 @@ func NewEgressController(
c.ReplaceEgressGroups(policies)
return nil
}
c.fullSyncGroup.Add(1)
c.fullSyncWaitGroup = &c.fullSyncGroup

egressInformer.Informer().AddEventHandlerWithResyncPeriod(
cache.ResourceEventHandlerFuncs{
Expand Down Expand Up @@ -329,9 +327,9 @@ func (c *Controller) addEgressPolicy(obj interface{}) {
klog.Errorf(err.Error())
return
}
c.ofClient.InstallSNATMarkFlows(net.ParseIP(egressIP), id)
if err != nil {
klog.Errorf(err.Error())
err2 := c.ofClient.InstallSNATMarkFlows(net.ParseIP(egressIP), id)
if err2 != nil {
klog.Errorf(err2.Error())
return
}
errroute := c.routeClient.AddSNATRule(net.ParseIP(egressIP), id)
Expand Down Expand Up @@ -373,6 +371,8 @@ func (c *Controller) updateEgressPolicy(old, cur interface{}) {

}
if isLocalIP(newEgressIP) {
c.IPAllocatorLock.Lock()
defer c.IPAllocatorLock.Unlock()
id, errAllocate := c.IPAllocator.allocateForIP(newEgressIP)
klog.Infof("%#v\n", c.IPAllocator)

Expand Down Expand Up @@ -432,9 +432,6 @@ func (c *Controller) Run(stopCh <-chan struct{}) {
}

go wait.NonSlidingUntil(c.watch, 5*time.Second, stopCh)

klog.Infof("Waiting for all watchers to complete full sync")
c.fullSyncGroup.Wait()
// Batch install all rules in queue after fullSync is finished.
for i := 0; i < defaultWorkers; i++ {
go wait.Until(c.worker, time.Second, stopCh)
Expand Down Expand Up @@ -612,8 +609,6 @@ loop:
}
if !c.fullSynced {
c.fullSynced = true
// Notify fullSyncWaitGroup that all events before bookmark is handled
c.fullSyncWaitGroup.Done()
}

for {
Expand Down Expand Up @@ -662,7 +657,6 @@ type Controller struct {
egressPolicyListerSynced cache.InformerSynced
routeClient route.Interface
ofClient openflow.Client
fullSyncGroup sync.WaitGroup
queue workqueue.RateLimitingInterface
objectType string
setByGroup map[string]v1beta1.GroupMemberSet
Expand All @@ -682,7 +676,6 @@ type Controller struct {
// lock protects connected.
lock sync.RWMutex
// group to be notified when each watcher receives bookmark event
fullSyncWaitGroup *sync.WaitGroup
// fullSynced indicates if the resource has been synced at least once since agent started.
fullSynced bool
}
4 changes: 4 additions & 0 deletions pkg/agent/route/route_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,8 +355,12 @@ func (c *Client) restoreIptablesData(podCIDR *net.IPNet, podIPSet string, snatMa
writeLine(iptablesData, "*nat")
writeLine(iptablesData, iptables.MakeChainLine(antreaPostRoutingChain))
// Egress rule must be inserted before the default masquerade rule.
klog.Infof("%#v\n", snatMarkToIP)

for snatMark, snatIP := range snatMarkToIP {
// Cannot reuse snatRuleSpec to generate the rule as it doesn't have "`" in the comment.
klog.Infof("%#v\n", snatMark)
klog.Infof("%#v\n", snatIP)
writeLine(iptablesData, []string{
"-A", antreaPostRoutingChain,
"-m", "comment", "--comment", `"Antrea: snat pod to external packets"`,
Expand Down

0 comments on commit 44b5abc

Please sign in to comment.